Hi, this is why I gave the example: I don't want to store the TClass itself. Here's a more elaborate example: class A { static A* GetContainersA(TContainer* cont) { return const->GetA(Class()); } } class TContainer { A* GetA(TClass* cl) { return map.GetValue(cl); } TMap map; } Now I can add classes deriving from A to TContainer, without TContainer knowing about those classes. Suppose I want to store TContainer::map. If I do that, TMap stores the keys (TClasses), but they can't be read back properly (i.e. after reading an object of type TContainer GetA() doesn't work anymore). That's why I would like to have a way to reference a TClass persistently. How? Cheers, Axel. ----- Original Message ----- From: Rene Brun <brun@pcbrun.cern.ch> Date: Wednesday, July 31, 2002 0:23 am Subject: Re: [ROOT] Persistency of TClass* > Hi Axel, > > We already have a procedure to save the class structure on a file, > see TStreamerInfo. Do not try to write TClass yourself to a file. > The dictionary for all classes written to a file is automatically > written to the file when the file is closed. > > Rene Brun > > > On Tue, 30 Jul 2002 axel@fnal.gov wrote: > > > Hi, > > > > writing a TClass to file works without any problems, it's just > that the > > read TClass is pretty much unusable. This makes kind of sense, > as > > TClass is more or less a static object. But there are some cases > where > > storing a TClass* would be helpful, e.g.: A map from TClass* to > > whatever-baseclass*, where the TClass* allows to identify and > access > > objects deriving from whatever-baseclass. > > > > Now, the suggestion I have is to make TClass store only the > class name, > > and when reading back, to let TClass's streamer search for the > TClass > > already instantiated which belongs to this class name. I believe > this > > would be the naive expectation of what a persistent TClass* does. > > > > The questions I have are: > > * What do you (users and rootdev) think about that? Does it > interfere > > with what other people do with a persistent TClass? > > * Reading a member of type TClass*, is there any way ROOT can > set this > > pointer to the TClass object already instatiated or will we end > up with > > two instatiations for the same class? > > > > Cheers, Axel. > > > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:02 MET