SimElecMaker Class Reference

#include <SimElecMaker.h>

Inheritance diagram for SimElecMaker:
SimElecMakerProxy< T >

List of all members.

Static Public Member Functions

static SimElectronicsCreate (std::string className, VldContext context, TRandom *random)
static Bool_t HasRegisteredClass (std::string className)

Protected Types

typedef std::map< std::string,
SimElecMaker * > 
MakerMap_t

Protected Member Functions

 SimElecMaker (const char *className)
virtual SimElectronicsCreate (VldContext context, TRandom *random) const =0
 SimElecMaker ()
virtual ~SimElecMaker ()
 ClassDef (SimElecMaker, 0)

Static Protected Member Functions

static MakerMap_tGetMakerMap ()

Detailed Description

Definition at line 17 of file SimElecMaker.h.


Member Typedef Documentation

typedef std::map<std::string,SimElecMaker*> SimElecMaker::MakerMap_t [protected]

Definition at line 31 of file SimElecMaker.h.


Constructor & Destructor Documentation

SimElecMaker::SimElecMaker ( const char *  className  )  [protected]

Definition at line 41 of file SimElecMaker.cxx.

References GetMakerMap().

00042 {
00043   std::string tmp(className);
00044   //std::cout << "Adding Maker: " << tmp << std::endl;
00045   GetMakerMap().insert(std::pair<std::string,SimElecMaker*>(tmp,this));
00046 }

SimElecMaker::SimElecMaker (  )  [inline, protected]

Definition at line 34 of file SimElecMaker.h.

00034 { }

virtual SimElecMaker::~SimElecMaker (  )  [inline, protected, virtual]

Definition at line 35 of file SimElecMaker.h.

00035 { }


Member Function Documentation

SimElecMaker::ClassDef ( SimElecMaker  ,
 
) [protected]
virtual SimElectronics* SimElecMaker::Create ( VldContext  context,
TRandom *  random 
) const [protected, pure virtual]

Implemented in SimElecMakerProxy< T >.

SimElectronics * SimElecMaker::Create ( std::string  className,
VldContext  context,
TRandom *  random 
) [static]

Definition at line 6 of file SimElecMaker.cxx.

References it.

Referenced by SimDetector::Config(), and SimDetector::SimDetector().

00009 {
00010   // Find the concrete factory:
00011   MakerMap_t::iterator it = GetMakerMap().find(className);
00012  
00013 
00014   if(it == GetMakerMap().end()) {
00015     // If it doesn't exist, return null.
00016     return 0;
00017   } else {
00018     // Otherwise, get the concrete factory to make one.
00019     SimElectronics* elec = it->second->Create(context,random);
00020     return elec;
00021   }
00022 
00023   // Make compiler happy:
00024   return 0;
00025 }

SimElecMaker::MakerMap_t & SimElecMaker::GetMakerMap (  )  [static, protected]

Definition at line 49 of file SimElecMaker.cxx.

Referenced by HasRegisteredClass(), and SimElecMaker().

00050 {
00051   // The whole point to this little function is to hide the 
00052   // static map from the compiler, to avoid
00053   // the "static initialization order fiasco"
00054   // ref: http://www.parashift.com/c++-faq-lite/ctors.html section 10.12
00055   
00056   // This object gets created on the first call,
00057   // thus ensuring it exists whenever it's needed. (i.e. before main())
00058   static MakerMap_t theMap;
00059   return theMap;
00060 }

Bool_t SimElecMaker::HasRegisteredClass ( std::string  className  )  [static]

Definition at line 27 of file SimElecMaker.cxx.

References GetMakerMap(), and it.

Referenced by SimDetector::Config().

00028 {
00029   // Find the concrete factory:
00030   MakerMap_t::iterator it = GetMakerMap().find(className);
00031   
00032   if(it == GetMakerMap().end()) {
00033     // If it doesn't exist, return null.
00034     return false;
00035   };
00036   return true;
00037 }


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1