#include <FitStateFactory.h>
Public Types | |
| typedef FitState *(* | FSCreator )() |
| pointer to function creating fitter state | |
Public Member Functions | |
| FitState * | GetFitState (const std::string &fitStateId) |
| create fitter state given its name | |
| FitState * | GetFitState (const char *fitStateId) |
| bool | RegisterFitState (const std::string &FitStateId, FSCreator creator) |
| Returns 'true' if registration was successful. | |
| bool | UnregisterFitState (const std::string &FitStateId) |
| Returns 'true' if the FitStateId was registered before. | |
Static Public Member Functions | |
| FitStateFactory & | Instance () |
| get reference to the FSFactory singleton | |
Private Types | |
| typedef std::map< std::string, FSCreator > | CallbackMap |
| map of creator function pointers keyed by name | |
| typedef std::map< std::string, FitState * > | StateMap |
Private Member Functions | |
| FitState * | CreateFitState (const std::string &FitStateId) |
| create fitter state given its name | |
| FitStateFactory () | |
| Those are private. | |
| FitStateFactory (const FitStateFactory &) | |
Private Attributes | |
| CallbackMap | fCallbacks |
| StateMap | fFitStates |
Static Private Attributes | |
| FitStateFactory * | fInstance = 0 |
| initialize singleton | |
FitStateFactory creates FitState objects. Pointers to functions creating different types of FitState are in a map, keyed by names of the fitter state types. Creator functions have to be registered with FSFactory using 'RegisterFitState' method, so that new types of histogram blocks can be added without changing FSFactory code. FSFactory is a singleton.
Definition at line 26 of file FitStateFactory.h.
|
|
map of creator function pointers keyed by name
Definition at line 34 of file FitStateFactory.h. |
|
|
pointer to function creating fitter state
Definition at line 30 of file FitStateFactory.h. |
|
|
Definition at line 35 of file FitStateFactory.h. |
|
|
Those are private.
Definition at line 126 of file FitStateFactory.cxx. 00126 {}
|
|
|
Definition at line 127 of file FitStateFactory.cxx. 00127 {}
|
|
|
create fitter state given its name CreateFitState - creates requested fitter state Definition at line 107 of file FitStateFactory.cxx. References fCallbacks, and MSG. Referenced by GetFitState(). 00108 {
00109 TracerSA trace("FitStateFactory::CreateFitState(const string&)");
00110
00111 // find fitter state creator callback
00112 CallbackMap::const_iterator i = fCallbacks.find(hbname);
00113
00114 // create if callback found
00115 if ( i != fCallbacks.end() ) {
00116 return (i->second)();
00117 }
00118
00119 MSG("FitTrackSA",Msg::kError)
00120 << "Dont know anything about " << hbname << endl;
00121 return 0;
00122 } // FitState* FitStateFactory::CreateFitState(string)
|
|
|
Definition at line 98 of file FitStateFactory.cxx. References GetFitState(). 00099 {
00100 return GetFitState(std::string(fsname));
00101 }
|
|
|
create fitter state given its name GetFitState - returns requested FitState* (if necessary creates it) Definition at line 76 of file FitStateFactory.cxx. References CreateFitState(), and fFitStates. Referenced by AlgFitTrackSA::DoFit(), FitContext::FitContext(), and GetFitState(). 00077 {
00078 TracerSA trace("FitStateFactory::GetFitState(string)");
00079
00080 // check if requested state already exists
00081 StateMap::const_iterator i = fFitStates.find(fsname);
00082
00083 // return state if exists
00084 if ( i != fFitStates.end() ) {
00085 return i->second;
00086 }
00087
00088 // create it if doesn't exist
00089 FitState* state = CreateFitState(fsname);
00090 if ( state ) {
00091 fFitStates[fsname] = state;
00092 return state;
00093 }
00094
00095 assert(kFALSE && "Unknown state requested!!");
00096 } // FitState* FitStateFactory::GetFitState(string)
|
|
|
get reference to the FSFactory singleton Get FSFactory reference Definition at line 38 of file FitStateFactory.cxx. References fInstance. Referenced by AlgFitTrackSA::DoFit(), and FitContext::FitContext(). 00039 {
00040 TracerSA trace("FitStateFactory::Instance()");
00041
00042 if ( !fInstance ) fInstance = new FitStateFactory;
00043 return *fInstance;
00044 } // FitStateFactory& FitStateFactory::Instance()
|
|
||||||||||||
|
Returns 'true' if registration was successful. Register fitter state creator function Definition at line 50 of file FitStateFactory.cxx. References fCallbacks. 00053 {
00054 TracerSA trace("FitStateFactory::RegisterFitState(string, FSCreator)");
00055
00056 // map<>::insert(value_type) returns pair<iterator, bool>
00057 return fCallbacks.insert(CallbackMap::value_type(hbname, creator)).second;
00058 } // bool FitStateFactory::RegisterFitState(string, FSCreator)
|
|
|
Returns 'true' if the FitStateId was registered before. Unregister fitter state Definition at line 64 of file FitStateFactory.cxx. References fCallbacks. 00065 {
00066 TracerSA trace("FitStateFactory::UnregisterFitState(string)");
00067
00068 return fCallbacks.erase(hbname) == 1;
00069 } // bool FitStateFactory::UnregisterFitState(string)
|
|
|
Definition at line 58 of file FitStateFactory.h. Referenced by CreateFitState(), RegisterFitState(), and UnregisterFitState(). |
|
|
Definition at line 59 of file FitStateFactory.h. Referenced by GetFitState(). |
|
|
initialize singleton
Definition at line 34 of file FitStateFactory.cxx. Referenced by Instance(). |
1.3.9.1