/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/lcio/src/cpp/src/SIO/SIOHandlerMgr.cc

Go to the documentation of this file.
00001 #include "SIO/SIOHandlerMgr.h"
00002 
00003 #include "SIO/SIOSimCalHitHandler.h" 
00004 #include "SIO/SIORawCalHitHandler.h" 
00005 #include "SIO/SIOCalHitHandler.h" 
00006 #include "SIO/SIOSimTrackHitHandler.h" 
00007 #include "SIO/SIOTrackHandler.h" 
00008 #include "SIO/SIOClusterHandler.h" 
00009 #include "SIO/SIOTPCHitHandler.h" 
00010 #include "SIO/SIOTrackerHitHandler.h" 
00011 #include "SIO/SIOParticleHandler.h" 
00012 #include "SIO/SIOStrVecHandler.h"
00013 #include "SIO/SIOFloatVecHandler.h" 
00014 #include "SIO/SIOIntVecHandler.h" 
00015 #include "SIO/SIOReconstructedParticleHandler.h" 
00016 #include "SIO/SIOLCRelationHandler.h" 
00017 #include "SIO/SIOLCGenericObjectHandler.h" 
00018 #include "SIO/SIOTPCHitHandler.h" 
00019 #include "SIO/SIOTrackerRawDataHandler.h" 
00020 #include "SIO/SIOTrackerDataHandler.h" 
00021 #include "SIO/SIOTrackerPulseHandler.h" 
00022 #include "SIO/SIOVertexHandler.h"
00023 
00024 #include "EVENT/LCIO.h"
00025 
00026 using namespace EVENT ;
00027 
00028 namespace SIO {
00029   
00030   SIOHandlerMgr* SIOHandlerMgr::_me  = 0 ;
00031   
00032   
00033   SIOHandlerMgr::SIOHandlerMgr(){
00034     
00035     // add instances for all types to the map
00036     
00037     _map[ LCIO::MCPARTICLE     ] = new SIOParticleHandler ;
00038     _map[ LCIO::SIMCALORIMETERHIT ] = new SIOSimCalHitHandler ;
00039     _map[ LCIO::RAWCALORIMETERHIT ] = new SIORawCalHitHandler ;
00040     _map[ LCIO::CALORIMETERHIT ] = new SIOCalHitHandler ;
00041     _map[ LCIO::SIMTRACKERHIT ] = new SIOSimTrackHitHandler ;
00042     _map[ LCIO::TPCHIT ] = new SIOTPCHitHandler ;
00043     _map[ LCIO::TRACKERRAWDATA ] = new SIOTrackerRawDataHandler ;
00044     _map[ LCIO::TRACKERDATA ] = new SIOTrackerDataHandler ;
00045     _map[ LCIO::TRACKERPULSE ] = new SIOTrackerPulseHandler ;
00046     _map[ LCIO::TRACKERHIT ] = new SIOTrackerHitHandler ;
00047     _map[ LCIO::TRACK ] = new SIOTrackHandler ;
00048     _map[ LCIO::CLUSTER ] = new SIOClusterHandler ;
00049     _map[ LCIO::RECONSTRUCTEDPARTICLE ] = new SIOReconstructedParticleHandler ;
00050     _map[ LCIO::LCRELATION] = new SIOLCRelationHandler ;
00051     _map[ LCIO::VERTEX] = new SIOVertexHandler ;
00052     // generic arrays/vectors
00053     _map[ LCIO::LCSTRVEC ] = new SIOStrVecHandler ;
00054     _map[ LCIO::LCFLOATVEC ] = new SIOFloatVecHandler ;
00055     _map[ LCIO::LCINTVEC ] = new SIOIntVecHandler ;
00056     _map[ LCIO::LCGENERICOBJECT ] = new SIOLCGenericObjectHandler ;
00057   } 
00058   
00059   SIOHandlerMgr::~SIOHandlerMgr(){
00060       // just called at end of program ...
00061     // to make valgrind happy delete the handlers
00062     // -> doesn't work as destructor is not explicitely called at end of main  :(
00063     for( SIOHandlerMap::iterator iter = _map.begin() ; iter  != _map.end() ; iter++ ){
00064       //     std::cout << " deleting SIOHandler : " << iter->first << std::endl ;
00065       delete iter->second ;
00066     }
00067   }
00068   
00069   SIOHandlerMgr* SIOHandlerMgr::instance(){
00070         
00071     if( ! _me  ){
00072       _me  = new SIOHandlerMgr ;
00073     }
00074     return _me ;
00075   }
00076   
00077   SIOObjectHandler* SIOHandlerMgr::getHandler( const std::string& type ){
00078     
00079     if(  _map.find( type ) == _map.end( ) ) 
00080       return 0 ;
00081     
00082     return _map[ type ] ;
00083   }
00084   
00085   
00086   bool SIOHandlerMgr::registerHandler( const std::string& type, SIOObjectHandler* handler ){
00087         
00088     // check if type name does not yet exist  
00089     if(  _map.find( type ) != _map.end( ) ) 
00090       return false ;
00091     
00092     _map[ type ] = handler ;
00093     
00094     return true ;
00095   }
00096   
00097 } // namespace

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7