#include <Factory.h>
Public Types | |
| typedef Handle< T >(* | Creator )() |
Public Member Functions | |
| bool | Register (const std::string &name, Creator creator) |
| bool | Unregister (const std::string &name) |
| Handle< T > | Create (const std::string &name) |
| const std::vector< std::string > | List () const |
| bool | Hold (const std::string &name, Handle< T > ptr) |
| Handle< T > | Get (const std::string &name) const |
| bool | Remove (const std::string &name) |
| void | Clear () |
| void | Print () const |
Static Public Member Functions | |
| Factory & | Instance () |
Private Types | |
| typedef std::map< std::string, Creator > | CallMap |
| typedef std::map< std::string, Handle< T > > | HoldMap |
Private Member Functions | |
| Factory () | |
| ~Factory () | |
| Factory (const Factory &) | |
| const Factory & | operator= (const Factory &) |
Private Attributes | |
| CallMap | fCalls |
| HoldMap | fHolds |
Static Private Attributes | |
| Factory * | fgInstance = 0 |
|
|||||
|
|
|
|||||
|
Definition at line 33 of file Factory.h. Referenced by Anp::Factory< T >::Register(). |
|
|||||
|
|
|
|||||||||
|
Definitions of template functions Definition at line 132 of file Factory.h. 00133 {
00134 }
|
|
|||||||||
|
Definition at line 137 of file Factory.h. 00138 {
00139 }
|
|
||||||||||
|
|
|
|||||||||
|
Definition at line 236 of file Factory.h. References Anp::Factory< T >::fHolds. 00237 {
00238 fHolds.clear();
00239 }
|
|
||||||||||
|
Definition at line 171 of file Factory.h. References Anp::Factory< T >::fCalls. Referenced by Anp::SelectTrue::GetAlg(), Anp::SelectKinem::GetAlg(), and Anp::SelectCount::GetCount(). 00172 {
00173 typename CallMap::const_iterator it = fCalls.find(name);
00174
00175 // handle unknown algorithm request
00176 if(it == fCalls.end())
00177 {
00178 std::cerr << "Factory<T>::Create - don't know anything about " << name << std::endl;
00179 return Handle<T>(NULL);
00180 }
00181
00182 return (it->second)();
00183 }
|
|
||||||||||
|
Definition at line 206 of file Factory.h. References Anp::Factory< T >::fHolds. 00207 {
00208 typename HoldMap::const_iterator it = fHolds.find(name);
00209
00210 // handle unknown algorithm request
00211 if(it == fHolds.end())
00212 {
00213 std::cerr << "Factory<T>::Get - don't know anything about " << name << std::endl;
00214 return Handle<T>(NULL);
00215 }
00216
00217 return it->second;
00218 }
|
|
||||||||||||||||
|
Definition at line 200 of file Factory.h. References Anp::Factory< T >::fHolds. 00201 {
00202 return fHolds.insert(typename HoldMap::value_type(name, ptr)).second;
00203 }
|
|
|||||||||
|
Definition at line 142 of file Factory.h. References Anp::Factory< T >::fgInstance. Referenced by TestDataModule::Analyze(), SetKNNModule::Analyze(), NueModule::Analyze(), AnalysisInfoAna::Analyze(), SetKNNModule::AnalyzeRecord(), Anp::SelectTrue::GetAlg(), Anp::SelectKinem::GetAlg(), Anp::SelectCount::GetCount(), MuonRemovalInfoAna::LoadROPID(), SetKNNModule::Reco(), FixModule::Reco(), SetKNNModule::SetKNNModule(), TestDataModule::TestDataModule(), SetKNNModule::~SetKNNModule(), and TestDataModule::~TestDataModule(). 00143 {
00144 if(!fgInstance)
00145 {
00146 fgInstance = new Anp::Factory<T>();
00147 }
00148
00149 return *fgInstance;
00150 }
|
|
|||||||||
|
Definition at line 186 of file Factory.h. References Anp::Factory< T >::fCalls. 00187 {
00188 std::vector<std::string> svec;
00189
00190 typename CallMap::const_iterator it = fCalls.begin();
00191 for(; it != fCalls.end(); ++it)
00192 {
00193 svec.push_back(it -> first);
00194 }
00195
00196 return svec;
00197 }
|
|
||||||||||
|
|
|
|||||||||
|
Definition at line 242 of file Factory.h. References Anp::Factory< T >::fCalls. 00243 {
00244 std::cout << "Print: Factory<> knows about " << fCalls.size() << " objects" << std::endl;
00245
00246 typename CallMap::const_iterator it = fCalls.begin();
00247 for(; it != fCalls.end(); ++it)
00248 {
00249 std::cout << "Registerted object name " << it -> first << std::endl;
00250 }
00251 }
|
|
||||||||||||||||
|
Definition at line 153 of file Factory.h. References Anp::Factory< T >::Creator, and Anp::Factory< T >::fCalls. 00154 {
00155 if(!fCalls.insert(typename CallMap::value_type(name, creator)).second)
00156 {
00157 std::cerr << "Factory<T>::Register - " << name << " already exists" << std::endl;
00158 return false;
00159 }
00160
00161 return true;
00162 }
|
|
||||||||||
|
Definition at line 221 of file Factory.h. References Anp::Factory< T >::fHolds. 00222 {
00223 //
00224 // Atempt to erase handle with key "name"
00225 //
00226 if(fHolds.erase(name) < 1)
00227 {
00228 std::cerr << "Factory<T>::Remove - don't know anything about " << name << std::endl;
00229 return false;
00230 }
00231
00232 return true;
00233 }
|
|
||||||||||
|
Definition at line 165 of file Factory.h. References Anp::Factory< T >::fCalls. 00166 {
00167 return fCalls.erase(name) == 1;
00168 }
|
|
|||||
|
Definition at line 75 of file Factory.h. Referenced by Anp::Factory< T >::Create(), Anp::Factory< T >::List(), Anp::Factory< T >::Print(), Anp::Factory< T >::Register(), and Anp::Factory< T >::Unregister(). |
|
|||||
|
Initialize static singleton pointer Definition at line 82 of file Factory.h. Referenced by Anp::Factory< T >::Instance(). |
|
|||||
|
Definition at line 76 of file Factory.h. Referenced by Anp::Factory< T >::Clear(), Anp::Factory< T >::Get(), Anp::Factory< T >::Hold(), and Anp::Factory< T >::Remove(). |
1.3.9.1