Logo ROOT  
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
28protected:
32
33public:
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
70private:
72protected:
74};
75
76#endif
#define b(i)
Definition: RSha256.hxx:100
void(* ClassStreamerFunc_t)(TBuffer &, void *)
Definition: Rtypes.h:70
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
TClassRef is used to implement a permanent reference to a TClass object.
Definition: TClassRef.h:29
virtual ~TClassStreamer()
virtual void Stream(TBuffer &b, void *objp, const TClass *onfileClass)
virtual TClassStreamer * Generate() const
virtual void operator()(TBuffer &b, void *objp)
TClassRef fOnFileClass
virtual const TClass * GetOnFileClass() const
virtual void SetOnFileClass(const TClass *cl)
TClassStreamer(const TClassStreamer &rhs)
TClassStreamer & operator=(const TClassStreamer &rhs)
TClassStreamer(ClassStreamerFunc_t pointer)
ClassStreamerFunc_t fStreamer
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75