yawn
1
I have developed TMyClass, derived from TObject.
When I write the object with TMyClass->Write(), I want to automatically call a function DoSomethingBeforeWrite() before the default TMyClass->Write()
And when I read the object, I want to call automatically a function DoSomethingAfterRead() after the default reading.
What’s the simplest way to do that?
Thanks
Paolo
pcanal
2
Hi,
One way is write a custom streamer to insert you calls:[code]void TMyClass::Streamer(TBuffer &R__b)
{
// Stream an object of class MyClass.
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
DoSomethingAfterRead();
R__b.CheckByteCount(R__s, R__c, TMyClass::IsA());
} else {
DoSomethingBeforeWrite();
R__c = R__b.WriteVersion(TMyClass::IsA(), kTRUE);
R__b.SetByteCount(R__c, kTRUE);
}
}[/code]
Cheers,
Philippe.