simb::EvtTimeDistFactory Class Reference

#include <EvtTimeDistFactory.h>

List of all members.

Classes

struct  Cleaner

Public Member Functions

simb::EvtTimeDistIGetEvtTimeDist (const std::string &, const std::string &)
bool IsKnownEvtTimeDist (const std::string &)
const std::vector< std::string > & AvailableEvtTimeDist () const
bool RegisterCreator (std::string name, EvtTimeDistICtorFuncPtr_t ctorptr, bool *ptr)

Static Public Member Functions

static EvtTimeDistFactoryInstance ()

Private Member Functions

 EvtTimeDistFactory ()
virtual ~EvtTimeDistFactory ()
 EvtTimeDistFactory (const EvtTimeDistFactory &)
void operator= (const EvtTimeDistFactory &)

Private Attributes

std::map< std::string,
EvtTimeDistICtorFuncPtr_t
fFunctionMap
std::map< std::string, bool * > fBoolPtrMap
std::vector< std::string > listnames

Static Private Attributes

static EvtTimeDistFactoryfgTheInstance

Friends

struct Cleaner

Detailed Description

Definition at line 33 of file EvtTimeDistFactory.h.


Constructor & Destructor Documentation

simb::EvtTimeDistFactory::EvtTimeDistFactory (  )  [private]

Definition at line 20 of file EvtTimeDistFactory.cxx.

References fgTheInstance.

Referenced by Instance().

00021 {
00022   fgTheInstance = this;   // record created self in static pointer
00023 }

simb::EvtTimeDistFactory::~EvtTimeDistFactory (  )  [private, virtual]

Definition at line 25 of file EvtTimeDistFactory.cxx.

References fgTheInstance.

00026 {
00027   fgTheInstance = 0;
00028 }

simb::EvtTimeDistFactory::EvtTimeDistFactory ( const EvtTimeDistFactory  )  [private]

Member Function Documentation

const std::vector< std::string > & simb::EvtTimeDistFactory::AvailableEvtTimeDist (  )  const

Definition at line 77 of file EvtTimeDistFactory.cxx.

References fFunctionMap, and listnames.

00078 {
00079   // list of names might be out of date due to new registrations
00080   // rescan the std::map on each call (which won't be frequent)
00081   listnames.clear();
00082 
00083   // scan map for registered names
00084   std::map<std::string, EvtTimeDistICtorFuncPtr_t>::const_iterator itr;
00085   for ( itr = fFunctionMap.begin(); itr != fFunctionMap.end(); ++itr )
00086     listnames.push_back(itr->first);
00087 
00088   return listnames;
00089 }

simb::EvtTimeDistI * simb::EvtTimeDistFactory::GetEvtTimeDist ( const std::string &  name,
const std::string &  config 
)

Definition at line 45 of file EvtTimeDistFactory.cxx.

References fFunctionMap.

00047 {
00048   simb::EvtTimeDistI* p = 0;
00049   
00050   // we don't want map creating an entry if it doesn't exist
00051   // so use map::find() not map::operator[]
00052   std::map<std::string, EvtTimeDistICtorFuncPtr_t>::iterator itr
00053     = fFunctionMap.find(name);
00054   if ( fFunctionMap.end() != itr ) { 
00055     // found an appropriate entry in the list
00056     EvtTimeDistICtorFuncPtr_t foo = itr->second;  // this is the function
00057     p = (*foo)(config);  // use function to create the EvtTimeDistI
00058   }
00059   if ( ! p ) {
00060     std::cerr << "### EvtTimeDistFactory WARNING: "
00061               << "EvtTimeDistI " << name << " is not known" << std::endl;
00062   }
00063   return p;
00064 }

EvtTimeDistFactory & simb::EvtTimeDistFactory::Instance (  )  [static]

Definition at line 30 of file EvtTimeDistFactory.cxx.

References EvtTimeDistFactory(), fgTheInstance, and simb::EvtTimeDistFactory::Cleaner::UseMe().

00031 {
00032   // Cleaner dtor calls EvtTimeDistFactory dtor at job end
00033   static Cleaner cleaner;
00034 
00035   if ( ! fgTheInstance ) {
00036     // need to create one
00037     cleaner.UseMe();   // dummy call to quiet compiler warnings
00038     fgTheInstance = new EvtTimeDistFactory();
00039   }
00040   
00041   return *fgTheInstance;
00042 }

bool simb::EvtTimeDistFactory::IsKnownEvtTimeDist ( const std::string &  name  ) 

Definition at line 66 of file EvtTimeDistFactory.cxx.

References fFunctionMap.

00067 {
00068   //  check if we know the name
00069   bool res = false;
00070   std::map<std::string, EvtTimeDistICtorFuncPtr_t>::iterator itr
00071     = fFunctionMap.find(name);
00072   if ( fFunctionMap.end() != itr ) res = true;
00073   return res;
00074 }

void simb::EvtTimeDistFactory::operator= ( const EvtTimeDistFactory  )  [private]
bool simb::EvtTimeDistFactory::RegisterCreator ( std::string  name,
EvtTimeDistICtorFuncPtr_t  ctorptr,
bool *  ptr 
)

Definition at line 91 of file EvtTimeDistFactory.cxx.

References fBoolPtrMap, and fFunctionMap.

00094 {
00095   // record new functions for creating processes
00096   fFunctionMap[name] = foo;
00097   fBoolPtrMap[name]  = boolptr;
00098   return true;
00099 }


Friends And Related Function Documentation

friend struct Cleaner [friend]

Definition at line 87 of file EvtTimeDistFactory.h.


Member Data Documentation

std::map<std::string, bool*> simb::EvtTimeDistFactory::fBoolPtrMap [private]

Definition at line 59 of file EvtTimeDistFactory.h.

Referenced by RegisterCreator().

std::vector<std::string> simb::EvtTimeDistFactory::listnames [mutable, private]

Definition at line 61 of file EvtTimeDistFactory.h.

Referenced by AvailableEvtTimeDist().


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

Generated on 19 Jan 2018 for loon by  doxygen 1.6.1