#include <DynamicPluggableFactory.h>
Inheritance diagram for DynamicPluggableFactory:

Public Member Functions | |
| Bool_t | IsRegistered (const char *regnm) const |
| virtual AlgBase & | LendAlg (const char *algnm) |
| virtual AlgConfig & | LendAlgConfig (const char *regnm) |
| void | Register (DynAlgReg *dar) |
Static Public Member Functions | |
| static DynamicPluggableFactory & | GetInstance () |
Private Member Functions | |
| DynamicPluggableFactory () | |
| virtual | ~DynamicPluggableFactory () |
| AlgBase * | GetPrototypicalAlg (const char *algnm) |
| AlgConfig * | GetPrototypicalAlgConfig (const char *regnm) |
| AlgBase * | LinkPrototypicalAlg (const char *algnm) |
| AlgConfig * | LinkPrototypicalAlgConfig (const char *cclnm) |
| DynamicPluggableFactory (const DynamicPluggableFactory &) | |
| void | operator= (const DynamicPluggableFactory &) |
Private Attributes | |
| TList | fDynamicAlgRegistry |
Static Private Attributes | |
| static DynamicPluggableFactory * | fsTheInstance |
Friends | |
| struct | Cleaner |
Classes | |
| struct | Cleaner |
Definition at line 20 of file DynamicPluggableFactory.h.
| DynamicPluggableFactory::DynamicPluggableFactory | ( | ) | [private] |
Definition at line 40 of file DynamicPluggableFactory.cxx.
References Msg::kDebug, and MSG.
Referenced by GetInstance().
00041 { 00042 MSG("DynFac", Msg::kDebug) << "DynamicPluggableFactory::Constructor\n"; 00043 fsTheInstance = this; 00044 }
| DynamicPluggableFactory::~DynamicPluggableFactory | ( | ) | [private, virtual] |
Definition at line 47 of file DynamicPluggableFactory.cxx.
References fDynamicAlgRegistry, fsTheInstance, Msg::kDebug, and MSG.
00048 { 00049 MSG("DynFac", Msg::kDebug) << "DynamicPluggableFactory::Destructor\n"; 00050 fDynamicAlgRegistry.Delete(); 00051 fsTheInstance = 0; 00052 }
| DynamicPluggableFactory::DynamicPluggableFactory | ( | const DynamicPluggableFactory & | ) | [private] |
| DynamicPluggableFactory & DynamicPluggableFactory::GetInstance | ( | ) | [static] |
Definition at line 55 of file DynamicPluggableFactory.cxx.
References DynamicPluggableFactory(), fsTheInstance, Msg::kDebug, MSG, and DynamicPluggableFactory::Cleaner::UseMe().
Referenced by AlgFactory::GetAlgHandle(), and AlgFactory::Register().
00056 { 00057 00058 // Cleaner destructor calls DynamicPluggableFactory dtor 00059 static Cleaner cleaner; 00060 00061 if (!fsTheInstance) { 00062 MSG("DynFac", Msg::kDebug) 00063 << "Instantiating DynamicPluggableFactory " << endl; 00064 cleaner.UseMe(); // dummy call to quiet compiler warnings 00065 fsTheInstance = new DynamicPluggableFactory(); 00066 } 00067 return *fsTheInstance; 00068 }
| AlgBase * DynamicPluggableFactory::GetPrototypicalAlg | ( | const char * | algnm | ) | [private] |
Definition at line 71 of file DynamicPluggableFactory.cxx.
References fDynamicAlgRegistry, DynAlgReg::GetAlgName(), DynAlgReg::GetDynamicLibraryName(), gSystem(), Msg::kError, LinkPrototypicalAlg(), MSG, and NamedProductPluggableFactory::RegisterPrototypicalAlg().
Referenced by LendAlg().
00072 { 00073 const TString algstr(algnm); 00074 DynAlgReg *dynalgfound = 0; 00075 00076 TIter algregiter(&fDynamicAlgRegistry); 00077 DynAlgReg *dar; 00078 while ((dar = (DynAlgReg *) algregiter())) { 00079 if (dar->GetAlgName() == algstr) { 00080 dynalgfound = dar; 00081 break; 00082 } 00083 } 00084 00085 if (!dynalgfound) return ((AlgBase *) 0); 00086 00087 // See if TUnixSystem knows about this Algorithm class yet. 00088 AlgBase *prototypicalalg = LinkPrototypicalAlg(algnm); 00089 00090 if (prototypicalalg) { 00091 RegisterPrototypicalAlg(prototypicalalg); 00092 return prototypicalalg; 00093 } 00094 00095 // Need to link the dynamic library containing the Algorithm class. 00096 Int_t irc = 00097 gSystem->Load(dynalgfound->GetDynamicLibraryName().Data()); 00098 if (irc < 0) { // Library not found 00099 00100 MSG("DynFac", Msg::kError) 00101 << "DynamicPluggableFactory::GetPrototypicalAlg(" << algnm << ")" 00102 << ". Dynamic library " 00103 << dynalgfound->GetDynamicLibraryName().Data() << " not found.\n"; 00104 00105 return ((AlgBase *) 0); 00106 } 00107 00108 prototypicalalg = LinkPrototypicalAlg(algnm); 00109 00110 if (prototypicalalg) RegisterPrototypicalAlg(prototypicalalg); 00111 00112 return prototypicalalg; 00113 }
| AlgConfig * DynamicPluggableFactory::GetPrototypicalAlgConfig | ( | const char * | regnm | ) | [private] |
Definition at line 116 of file DynamicPluggableFactory.cxx.
References fDynamicAlgRegistry, DynAlgReg::GetAlgConfigName(), DynAlgReg::GetDynamicLibraryName(), gSystem(), Msg::kError, LinkPrototypicalAlgConfig(), MSG, and NamedProductPluggableFactory::RegisterPrototypicalAlgConfig().
Referenced by LendAlgConfig().
00118 { 00119 const TString regstr(regnm); 00120 DynAlgReg *dynalgfound = 0; 00121 00122 TIter algregiter(&fDynamicAlgRegistry); 00123 DynAlgReg *dar; 00124 while ((dar = (DynAlgReg *) algregiter())) { 00125 if (TString(dar->GetName()) == regstr) { 00126 dynalgfound = dar; 00127 break; 00128 } 00129 } 00130 00131 if (!dynalgfound) return ((AlgConfig *) 0); 00132 00133 // See if TUnixSystem knows about this AlgConfig class yet. 00134 const char *cclnm = dar->GetAlgConfigName(); // ClassName 00135 AlgConfig *prototypicalalgconfig = LinkPrototypicalAlgConfig(cclnm); 00136 00137 if (prototypicalalgconfig) { 00138 prototypicalalgconfig->SetName(regnm); 00139 RegisterPrototypicalAlgConfig(prototypicalalgconfig); 00140 return prototypicalalgconfig; 00141 } 00142 00143 // Need to link the dynamic library containing the Algorithm class. 00144 Int_t irc = 00145 gSystem->Load(dynalgfound->GetDynamicLibraryName().Data()); 00146 if (irc < 0) { // Library not found 00147 00148 MSG("DynFac", Msg::kError) 00149 << "DynamicPluggableFactory::GetPrototypicalAlgConfig(" 00150 << regnm << ")" << ". Dynamic library " 00151 << dynalgfound->GetDynamicLibraryName().Data() << " not found.\n"; 00152 00153 return ((AlgConfig *) 0); 00154 } 00155 00156 prototypicalalgconfig = LinkPrototypicalAlgConfig(cclnm); 00157 00158 if (prototypicalalgconfig) { 00159 prototypicalalgconfig->SetName(regnm); 00160 RegisterPrototypicalAlgConfig(prototypicalalgconfig); 00161 } 00162 00163 return prototypicalalgconfig; 00164 }
| Bool_t DynamicPluggableFactory::IsRegistered | ( | const char * | regnm | ) | const |
Definition at line 167 of file DynamicPluggableFactory.cxx.
References fDynamicAlgRegistry.
Referenced by AlgFactory::GetAlgHandle(), and AlgFactory::Register().
00168 { 00169 00170 return (fDynamicAlgRegistry.FindObject(regnm) != 0); 00171 00172 }
| AlgBase & DynamicPluggableFactory::LendAlg | ( | const char * | algnm | ) | [virtual] |
Reimplemented from NamedProductPluggableFactory.
Definition at line 175 of file DynamicPluggableFactory.cxx.
References NamedProductPluggableFactory::GetAlgPtr(), GetPrototypicalAlg(), Msg::kError, and MSG.
Referenced by AlgFactory::GetAlgHandle().
00176 { 00177 AlgBase *algbase = GetAlgPtr(algnm); 00178 00179 if (!algbase) { 00180 AlgBase *prototypicalalg = GetPrototypicalAlg(algnm); 00181 algbase = (prototypicalalg ? prototypicalalg : 0); 00182 if (!algbase) { 00183 MSG("DynFac", Msg::kError) 00184 << "DynamicPluggableFactory::LendAlg(" << algnm << ")" 00185 << ": Prototypical Algorithm not found. Abort job." << endl; 00186 } 00187 assert(algbase); 00188 } 00189 00190 return *algbase; 00191 }
| AlgConfig & DynamicPluggableFactory::LendAlgConfig | ( | const char * | regnm | ) | [virtual] |
Reimplemented from NamedProductPluggableFactory.
Definition at line 194 of file DynamicPluggableFactory.cxx.
References NamedProductPluggableFactory::GetAlgConfigPtr(), GetPrototypicalAlgConfig(), Msg::kError, and MSG.
Referenced by AlgFactory::GetAlgHandle().
00195 { 00196 AlgConfig *algconfig = GetAlgConfigPtr(regnm); 00197 00198 if (!algconfig) { 00199 AlgConfig *prototypicalalgconfig = GetPrototypicalAlgConfig(regnm); 00200 algconfig = (prototypicalalgconfig ? prototypicalalgconfig : 0); 00201 if (!algconfig) { 00202 MSG("DynFac", Msg::kError) 00203 << "DynamicPluggableFactory::LendAlgConfig(" << regnm << ")" 00204 << ": Prototypical AlgConfig not found. Abort job." << endl; 00205 } 00206 assert(algconfig); 00207 } 00208 00209 return *algconfig; 00210 }
| AlgBase * DynamicPluggableFactory::LinkPrototypicalAlg | ( | const char * | algnm | ) | [private] |
Definition at line 213 of file DynamicPluggableFactory.cxx.
References Msg::kDebug, and MSG.
Referenced by GetPrototypicalAlg().
00214 { 00215 MSG("DynFac", Msg::kDebug) 00216 << "DynamicPluggableFactory::LinkPrototypicalAlg(" << algnm << ")\n"; 00217 00218 AlgBase *prototypicalalg = 0; 00219 if (gROOT->GetClass(algnm,kTRUE)) 00220 prototypicalalg = (AlgBase *) gROOT->GetClass(algnm,kTRUE)->New(); 00221 00222 return prototypicalalg ? prototypicalalg : 0; 00223 }
| AlgConfig * DynamicPluggableFactory::LinkPrototypicalAlgConfig | ( | const char * | cclnm | ) | [private] |
Definition at line 226 of file DynamicPluggableFactory.cxx.
References Msg::kDebug, and MSG.
Referenced by GetPrototypicalAlgConfig().
00228 { 00229 MSG("DynFac", Msg::kDebug) 00230 << "DynamicPluggableFactory::LinkPrototypicalAlg(" << cclnm << ")\n"; 00231 00232 AlgConfig *prototypicalalgconfig = 0; 00233 if (gROOT->GetClass(cclnm,kTRUE)) 00234 prototypicalalgconfig = 00235 (AlgConfig *) gROOT->GetClass(cclnm,kTRUE)->New(); 00236 00237 return prototypicalalgconfig ? prototypicalalgconfig : 0; 00238 }
| void DynamicPluggableFactory::operator= | ( | const DynamicPluggableFactory & | ) | [private] |
| void DynamicPluggableFactory::Register | ( | DynAlgReg * | dar | ) |
Definition at line 241 of file DynamicPluggableFactory.cxx.
References fDynamicAlgRegistry.
Referenced by AlgFactory::Register().
00242 { 00243 fDynamicAlgRegistry.Add(dar); 00244 }
friend struct Cleaner [friend] |
Definition at line 56 of file DynamicPluggableFactory.h.
TList DynamicPluggableFactory::fDynamicAlgRegistry [private] |
Definition at line 33 of file DynamicPluggableFactory.h.
Referenced by GetPrototypicalAlg(), GetPrototypicalAlgConfig(), IsRegistered(), Register(), and ~DynamicPluggableFactory().
DynamicPluggableFactory * DynamicPluggableFactory::fsTheInstance [static, private] |
Definition at line 32 of file DynamicPluggableFactory.h.
Referenced by GetInstance(), DynamicPluggableFactory::Cleaner::~Cleaner(), and ~DynamicPluggableFactory().
1.4.7