Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
genie::flux::GFlavorMixerFactory 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/GFlavorMixerFactory.h"

Classes

struct  Cleaner
 

Public Member Functions

genie::flux::GFlavorMixerIGetFlavorMixer (const std::string &)
 
bool IsKnownFlavorMixer (const std::string &)
 
const std::vector< std::string > & AvailableFlavorMixers () const
 
bool RegisterCreator (std::string name, GFlavorMixerICtorFuncPtr_t ctorptr, bool *ptr)
 

Static Public Member Functions

static GFlavorMixerFactoryInstance ()
 

Private Member Functions

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

Private Attributes

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

Static Private Attributes

static GFlavorMixerFactoryfgTheInstance
 

Friends

struct Cleaner
 

Detailed Description

Definition at line 35 of file GFlavorMixerFactory.h.

Constructor & Destructor Documentation

genie::flux::GFlavorMixerFactory::GFlavorMixerFactory ( )
private

Definition at line 22 of file GFlavorMixerFactory.cxx.

References fgTheInstance.

Referenced by Instance().

23 {
24  fgTheInstance = this; // record created self in static pointer
25 }
static GFlavorMixerFactory * fgTheInstance
genie::flux::GFlavorMixerFactory::~GFlavorMixerFactory ( )
privatevirtual

Definition at line 27 of file GFlavorMixerFactory.cxx.

References fgTheInstance.

28 {
29  fgTheInstance = 0;
30 }
static GFlavorMixerFactory * fgTheInstance
genie::flux::GFlavorMixerFactory::GFlavorMixerFactory ( const GFlavorMixerFactory )
private

Member Function Documentation

const std::vector< std::string > & genie::flux::GFlavorMixerFactory::AvailableFlavorMixers ( ) const

Definition at line 78 of file GFlavorMixerFactory.cxx.

References fFunctionMap, and listnames.

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
85  std::map<std::string, GFlavorMixerICtorFuncPtr_t>::const_iterator itr;
86  for ( itr = fFunctionMap.begin(); itr != fFunctionMap.end(); ++itr )
87  listnames.push_back(itr->first);
88 
89  return listnames;
90 }
std::vector< std::string > listnames
std::map< std::string, GFlavorMixerICtorFuncPtr_t > fFunctionMap
GFlavorMixerI * genie::flux::GFlavorMixerFactory::GetFlavorMixer ( const std::string name)

Definition at line 47 of file GFlavorMixerFactory.cxx.

References fFunctionMap, LOG, and pWARN.

48 {
49  GFlavorMixerI* 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[]
53  std::map<std::string, GFlavorMixerICtorFuncPtr_t>::iterator itr
54  = fFunctionMap.find(name);
55  if ( fFunctionMap.end() != itr ) {
56  // found an appropriate entry in the list
57  GFlavorMixerICtorFuncPtr_t foo = itr->second; // this is the function
58  p = (*foo)(); // use function to create the GFlavorMixerI
59  }
60  if ( ! p ) {
61  LOG("Flux",pWARN) << "### GFlavorMixerFactory WARNING: "
62  << "GFlavorMixerI " << name << " is not known";
63  }
64  return p;
65 }
const XML_Char * name
Definition: expat.h:151
genie::flux::GFlavorMixerI *(* GFlavorMixerICtorFuncPtr_t)()
const char * p
Definition: xmltok.h:285
#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, GFlavorMixerICtorFuncPtr_t > fFunctionMap
GFlavorMixerFactory & genie::flux::GFlavorMixerFactory::Instance ( void  )
static

Definition at line 32 of file GFlavorMixerFactory.cxx.

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

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

Definition at line 67 of file GFlavorMixerFactory.cxx.

References fFunctionMap.

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

Definition at line 92 of file GFlavorMixerFactory.cxx.

References fBoolPtrMap, and fFunctionMap.

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

Friends And Related Function Documentation

friend struct Cleaner
friend

Definition at line 89 of file GFlavorMixerFactory.h.

Member Data Documentation

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

Definition at line 61 of file GFlavorMixerFactory.h.

Referenced by RegisterCreator().

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

Definition at line 63 of file GFlavorMixerFactory.h.

Referenced by AvailableFlavorMixers().


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