Logo ROOT   6.14/05
Reference Guide
TClassStreamer.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Victor Perev and Philippe Canal 08/05/02
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2003, Rene Brun, Fons Rademakers and al. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TClassStreamer_h
13 #define ROOT_TClassStreamer_h
14 
15 #include "Rtypes.h"
16 #include "TClassRef.h"
17 
18 //////////////////////////////////////////////////////////////////////////
19 // //
20 // TClassStreamer is used to stream an object of a specific class. //
21 // //
22 // The address passed to operator() will be the address of the start //
23 // of the object. //
24 // //
25 //////////////////////////////////////////////////////////////////////////
26 
28 protected:
32 
33 public:
35 
36  virtual void SetOnFileClass( const TClass* cl ) { fOnFileClass = const_cast<TClass*>(cl); }
37  virtual const TClass* GetOnFileClass() const { return fOnFileClass; }
38 
39  virtual TClassStreamer *Generate() const {
40  // Virtual copy constructor.
41  return new TClassStreamer(*this);
42  }
43 
44  virtual ~TClassStreamer(){};
45  virtual void operator()(TBuffer &b, void *objp)
46  {
47  // The address passed to operator() will be the address of the start of the
48  // object.
49 
50  (*fStreamer)(b,objp);
51  }
52  virtual void Stream(TBuffer &b, void *objp, const TClass *onfileClass)
53  {
54  // The address passed to operator() will be the address of the start of the
55  // object. Overload this routine, if your derived class can optimize
56  // the handling of the onfileClass (rather than storing and restoring from the
57  // fOnFileClass member.
58 
59  // Note we can not name this routine 'operator()' has it would be slightly
60  // backward incompatible and lead to the following warning/error from the
61  // compiler in the derived class overloading the other operator():
62 // include/TClassStreamer.h:51: error: ‘virtual void TClassStreamer::operator()(TBuffer&, void*, const TClass*)’ was hidden
63 // include/TCollectionProxyFactory.h:180: error: by ‘virtual void TCollectionClassStreamer::operator()(TBuffer&, void*)’
64 // cc1plus: warnings being treated as errors
65 
66  SetOnFileClass(onfileClass);
67  (*this)(b,objp);
68  }
69 
70 private:
72 protected:
74 };
75 
76 #endif
void(* ClassStreamerFunc_t)(TBuffer &, void *)
Definition: Rtypes.h:65
TClassStreamer(ClassStreamerFunc_t pointer)
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
TClassStreamer(const TClassStreamer &rhs)
virtual void Stream(TBuffer &b, void *objp, const TClass *onfileClass)
virtual const TClass * GetOnFileClass() const
virtual void operator()(TBuffer &b, void *objp)
virtual void SetOnFileClass(const TClass *cl)
virtual ~TClassStreamer()
TClassStreamer & operator=(const TClassStreamer &rhs)
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
virtual TClassStreamer * Generate() const
TClassRef fOnFileClass
TClassRef is used to implement a permanent reference to a TClass object.
Definition: TClassRef.h:29
ClassStreamerFunc_t fStreamer
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630