Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FitStateFactory Class Reference

FitStateFactory - creates FitState objects. More...

#include <FitStateFactory.h>

List of all members.

Public Types

typedef FitState *(* FSCreator )()
 pointer to function creating fitter state

Public Member Functions

FitStateGetFitState (const std::string &fitStateId)
 create fitter state given its name
FitStateGetFitState (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

FitStateFactoryInstance ()
 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

FitStateCreateFitState (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

FitStateFactoryfInstance = 0
 initialize singleton


Detailed Description

FitStateFactory - creates FitState objects.

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.

Author:
Sergei avva@fnal.gov

Definition at line 26 of file FitStateFactory.h.


Member Typedef Documentation

typedef std::map<std::string, FSCreator> FitStateFactory::CallbackMap [private]
 

map of creator function pointers keyed by name

Definition at line 34 of file FitStateFactory.h.

typedef FitState*(* FitStateFactory::FSCreator)()
 

pointer to function creating fitter state

Definition at line 30 of file FitStateFactory.h.

typedef std::map<std::string, FitState*> FitStateFactory::StateMap [private]
 

Definition at line 35 of file FitStateFactory.h.


Constructor & Destructor Documentation

FitStateFactory::FitStateFactory  )  [private]
 

Those are private.

Definition at line 126 of file FitStateFactory.cxx.

00126 {}

FitStateFactory::FitStateFactory const FitStateFactory  )  [private]
 

Definition at line 127 of file FitStateFactory.cxx.

00127 {}


Member Function Documentation

FitState * FitStateFactory::CreateFitState const std::string &  FitStateId  )  [private]
 

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)

FitState * FitStateFactory::GetFitState const char *  fitStateId  ) 
 

Definition at line 98 of file FitStateFactory.cxx.

References GetFitState().

00099 {
00100     return GetFitState(std::string(fsname));
00101 }

FitState * FitStateFactory::GetFitState const std::string &  fitStateId  ) 
 

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)

FitStateFactory & FitStateFactory::Instance  )  [static]
 

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()

bool FitStateFactory::RegisterFitState const std::string &  FitStateId,
FSCreator  creator
 

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)

bool FitStateFactory::UnregisterFitState const std::string &  FitStateId  ) 
 

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)


Member Data Documentation

CallbackMap FitStateFactory::fCallbacks [private]
 

Definition at line 58 of file FitStateFactory.h.

Referenced by CreateFitState(), RegisterFitState(), and UnregisterFitState().

StateMap FitStateFactory::fFitStates [private]
 

Definition at line 59 of file FitStateFactory.h.

Referenced by GetFitState().

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

initialize singleton

Definition at line 34 of file FitStateFactory.cxx.

Referenced by Instance().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:09:12 2010 for loon by  doxygen 1.3.9.1