Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
genie::flux::GFluxDriverFactory Class Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/genie/v3_00_06_p01/Linux64bit+2.6-2.12-e17-debug/GENIE-Generator/src/Tools/Flux/GFluxDriverFactory.h"

Classes

struct  Cleaner
 

Public Member Functions

genie::GFluxIGetFluxDriver (const std::string &)
 
bool IsKnownFluxDriver (const std::string &)
 
const std::vector< std::string > & AvailableFluxDrivers () const
 
bool RegisterCreator (std::string name, GFluxICtorFuncPtr_t ctorptr, bool *ptr)
 
void PrintConfig () const
 

Static Public Member Functions

static GFluxDriverFactoryInstance ()
 

Private Member Functions

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

Private Attributes

std::map< std::string, GFluxICtorFuncPtr_tfFunctionMap
 
std::map< std::string, bool * > fBoolPtrMap
 
std::vector< std::stringlistnames
 

Static Private Attributes

static GFluxDriverFactoryfgTheInstance
 

Friends

struct Cleaner
 

Detailed Description

Definition at line 38 of file GFluxDriverFactory.h.

Constructor & Destructor Documentation

genie::flux::GFluxDriverFactory::GFluxDriverFactory ( )
private

Definition at line 24 of file GFluxDriverFactory.cxx.

References fgTheInstance.

Referenced by Instance().

25 {
26  fgTheInstance = this; // record created self in static pointer
27 }
static GFluxDriverFactory * fgTheInstance
genie::flux::GFluxDriverFactory::~GFluxDriverFactory ( )
privatevirtual

Definition at line 29 of file GFluxDriverFactory.cxx.

References fgTheInstance.

30 {
31  fgTheInstance = 0;
32 }
static GFluxDriverFactory * fgTheInstance
genie::flux::GFluxDriverFactory::GFluxDriverFactory ( const GFluxDriverFactory )
private

Member Function Documentation

const std::vector< std::string > & genie::flux::GFluxDriverFactory::AvailableFluxDrivers ( ) const

Definition at line 80 of file GFluxDriverFactory.cxx.

References fFunctionMap, and listnames.

Referenced by main(), and PrintConfig().

81 {
82  // list of names might be out of date due to new registrations
83  // rescan the std::map on each call (which won't be frequent)
84  listnames.clear();
85 
86  // scan map for registered names
87  std::map<std::string, GFluxICtorFuncPtr_t>::const_iterator itr;
88  for ( itr = fFunctionMap.begin(); itr != fFunctionMap.end(); ++itr )
89  listnames.push_back(itr->first);
90 
91  return listnames;
92 }
std::vector< std::string > listnames
std::map< std::string, GFluxICtorFuncPtr_t > fFunctionMap
GFluxI * genie::flux::GFluxDriverFactory::GetFluxDriver ( const std::string name)

Definition at line 49 of file GFluxDriverFactory.cxx.

References fFunctionMap, LOG, and pWARN.

Referenced by main().

50 {
51  GFluxI* p = 0;
52 
53  // we don't want map creating an entry if it doesn't exist
54  // so use map::find() not map::operator[]
55  std::map<std::string, GFluxICtorFuncPtr_t>::iterator itr
56  = fFunctionMap.find(name);
57  if ( fFunctionMap.end() != itr ) {
58  // found an appropriate entry in the list
59  GFluxICtorFuncPtr_t foo = itr->second; // this is the function
60  p = (*foo)(); // use function to create the GFluxI
61  }
62  if ( ! p ) {
63  LOG("Flux",pWARN) << "### GFluxDriverFactory WARNING: "
64  << "GFluxI " << name << " is not known";
65  }
66  return p;
67 }
const XML_Char * name
Definition: expat.h:151
const char * p
Definition: xmltok.h:285
genie::GFluxI *(* GFluxICtorFuncPtr_t)()
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
#define pWARN
Definition: Messenger.h:61
std::map< std::string, GFluxICtorFuncPtr_t > fFunctionMap
GFluxDriverFactory & genie::flux::GFluxDriverFactory::Instance ( void  )
static

Definition at line 34 of file GFluxDriverFactory.cxx.

References fgTheInstance, GFluxDriverFactory(), and genie::flux::GFluxDriverFactory::Cleaner::UseMe().

Referenced by main().

35 {
36  // Cleaner dtor calls GFluxDriverFactory dtor at job end
37  static Cleaner cleaner;
38 
39  if ( ! fgTheInstance ) {
40  // need to create one
41  cleaner.UseMe(); // dummy call to quiet compiler warnings
43  }
44 
45  return *fgTheInstance;
46 }
static GFluxDriverFactory * fgTheInstance
bool genie::flux::GFluxDriverFactory::IsKnownFluxDriver ( const std::string name)

Definition at line 69 of file GFluxDriverFactory.cxx.

References fFunctionMap.

70 {
71  // check if we know the name
72  bool res = false;
73  std::map<std::string, GFluxICtorFuncPtr_t>::iterator itr
74  = fFunctionMap.find(name);
75  if ( fFunctionMap.end() != itr ) res = true;
76  return res;
77 }
const XML_Char * name
Definition: expat.h:151
std::map< std::string, GFluxICtorFuncPtr_t > fFunctionMap
void genie::flux::GFluxDriverFactory::operator= ( const GFluxDriverFactory )
private
void genie::flux::GFluxDriverFactory::PrintConfig ( void  ) const

Definition at line 104 of file GFluxDriverFactory.cxx.

References AvailableFluxDrivers(), om::cout, allTimeWatchdog::endl, MECModelEnuComparisons::i, and getGoodRuns4SAM::n.

105 {
106  const std::vector<std::string>& avail = AvailableFluxDrivers();
107  size_t n = avail.size();
108  std::cout << "GFluxDriverFactory has the following drivers registered:"
109  << std::endl;
110  for (size_t i=0; i<n; ++i) {
111  std::cout << " [" << std::setw(3) << i << "] "
112  << avail[i] << std::endl;
113  }
114 }
const std::vector< std::string > & AvailableFluxDrivers() const
OStream cout
Definition: OStream.cxx:6
bool genie::flux::GFluxDriverFactory::RegisterCreator ( std::string  name,
GFluxICtorFuncPtr_t  ctorptr,
bool *  ptr 
)

Definition at line 94 of file GFluxDriverFactory.cxx.

References fBoolPtrMap, and fFunctionMap.

97 {
98  // record new functions for creating processes
99  fFunctionMap[name] = foo;
100  fBoolPtrMap[name] = boolptr;
101  return true;
102 }
const XML_Char * name
Definition: expat.h:151
std::map< std::string, GFluxICtorFuncPtr_t > fFunctionMap
std::map< std::string, bool * > fBoolPtrMap

Friends And Related Function Documentation

friend struct Cleaner
friend

Definition at line 94 of file GFluxDriverFactory.h.

Member Data Documentation

std::map<std::string, bool*> genie::flux::GFluxDriverFactory::fBoolPtrMap
private

Definition at line 66 of file GFluxDriverFactory.h.

Referenced by RegisterCreator().

std::map<std::string, GFluxICtorFuncPtr_t> genie::flux::GFluxDriverFactory::fFunctionMap
private
GFluxDriverFactory * genie::flux::GFluxDriverFactory::fgTheInstance
staticprivate
std::vector<std::string> genie::flux::GFluxDriverFactory::listnames
mutableprivate

Definition at line 68 of file GFluxDriverFactory.h.

Referenced by AvailableFluxDrivers().


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