1 #ifndef __JGIZMO__JMANAGER__
2 #define __JGIZMO__JMANAGER__
22 namespace JPP {
using namespace JGIZMO; }
37 template<
class JKey_t,
class JValue_t = TObject>
56 std::ios::fmtflags format = std::ios::fmtflags()) :
58 std::map<JKey_t, JValue_t*>(),
63 using namespace JLANG;
69 master->SetDirectory(0);
71 if (
string(master->GetName()).find(
wc) == string::npos) {
72 THROW(
JException,
"JManager: Missing wildcard " << master->GetName() <<
' ' <<
wc);
87 typename map<JKey_t, JValue_t*>::iterator i = this->find(key);
89 if (i == this->end()) {
91 string buffer = this->
get()->GetName();
92 string::size_type ipos = buffer.find(
wc);
100 buffer.replace(ipos, 1, os.str());
102 JValue_t* p = (JValue_t*) this->
get()->Clone(buffer.c_str());
107 this->insert(make_pair(key,p));
124 void Write(TDirectory& out,
const bool wm =
false)
127 out.WriteTObject(i->second);
131 out.WriteTObject(this->
get());
142 void Write(
const char* file_name,
const bool wm =
false)
144 TFile out(file_name,
"RECREATE");
146 this->
Write(out, wm) ;
friend TFile & operator<<(TFile &file, JManager &object)
Write manager to file.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
JManager(JValue_t *master, char wildcard= '%', std::ios::fmtflags format=std::ios::fmtflags())
Constructor.
Auxiliary class to manage set of compatible ROOT objects (e.g.
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
Template implementation of class that holds pointer to object(s).
JValue_t * operator[](JKey_t key)
Get pointer to object for given key.
void Write(const char *file_name, const bool wm=false)
Write objects to file.