LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
evgb::EvtTimeShiftFactory Class Reference

#include "EvtTimeShiftFactory.h"

Classes

struct  Cleaner
 

Public Member Functions

evgb::EvtTimeShiftIGetEvtTimeShift (const std::string &name, const std::string &config="") const
 
bool IsKnownEvtTimeShift (const std::string &)
 
const std::vector< std::string > & AvailableEvtTimeShift () const
 
void Print () const
 
bool RegisterCreator (std::string name, EvtTimeShiftICtorFuncPtr_t ctorptr, bool *ptr)
 

Static Public Member Functions

static EvtTimeShiftFactoryInstance ()
 

Private Member Functions

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

Private Attributes

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

Static Private Attributes

static EvtTimeShiftFactoryfgTheInstance
 

Friends

struct Cleaner
 

Detailed Description

Definition at line 33 of file EvtTimeShiftFactory.h.

Constructor & Destructor Documentation

evgb::EvtTimeShiftFactory::EvtTimeShiftFactory ( )
private

Definition at line 21 of file EvtTimeShiftFactory.cxx.

References fgTheInstance.

Referenced by Instance().

22 {
23  fgTheInstance = this; // record created self in static pointer
24 }
static EvtTimeShiftFactory * fgTheInstance
evgb::EvtTimeShiftFactory::~EvtTimeShiftFactory ( )
privatevirtual

Definition at line 26 of file EvtTimeShiftFactory.cxx.

References fgTheInstance.

27 {
28  fgTheInstance = 0;
29 }
static EvtTimeShiftFactory * fgTheInstance
evgb::EvtTimeShiftFactory::EvtTimeShiftFactory ( const EvtTimeShiftFactory )
private

Member Function Documentation

const std::vector< std::string > & evgb::EvtTimeShiftFactory::AvailableEvtTimeShift ( ) const

Definition at line 78 of file EvtTimeShiftFactory.cxx.

References fFunctionMap, and listnames.

Referenced by Print().

79 {
80  // list of names might be out of date due to new registrations
81  // rescan the std::map on each call (which won't be frequent)
82  listnames.clear();
83 
84  // scan map for registered names
86  for ( itr = fFunctionMap.begin(); itr != fFunctionMap.end(); ++itr )
87  listnames.push_back(itr->first);
88 
89  return listnames;
90 }
intermediate_table::const_iterator const_iterator
std::map< std::string, EvtTimeShiftICtorFuncPtr_t > fFunctionMap
std::vector< std::string > listnames
evgb::EvtTimeShiftI * evgb::EvtTimeShiftFactory::GetEvtTimeShift ( const std::string &  name,
const std::string &  config = "" 
) const

Definition at line 46 of file EvtTimeShiftFactory.cxx.

References fFunctionMap.

Referenced by evgb::GENIEHelper::GENIEHelper().

48 {
49  evgb::EvtTimeShiftI* p = 0;
50 
51  // we don't want map creating an entry if it doesn't exist
52  // so use map::find() not map::operator[]
54  = fFunctionMap.find(name);
55  if ( fFunctionMap.end() != itr ) {
56  // found an appropriate entry in the list
57  EvtTimeShiftICtorFuncPtr_t foo = itr->second; // this is the function
58  p = (*foo)(config); // use function to create the EvtTimeShiftI
59  }
60  if ( ! p ) {
61  std::cerr << "### EvtTimeShiftFactory WARNING: "
62  << "EvtTimeShiftI \"" << name << "\" is not known" << std::endl;
63  }
64  return p;
65 }
interface for event time distribution
Definition: EvtTimeShiftI.h:29
intermediate_table::const_iterator const_iterator
std::map< std::string, EvtTimeShiftICtorFuncPtr_t > fFunctionMap
evgb::EvtTimeShiftI *(* EvtTimeShiftICtorFuncPtr_t)(const std::string &)
EvtTimeShiftFactory & evgb::EvtTimeShiftFactory::Instance ( )
static

Definition at line 31 of file EvtTimeShiftFactory.cxx.

References EvtTimeShiftFactory(), fgTheInstance, and evgb::EvtTimeShiftFactory::Cleaner::UseMe().

Referenced by evgb::GENIEHelper::GENIEHelper().

32 {
33  // Cleaner dtor calls EvtTimeShiftFactory dtor at job end
34  static Cleaner cleaner;
35 
36  if ( ! fgTheInstance ) {
37  // need to create one
38  cleaner.UseMe(); // dummy call to quiet compiler warnings
40  }
41 
42  return *fgTheInstance;
43 }
static EvtTimeShiftFactory * fgTheInstance
bool evgb::EvtTimeShiftFactory::IsKnownEvtTimeShift ( const std::string &  name)

Definition at line 67 of file EvtTimeShiftFactory.cxx.

References fFunctionMap.

68 {
69  // check if we know the name
70  bool res = false;
72  = fFunctionMap.find(name);
73  if ( fFunctionMap.end() != itr ) res = true;
74  return res;
75 }
intermediate_table::iterator iterator
std::map< std::string, EvtTimeShiftICtorFuncPtr_t > fFunctionMap
void evgb::EvtTimeShiftFactory::operator= ( const EvtTimeShiftFactory )
private
void evgb::EvtTimeShiftFactory::Print ( ) const

Definition at line 92 of file EvtTimeShiftFactory.cxx.

References AvailableEvtTimeShift().

Referenced by evgb::GENIEHelper::GENIEHelper().

93 {
94  const std::vector<std::string>& known = AvailableEvtTimeShift();
95  for (size_t i=0; i < known.size(); ++i) {
96  std::cout << " [" << std::setw(2) << i << "] " << known[i] << std::endl;
97  }
98 }
const std::vector< std::string > & AvailableEvtTimeShift() const
bool evgb::EvtTimeShiftFactory::RegisterCreator ( std::string  name,
EvtTimeShiftICtorFuncPtr_t  ctorptr,
bool *  ptr 
)

Definition at line 100 of file EvtTimeShiftFactory.cxx.

References fBoolPtrMap, and fFunctionMap.

103 {
104  // record new functions for creating processes
105  fFunctionMap[name] = foo;
106  fBoolPtrMap[name] = boolptr;
107  return true;
108 }
std::map< std::string, EvtTimeShiftICtorFuncPtr_t > fFunctionMap
std::map< std::string, bool * > fBoolPtrMap

Friends And Related Function Documentation

friend struct Cleaner
friend

Definition at line 91 of file EvtTimeShiftFactory.h.

Member Data Documentation

std::map<std::string, bool*> evgb::EvtTimeShiftFactory::fBoolPtrMap
private

Definition at line 63 of file EvtTimeShiftFactory.h.

Referenced by RegisterCreator().

std::map<std::string, EvtTimeShiftICtorFuncPtr_t> evgb::EvtTimeShiftFactory::fFunctionMap
private
EvtTimeShiftFactory * evgb::EvtTimeShiftFactory::fgTheInstance
staticprivate
std::vector<std::string> evgb::EvtTimeShiftFactory::listnames
mutableprivate

Definition at line 65 of file EvtTimeShiftFactory.h.

Referenced by AvailableEvtTimeShift().


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