Hello Maarten, how do I have to write it correctly with the following class: class c_MsgSimple : public TObject { public: c_MsgSimple() {}; ~c_MsgSimple() {}; Int_t iValue; Long_t lValue; Double_t dValue; TString txt; ClassDef(c_MsgSimple, 1) }; I have the ClassImp(c_MsgSimple) and a LinkDef.h like: #pragma link off all typedefs; #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ nestedclass; #pragma link C++ nestedtypedef; #pragma link C++ class c_MsgSimple+; My program is the following: TBuffer a(TBuffer::kWrite); c_MsgSimple MsgSimple_in; MsgSimple_in.iValue=123456780; MsgSimple_in.lValue=(Long_t)2076543219; MsgSimple_in.dValue=3.1415; MsgSimple_in.txt="test text"; B << "i=" << MsgSimple_in.iValue << " l=" << MsgSimple_in.lValue << " d=" << MsgSimple_in.dValue << " txt=" << MsgSimple_in.txt << E; a.WriteObject(&MsgSimple_in); char *buf = new char(a.Length()); Int_t len = a.Length(); // send and receive char array memcpy(buf, a.Buffer(), len); TBuffer b(TBuffer::kRead); b.SetBuffer( buf, len, kFALSE ); c_MsgSimple* MsgSimple_out; MsgSimple_out = (c_MsgSimple*)b.ReadObject(gROOT->GetClass("c_MsgSimple")); B << "i=" << MsgSimple_out->iValue << " l=" << MsgSimple_out->lValue << " d=" << MsgSimple_out->dValue << " txt=" << MsgSimple_out->txt << E; return 0; But the output is: (!!!!??????????) i=123456780 l=2076543219 d=3.1415 txt=test text i=123456780 l=0 d=3.1415 txt=test text What I am doing wrong? Thank you for your help. Ciao, Mario Schubert --------------------------------------------- Beschleunigerlabor der LMU und TU München Dipl. Phys. Mario Schubert EMail: mario.schubert@physik.uni-muenchen.de Phone: (+49 89)289 14283 FAX: (+49 89)289 14280 Am Coulombwall 6, D-85748 Garching, Germany On Friday 30 August 2002 18:42, Maarten Ballintijn wrote: > Hi Mario, > > TBuffer is the way to go. Please attached simple example. > The tricky part might be the ownership of the buffer. > (see the comments in the source for details) > > If you still have problems, please provide the ROOT version > you are using, the platform you are running on and a simplified > example of your problem. > > Cheers, > Maarten. > > On Fri, 2002-08-30 at 11:46, Mario Schubert wrote: > > Hello, > > > > I need to convert/serialize/marshal an object (in derived from TObject, > > with dictionary generated) to a simmple char[] array. > > Then it will be sent over and received by the MPICH library. > > After this I want to generate this object from the char[] array. > > > > How to do this? > > > > My experiments with TMessage/TBuffer ended in segmentation faults. :-| > > Thank you very much for your help. > > > > Ciao, > > Mario Schubert
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:06 MET