Dear ROOT experts,
I have a singleton class which contains a map of custom class and I would like to write it to a root file:
class Volume : public TObject
{
public:
Volume();
/* other stuff */
ClassDef(Volume,1)
}
class Info : public TObject
{
private:
map<const char *, Volume *> volumes;
void init(); // fill volumes
Info() { init(); }
public:
Info &Instance() { static Info instance; return instance; }
ClassDef(Info,1)
}
I set up all the code and the makefile in order to compile with cint and it works, except that when I try
Info::Instance().Write("Info");
it says
I understand that Info need a public constructor in order to be read from the file, but a singleton cannot have a public constructor…
What I need is the following:
- At the beginning of the program, the volumes map must be filled and must be globally available to all the program (hence Info must be a singleton: it must happen only once during the program and anyone can call it without worrying of its initialization)
- The volumes map is saved to a root file
- Another program open the root file and load back in memory the volumes map which must be globally available
I was thinking of using the Info class for both the writing and reading part, but the singleton is a problem.
How can I solve this problem?
Thanks,
Claudio