Re: [ROOT] MySQL error

From: André David (Andre.David@cern.ch)
Date: Mon Mar 11 2002 - 18:44:10 MET


Hi again Fons,

Fons Rademakers wrote:
> TH1F *myhist = new TH1F(...);
> TMessage mess(kMESS_OBJECT);
> mess.WriteObject(myhist);
> char *buf = mess.Buffer();
> int   len = mess.Length();

This seems to work fine, but (there's always a 'but')

> store "buf" with length "len" in DB. To read back retrieve BLOB in "buf"
> and length in "len" and do:
> 
> TMessage mess(buf, len);

ROOT complains on this one, on the grounds that

Error: can not call private or protected function FILE:MySQL.C LINE:71
  (compiled)   0 TMessage TMessage::TMessage(void*,Int_t);
Calling : TMessage::TMessage(void*,Int_t);
Match rank: file     line  signature
  ffffffff (compiled)   0 TMessage TMessage::TMessage(UInt_t);
*        0 (compiled)   0 TMessage TMessage::TMessage(void*,Int_t);
  ffffffff (compiled)   0 TMessage TMessage::TMessage(const TMessage&);
*** Interpreter error recovered ***

Now ROOT is right because that constructor is indeed private. The source
code reveals that:

private:
//...
TMessage(void *buf, Int_t bufsize);   // only called by
T(P)Socket::Recv()

So, since I'm a newbie to ROOT, should I use TBuffer instead? It looks
like it provides a public constructor that accepts a pointer and a
length:

public:
//...
TBuffer(EMode mode, Int_t bufsiz = kInitialSize, void *buf = 0, Bool_t
adopt = kTRUE);

If I can use this I am a bit lost. Would

TBuffer buffrd(kRead, len, buf);

work? (I'll test it right now anyway..)
Then again, why can't TMessage::TMessage(void *, Int_t) be public(ized)?

Cheers,

Andre




This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:45 MET