Re: [ROOT] MySQL error

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Fri Mar 22 2002 - 15:52:51 MET


Hi Andre,

   in your case it is indeed best to directly use the TBuffer. TMessage
is more geared to networking and hides some essential accessor methods
that you will need. However, the principle remains the same.
For a detailed axample see:

http://carrot.cern.ch/~onuchin/RDBC/
http://carrot.cern.ch/~onuchin/RDBC/html/src/TSQLResultSet.cxx.html#TSQLResultSet:UpdateObject


Cheers, Fons.



On Mon, 2002-03-11 at 18:44, André David wrote:
> 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
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



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