LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIOHandlerMgr.cc
Go to the documentation of this file.
1 #include "SIO/SIOHandlerMgr.h"
2 
5 #include "SIO/SIOCalHitHandler.h"
7 #include "SIO/SIOTrackHandler.h"
9 #include "SIO/SIOTPCHitHandler.h"
13 #include "SIO/SIOParticleHandler.h"
14 #include "SIO/SIOLCVecHandler.h"
18 #include "SIO/SIOTPCHitHandler.h"
22 #include "SIO/SIOVertexHandler.h"
23 
24 #include "EVENT/LCIO.h"
25 
26 namespace SIO {
27 
29 
30  // add instances for all types to the map
31  _map[ EVENT::LCIO::MCPARTICLE ] = std::make_shared<SIOParticleHandler>() ;
32  _map[ EVENT::LCIO::SIMCALORIMETERHIT ] = std::make_shared<SIOSimCalHitHandler>() ;
33  _map[ EVENT::LCIO::RAWCALORIMETERHIT ] = std::make_shared<SIORawCalHitHandler>() ;
34  _map[ EVENT::LCIO::CALORIMETERHIT ] = std::make_shared<SIOCalHitHandler>() ;
35  _map[ EVENT::LCIO::SIMTRACKERHIT ] = std::make_shared<SIOSimTrackHitHandler>() ;
36  _map[ EVENT::LCIO::TPCHIT ] = std::make_shared<SIOTPCHitHandler>() ;
37  _map[ EVENT::LCIO::TRACKERRAWDATA ] = std::make_shared<SIOTrackerRawDataHandler>() ;
38  _map[ EVENT::LCIO::TRACKERDATA ] = std::make_shared<SIOTrackerDataHandler>() ;
39  _map[ EVENT::LCIO::TRACKERPULSE ] = std::make_shared<SIOTrackerPulseHandler>() ;
40  _map[ EVENT::LCIO::TRACKERHIT ] = std::make_shared<SIOTrackerHitHandler>() ;
41  _map[ EVENT::LCIO::TRACKERHITPLANE ] = std::make_shared<SIOTrackerHitPlaneHandler>() ;
42  _map[ EVENT::LCIO::TRACKERHITZCYLINDER ] = std::make_shared<SIOTrackerHitZCylinderHandler>() ;
43  _map[ EVENT::LCIO::TRACK ] = std::make_shared<SIOTrackHandler>() ;
44  _map[ EVENT::LCIO::CLUSTER ] = std::make_shared<SIOClusterHandler>() ;
45  _map[ EVENT::LCIO::RECONSTRUCTEDPARTICLE ] = std::make_shared<SIOReconstructedParticleHandler>() ;
46  _map[ EVENT::LCIO::LCRELATION] = std::make_shared<SIOLCRelationHandler>() ;
47  _map[ EVENT::LCIO::VERTEX] = std::make_shared<SIOVertexHandler>() ;
48  // generic arrays/vectors
49  _map[ EVENT::LCIO::LCSTRVEC ] = std::make_shared<SIOStrVecHandler>() ;
50  _map[ EVENT::LCIO::LCFLOATVEC ] = std::make_shared<SIOFloatVecHandler>() ;
51  _map[ EVENT::LCIO::LCINTVEC ] = std::make_shared<SIOIntVecHandler>() ;
52  _map[ EVENT::LCIO::LCGENERICOBJECT ] = std::make_shared<SIOLCGenericObjectHandler>() ;
53  }
54 
55  //----------------------------------------------------------------------------
56 
58  auto findIter = _map.find( type );
59  if( findIter == _map.end( ) ) {
60  return nullptr ;
61  }
62  return findIter->second ;
63  }
64 
65  //----------------------------------------------------------------------------
66 
68  if( _map.find( type ) != _map.end( ) ) {
69  throw EVENT::Exception( "SIOHandlerMgr::registerHandler: Handler of type '" + type + "' already exists !" ) ;
70  }
71  _map[ type ] = std::move(handler) ;
72  }
73 
74 } // namespace
Base exception class for LCIO - all other exceptions extend this.
Definition: Exceptions.h:21
T end(T...args)
STL class.
T find(T...args)
STL class.
void registerHandler(const std::string &type, std::unique_ptr< SIOObjectHandler > handler)
Registers an instance of a handler for the given type.
SIOHandlerMap _map
The handler map.
Definition: SIOHandlerMgr.h:37
std::shared_ptr< SIOObjectHandler > getHandler(const std::string &type) const
Returns the instance of the handler for the given type - null if it doesn&#39;t exist.