Is there a way to serialize/stream this object? It will be the best if I could get a char[] (with length) of the serialized object and I can do something like hashing them. And, of course, the reverse - construct an object.
I know it must be being done somewhere inside root, otherwise we can’t put reflex object inside ttrees, right?
By the way, I’m a bit confused about TClass/TObject and Reflex, aren’t they doing the same thing in terms of describing/constructing objects?
[quote]Is there a way to serialize/stream this object?[/quote]Of course , (assuming you have called Cintex::Enable in order to back fill ROOT and Cint with the information from Reflex).
[quote]By the way, I’m a bit confused about TClass/TObject and Reflex, aren’t they doing the same thing in terms of describing/constructing objects?[/quote]TClass predate Reflex by a decade or so and the Reflex is not yet the default C++ information store for ROOT (the Cint structures are).
To store your object do:TBufferFile buffer(TBuffer::kWrite);
TClass::GetClass("myobjtype")->Streamer(myobj,buffer);
and the char[] is available at buffer.Buffer() and its length at buffer.Length().
Assume I’ve got a class serialized into a TBuffer buf. And I would like to put this buffer into a branch of a ttree. What type of branch should I use? Can I do a Ttree.Branch(“mybranch”,&buf)?
I’m not directly putting the object itself into the branch since I would like to put different type of objects into the same branch.
[quote]I’m not directly putting the object itself into the branch since I would like to put different type of objects into the same branch. [/quote]Why? Could a collection of pointers (to a base class) do it easier?
[quote]
To store your object do:TBufferFile buffer(TBuffer::kWrite);
TClass::GetClass("myobjtype")->Streamer(myobj,buffer);
and the char[] is available at buffer.Buffer() and its length at buffer.Length().
Cheers,
Philippe.[/quote]
Just wondering how do I do the inverse of this. I.e. I have a char* and want to create a Reflex::Object from it.