1 #ifndef RAT_DS_ROOTFACTORY_HH
2 #define RAT_DS_ROOTFACTORY_HH
9 #include "RAT/DS/Root.hh"
14 static void SetClassName(
const std::string& name) { ClassName() = name; }
16 static Root* Create() {
17 const std::string& name = ClassName();
18 if (name.empty() || name ==
"RAT::DS::Root")
return new Root();
20 TClass* cl = TClass::GetClass(name.c_str());
21 if (!cl)
throw std::runtime_error(
"RootFactory: no dictionary for " + name);
22 if (!cl->InheritsFrom(Root::Class()))
throw std::runtime_error(
"RootFactory: " + name +
" is not a RAT::DS::Root");
24 void* obj = cl->New();
25 if (!obj)
throw std::runtime_error(
"RootFactory: New() failed for " + name);
28 return static_cast<Root*
>(cl->DynamicCast(Root::Class(), obj, kTRUE));
31 static const std::string& GetClassName() {
return ClassName(); }
34 static std::string& ClassName() {
Definition: RootFactory.hh:12