EvtKinFactory Class Reference

Create FluxGenerator and InteractionGenerator objects. More...

#include <EvtKinFactory.h>

List of all members.

Public Types

typedef FluxGenerator *(* FluxCreator )()
 pointer to function creating {Flux|Interaction}Generator
typedef FlavorModifier *(* FlavorCreator )()
typedef InteractionGenerator *(* InteractionCreator )()

Public Member Functions

bool RegisterFlux (const std::string &fluxname, FluxCreator creator)
 return 'true' is the registration was successful
bool RegisterFlavor (const std::string &flavorname, FlavorCreator creator)
bool RegisterInteraction (const std::string &intername, InteractionCreator creator)
bool UnregisterFlux (const std::string &fluxname)
 return 'true' if creator was previously registered
bool UnregisterFlavor (const std::string &flavorname)
bool UnregisterInteraction (const std::string &intername)
FluxGeneratorCreateFluxGenerator (const std::string &fluxname)
 create the requested object
FlavorModifierCreateFlavorModifier (const std::string &flavorname)
InteractionGeneratorCreateInteractionGenerator (const std::string &intername)
void Print (Option_t *option="") const
 list what we have

Static Public Member Functions

static EvtKinFactoryInstance ()

Private Types

typedef std::map< std::string,
FluxCreator
CallbackMapFlux
 map of creator function pointers keyed by name
typedef std::map< std::string,
FlavorCreator
CallbackMapFlavor
typedef std::map< std::string,
InteractionCreator
CallbackMapInteraction

Private Member Functions

 EvtKinFactory ()
 These are private.
 EvtKinFactory (const EvtKinFactory &)

Private Attributes

CallbackMapFlux fFluxCallbacks
CallbackMapFlavor fFlavorCallbacks
CallbackMapInteraction fInteractionCallbacks

Static Private Attributes

static EvtKinFactoryfInstance = 0
 initialize singleton

Detailed Description

Create FluxGenerator and InteractionGenerator objects.

EvtKinFactory creates various "Generator" objects. Pointers to functions creating different types of these are in a map, keyed by names. Creator functions have to be registered with factory using 'RegisterFlux' or 'RegisterGenerator' method, so that new types can be added without changing factory code. EvtKinFactory is a singleton.

FluxGenerator: supplies a flux of neutrinos FlavorModifier: flavor mixing InteractionGenerator: cross sections and final state particle lists

EvtKinFactory is adapted from Sergei's HistogramBlockFactor which is itself adapted from an example in "Modern C++ Design..." section 8.3

Author:
(last to touch it)
Author
rhatcher

Contact: rhatcher@fnal.gov

Id
EvtKinFactory.h,v 1.4 2006/06/21 04:13:00 rhatcher Exp

Definition at line 42 of file EvtKinFactory.h.


Member Typedef Documentation

typedef std::map<std::string, FlavorCreator> EvtKinFactory::CallbackMapFlavor [private]

Definition at line 53 of file EvtKinFactory.h.

typedef std::map<std::string, FluxCreator> EvtKinFactory::CallbackMapFlux [private]

map of creator function pointers keyed by name

Definition at line 52 of file EvtKinFactory.h.

typedef std::map<std::string, InteractionCreator> EvtKinFactory::CallbackMapInteraction [private]

Definition at line 54 of file EvtKinFactory.h.

Definition at line 47 of file EvtKinFactory.h.

pointer to function creating {Flux|Interaction}Generator

Definition at line 46 of file EvtKinFactory.h.

Definition at line 48 of file EvtKinFactory.h.


Constructor & Destructor Documentation

EvtKinFactory::EvtKinFactory (  )  [private]

These are private.

Private ctor and copy-ctor.

Definition at line 195 of file EvtKinFactory.cxx.

00195 { }

EvtKinFactory::EvtKinFactory ( const EvtKinFactory  )  [private]

Definition at line 196 of file EvtKinFactory.cxx.

00196 { }


Member Function Documentation

FlavorModifier * EvtKinFactory::CreateFlavorModifier ( const std::string &  flavorname  ) 

Definition at line 108 of file EvtKinFactory.cxx.

References fFlavorCallbacks, Msg::kDebug, and MSG.

Referenced by EvtKinNuModule::BeginJob().

00109 {
00110     MSG("EvtKin",Msg::kDebug)
00111         << "EvtKinFactory::CreateFlavorModifier() " << flavorname << endl;
00112     // map<>::insert(value_type) returns pair<iterator, bool>
00113     CallbackMapFlavor::const_iterator i = fFlavorCallbacks.find(flavorname);
00114 
00115     // handle unknown request
00116     if (i == fFlavorCallbacks.end()) {
00117         MSG("EvtKin",Msg::kDebug)
00118             << "Unknown FlavorModifier: " << flavorname << endl;
00119         return 0;
00120     }
00121 
00122     // invoke creator function
00123     return (i->second)();
00124 }

FluxGenerator * EvtKinFactory::CreateFluxGenerator ( const std::string &  fluxname  ) 

create the requested object

Call the creator functions

Definition at line 90 of file EvtKinFactory.cxx.

References fFluxCallbacks, Msg::kDebug, and MSG.

Referenced by EvtKinNuModule::BeginJob().

00091 {
00092     MSG("EvtKin",Msg::kDebug)
00093         << "EvtKinFactory::CreateFluxGenerator() " << fluxname << endl;
00094     // map<>::insert(value_type) returns pair<iterator, bool>
00095     CallbackMapFlux::const_iterator i = fFluxCallbacks.find(fluxname);
00096 
00097     // handle unknown request
00098     if (i == fFluxCallbacks.end()) {
00099         MSG("EvtKin",Msg::kDebug)
00100             << "Unknown FluxGenerator: " << fluxname << endl;
00101         return 0;
00102     }
00103 
00104     // invoke creator function
00105     return (i->second)();
00106 }

InteractionGenerator * EvtKinFactory::CreateInteractionGenerator ( const std::string &  intername  ) 

Definition at line 126 of file EvtKinFactory.cxx.

References fInteractionCallbacks, Msg::kDebug, and MSG.

Referenced by EvtKinNuModule::BeginJob().

00127 {
00128     MSG("EvtKin",Msg::kDebug)
00129         << "EvtKinFactory::CreateInteractionGenerator() " << intername << endl;
00130     // map<>::insert(value_type) returns pair<iterator, bool>
00131     CallbackMapInteraction::const_iterator i = fInteractionCallbacks.find(intername);
00132 
00133     // handle unknown request
00134     if (i == fInteractionCallbacks.end()) {
00135         MSG("EvtKin",Msg::kDebug)
00136             << "Unknown InteractionGenerator: " << intername << endl;
00137         return 0;
00138     }
00139 
00140     // invoke creator function
00141     return (i->second)();
00142 }

EvtKinFactory & EvtKinFactory::Instance (  )  [static]

Get EvtKinFactory reference

Definition at line 19 of file EvtKinFactory.cxx.

References fInstance, Msg::kVerbose, and MSG.

Referenced by EvtKinNuModule::BeginJob().

00020 {
00021     MSG("EvtKin",Msg::kVerbose)
00022         << "EvtKinFactory::Instance()" << endl;
00023     if ( !fInstance ) fInstance = new EvtKinFactory;
00024     return *fInstance;
00025 }

void EvtKinFactory::Print ( Option_t *  option = ""  )  const

list what we have

Definition at line 146 of file EvtKinFactory.cxx.

References fFlavorCallbacks, fFluxCallbacks, fInteractionCallbacks, Msg::kInfo, MSG, and Munits::nm.

Referenced by EvtKinNuModule::BeginJob().

00147 {
00148     MSG("EvtKin",Msg::kInfo)
00149         << "EvtKinFactory::Print(\"" << option << "\"):" << endl << endl;
00150  
00151     MSG("EvtKin",Msg::kInfo)
00152         << "  FluxGenerators:" << endl;
00153     int nf = 0; 
00154     CallbackMapFlux::const_iterator fitr = fFluxCallbacks.begin();
00155     while ( fitr != fFluxCallbacks.end() ) {
00156         MSG("EvtKin",Msg::kInfo) 
00157             << "     [" << nf++ << "]  "
00158             << fitr->first
00159             << endl;
00160         fitr++;
00161     }
00162     MSG("EvtKin",Msg::kInfo) << endl;
00163 
00164     MSG("EvtKin",Msg::kInfo)
00165         << "  FlavorModifiers:" << endl;
00166     int nm = 0; 
00167     CallbackMapFlavor::const_iterator mitr = fFlavorCallbacks.begin();
00168     while ( mitr != fFlavorCallbacks.end() ) {
00169         MSG("EvtKin",Msg::kInfo) 
00170             << "     [" << nm++ << "]  "
00171             << mitr->first
00172             << endl;
00173         mitr++;
00174     }
00175     MSG("EvtKin",Msg::kInfo) << endl;
00176 
00177     MSG("EvtKin",Msg::kInfo)
00178         << "  InteractionGenerators:" << endl;
00179     int ni = 0; 
00180     CallbackMapInteraction::const_iterator iitr = fInteractionCallbacks.begin();
00181     while ( iitr != fInteractionCallbacks.end() ) {
00182         MSG("EvtKin",Msg::kInfo) 
00183             << "     [" << ni++ << "]  "
00184             << iitr->first
00185             << endl;
00186         iitr++;
00187     }
00188     MSG("EvtKin",Msg::kInfo) << endl;
00189 
00190 }

bool EvtKinFactory::RegisterFlavor ( const std::string &  flavorname,
FlavorCreator  creator 
)

Definition at line 40 of file EvtKinFactory.cxx.

References fFlavorCallbacks, Msg::kDebug, and MSG.

00042 {
00043     MSG("EvtKin",Msg::kDebug)
00044         << "EvtKinFactory::RegisterFlavor()" << flavorname << endl;
00045     // map<>::insert(value_type) returns pair<iterator, bool>
00046     return fFlavorCallbacks.insert(CallbackMapFlavor::value_type(flavorname,creator)).second;
00047 }

bool EvtKinFactory::RegisterFlux ( const std::string &  fluxname,
FluxCreator  creator 
)

return 'true' is the registration was successful

Register creator functions

Definition at line 31 of file EvtKinFactory.cxx.

References fFluxCallbacks, Msg::kDebug, and MSG.

00033 {
00034     MSG("EvtKin",Msg::kDebug)
00035         << "EvtKinFactory::RegisterFlux()" << fluxname << endl;
00036     // map<>::insert(value_type) returns pair<iterator, bool>
00037     return fFluxCallbacks.insert(CallbackMapFlux::value_type(fluxname,creator)).second;
00038 }

bool EvtKinFactory::RegisterInteraction ( const std::string &  intername,
InteractionCreator  creator 
)

Definition at line 49 of file EvtKinFactory.cxx.

References fInteractionCallbacks, Msg::kDebug, and MSG.

00051 {
00052     MSG("EvtKin",Msg::kDebug)
00053         << "EvtKinFactory::RegisterInteractor()" << intername << endl;
00054     // map<>::insert(value_type) returns pair<iterator, bool>
00055     return fInteractionCallbacks.insert(CallbackMapInteraction::value_type(intername,creator)).second;
00056 }

bool EvtKinFactory::UnregisterFlavor ( const std::string &  flavorname  ) 

Definition at line 70 of file EvtKinFactory.cxx.

References fFlavorCallbacks, Msg::kDebug, and MSG.

00071 {
00072     MSG("EvtKin",Msg::kDebug)
00073         << "EvtKinFactory::UnregisterFlavor()" << flavorname << endl;
00074     // map<>::insert(value_type) returns pair<iterator, bool>
00075     return fFlavorCallbacks.erase(flavorname) == 1;
00076 }

bool EvtKinFactory::UnregisterFlux ( const std::string &  fluxname  ) 

return 'true' if creator was previously registered

Unregister creator functions

Definition at line 62 of file EvtKinFactory.cxx.

References fFluxCallbacks, Msg::kDebug, and MSG.

00063 {
00064     MSG("EvtKin",Msg::kDebug)
00065         << "EvtKinFactory::UnregisterFlux()" << fluxname << endl;
00066     // map<>::insert(value_type) returns pair<iterator, bool>
00067     return fFluxCallbacks.erase(fluxname) == 1;
00068 }

bool EvtKinFactory::UnregisterInteraction ( const std::string &  intername  ) 

Definition at line 78 of file EvtKinFactory.cxx.

References fInteractionCallbacks, Msg::kDebug, and MSG.

00079 {
00080     MSG("EvtKin",Msg::kDebug)
00081         << "EvtKinFactory::UnregisterInteractor()" << intername << endl;
00082     // map<>::insert(value_type) returns pair<iterator, bool>
00083     return fInteractionCallbacks.erase(intername) == 1;
00084 }


Member Data Documentation

Definition at line 82 of file EvtKinFactory.h.

Referenced by CreateFlavorModifier(), Print(), RegisterFlavor(), and UnregisterFlavor().

Definition at line 81 of file EvtKinFactory.h.

Referenced by CreateFluxGenerator(), Print(), RegisterFlux(), and UnregisterFlux().

EvtKinFactory * EvtKinFactory::fInstance = 0 [static, private]

initialize singleton

Definition at line 80 of file EvtKinFactory.h.

Referenced by Instance().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1