Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TClassRef.h"
16
17//////////////////////////////////////////////////////////////////////////
18// //
19// TClassStreamer is used to stream an object of a specific class. //
20// //
21// The address passed to operator() will be the address of the start //
22// of the object. //
23// //
24//////////////////////////////////////////////////////////////////////////
25
27protected:
28 TClassStreamer() : fStreamer(nullptr) {};
31
32public:
34
35 virtual void SetOnFileClass( const TClass* cl ) { fOnFileClass = const_cast<TClass*>(cl); }
36 virtual const TClass* GetOnFileClass() const { return fOnFileClass; }
37
38 virtual TClassStreamer *Generate() const {
39 // Virtual copy constructor.
40 return new TClassStreamer(*this);
41 }
42
43 virtual ~TClassStreamer(){};
44 virtual void operator()(TBuffer &b, void *objp)
45 {
46 // The address passed to operator() will be the address of the start of the
47 // object.
48
49 (*fStreamer)(b,objp);
50 }
51 virtual void Stream(TBuffer &b, void *objp, const TClass *onfileClass)
52 {
53 // The address passed to operator() will be the address of the start of the
54 // object. Overload this routine, if your derived class can optimize
55 // the handling of the onfileClass (rather than storing and restoring from the
56 // fOnFileClass member.
57
58 // Note we can not name this routine 'operator' has it would be slightly
59 // backward incompatible and lead to the following warning/error from the
60 // compiler in the derived class overloading the other operator():
61// include/TClassStreamer.h:51: error: ‘virtual void TClassStreamer::operator()(TBuffer&, void*, const TClass*)’ was hidden
62// include/TCollectionProxyFactory.h:180: error: by ‘virtual void TCollectionClassStreamer::operator()(TBuffer&, void*)’
63// cc1plus: warnings being treated as errors
64
65 SetOnFileClass(onfileClass);
66 (*this)(b,objp);
67 }
68
69private:
71protected:
73};
74
75#endif
#define b(i)
Definition RSha256.hxx:100
void(* ClassStreamerFunc_t)(TBuffer &, void *)
Definition Rtypes.h:77
Buffer base class used for serializing objects.
Definition TBuffer.h:43
TClassRef is used to implement a permanent reference to a TClass object.
Definition TClassRef.h:28
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:81