Logo ROOT  
Reference Guide
TCollectionProxyFactory.h
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Markus Frank 28/10/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
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 #ifndef ROOT_TCollectionProxyFactory
12 #define ROOT_TCollectionProxyFactory
13 
14 //////////////////////////////////////////////////////////////////////////
15 // //
16 // Small helper to save proxy environment in the event of
17 // recursive calls.
18 //
19 //////////////////////////////////////////////////////////////////////////
20 
21 #include "TCollectionProxyInfo.h"
22 
23 #include "TClassStreamer.h"
24 
25 #include "TMemberStreamer.h"
26 
27 #include "TGenCollectionProxy.h"
28 
29 // Forward declarations
30 class TBuffer;
35 
36 #if defined(_WIN32)
37  #if _MSC_VER<1300
38  #define TYPENAME
39  #define R__VCXX6
40  #else
41  #define TYPENAME typename
42  #endif
43 #else
44  #define TYPENAME typename
45 #endif
46 
47 
48 /** \class TCollectionProxyFactory TCollectionProxyFactory.h
49  TCollectionProxyFactory
50  Interface to collection proxy and streamer generator.
51  Proxy around an arbitrary container, which implements basic
52  functionality and iteration. The purpose of this implementation
53  is to shield any generated dictionary implementation from the
54  underlying streamer/proxy implementation and only expose
55  the creation functions.
56 
57  In particular this is used to implement splitting and abstract
58  element access of any container. Access to compiled code is necessary
59  to implement the abstract iteration sequence and functionality like
60  size(), clear(), resize(). resize() may be a void operation.
61 
62  \author M.Frank
63  \version 1.0
64 */
66 public:
67 
69 #ifdef R__HPUX
70  typedef const std::type_info& Info_t;
71 #else
72  typedef const std::type_info& Info_t;
73 #endif
74 
75  /// Generate emulated collection proxy for a given class
76  static TVirtualCollectionProxy* GenEmulatedProxy(const char* class_name, Bool_t silent);
77 
78  /// Generate emulated class streamer for a given collection class
79  static TClassStreamer* GenEmulatedClassStreamer(const char* class_name, Bool_t silent);
80 
81  /// Generate emulated member streamer for a given collection class
82  static TMemberStreamer* GenEmulatedMemberStreamer(const char* class_name, Bool_t silent);
83 
84 
85  /// Generate proxy from static functions
86  static Proxy_t* GenExplicitProxy( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
87 
88  /// Generate proxy from template
89  template <class T> static Proxy_t* GenProxy(const T &arg, TClass *cl) {
91  }
92 
93  /// Generate streamer from static functions
95  GenExplicitStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
96 
97  /// Generate class streamer from static functions
98  static TClassStreamer*
99  GenExplicitClassStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
100 
101  /// Generate class streamer from template
102  template <class T> static TClassStreamer* GenClassStreamer(const T &arg, TClass *cl) {
104  }
105 
106  /// Generate member streamer from static functions
107  static TMemberStreamer*
108  GenExplicitMemberStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl);
109 
110  /// Generate member streamer from template
111  template <class T> static TMemberStreamer* GenMemberStreamer(const T &arg, TClass *cl) {
113  }
114 };
115 
116 /**
117  \class TCollectionStreamer TCollectionProxyFactory.h
118  \ingroup IO
119 
120  Class streamer object to implement TClassStreamer functionality for I/O emulation.
121 
122  @author M.Frank
123  @version 1.0
124 */
126 private:
127  TCollectionStreamer& operator=(const TCollectionStreamer&); // not implemented
128 
129 protected:
130  TGenCollectionProxy* fStreamer; ///< Pointer to worker streamer
131 
132  /// Issue Error about invalid proxy
133  void InvalidProxyError();
134 
135 public:
136  /// Initializing constructor
138  /// Copy constructor
140  /// Standard destructor
141  virtual ~TCollectionStreamer();
142  /// Attach worker proxy
143  void AdoptStreamer(TGenCollectionProxy* streamer);
144  /// Streamer for I/O handling
145  void Streamer(TBuffer &refBuffer, void *obj, int siz, TClass *onFileClass );
146 };
147 
148 /**
149  \class TCollectionClassStreamer TCollectionProxyFactory.h
150  \ingroup IO
151 
152  Class streamer object to implement TClassStreamer functionality
153  for I/O emulation.
154  \author M.Frank
155  \version 1.0
156 */
158  protected:
160  /// Copy constructor
163 
164 public:
165  /// Initializing constructor
167  /// Standard destructor
169  /// Streamer for I/O handling
170  virtual void operator()(TBuffer &buff, void *obj ) { Streamer(buff,obj,0,fOnFileClass); }
171 
172  virtual void Stream(TBuffer &b, void *obj, const TClass *onfileClass)
173  {
174  if (b.IsReading()) {
176  if (onfileClass==0 || onfileClass == proxy->GetCollectionClass()) {
177  proxy->ReadBuffer(b,obj);
178  } else {
179  proxy->ReadBuffer(b,obj,onfileClass);
180  }
181  } else {
182  // fStreamer->WriteBuffer(b,objp,onfileClass);
183  Streamer(b,obj,0,(TClass*)onfileClass);
184  }
185  }
186 
187  /// Virtual copy constructor.
188  virtual TClassStreamer *Generate() const {
189  return new TCollectionClassStreamer(*this);
190  }
191 
193 
194 };
195 
196 /**
197  \class TCollectionMemberStreamer TCollectionProxyFactory.h
198  \ingroup IO
199 
200  Class streamer object to implement TMemberStreamer functionality
201  for I/O emulation.
202  \author M.Frank
203  \version 1.0
204  */
206 private:
208 public:
209  /// Initializing constructor
211  /// Copy constructor
214  /// Standard destructor
216  /// Streamer for I/O handling
217  virtual void operator()(TBuffer &buff,void *obj,Int_t siz=0)
218  { Streamer(buff, obj, siz, 0); /* FIXME */ }
219 };
220 
221 #endif
c
#define c(i)
Definition: RSha256.hxx:101
TCollectionStreamer::InvalidProxyError
void InvalidProxyError()
Issue Error about invalid proxy.
Definition: TCollectionProxyFactory.cxx:122
TCollectionStreamer::AdoptStreamer
void AdoptStreamer(TGenCollectionProxy *streamer)
Attach worker proxy.
Definition: TCollectionProxyFactory.cxx:151
TCollectionProxyFactory::GenEmulatedClassStreamer
static TClassStreamer * GenEmulatedClassStreamer(const char *class_name, Bool_t silent)
Generate emulated class streamer for a given collection class.
Definition: TCollectionProxyFactory.cxx:71
TCollectionStreamer
Class streamer object to implement TClassStreamer functionality for I/O emulation.
Definition: TCollectionProxyFactory.h:125
TCollectionClassStreamer::Stream
virtual void Stream(TBuffer &b, void *obj, const TClass *onfileClass)
Definition: TCollectionProxyFactory.h:172
TCollectionClassStreamer::operator=
TCollectionClassStreamer & operator=(const TCollectionClassStreamer &rhs)
TCollectionMemberStreamer
Class streamer object to implement TMemberStreamer functionality for I/O emulation.
Definition: TCollectionProxyFactory.h:205
TCollectionMemberStreamer::~TCollectionMemberStreamer
virtual ~TCollectionMemberStreamer()
Standard destructor.
Definition: TCollectionProxyFactory.h:215
TCollectionProxyFactory::GenExplicitProxy
static Proxy_t * GenExplicitProxy(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate proxy from static functions.
Definition: TCollectionProxyFactory.cxx:90
TCollectionProxyInfo.h
TBuffer
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
TCollectionClassStreamer::TCollectionClassStreamer
TCollectionClassStreamer()
Initializing constructor.
Definition: TCollectionProxyFactory.h:166
TGenCollectionProxy.h
TCollectionProxyFactory::Info_t
const std::type_info & Info_t
Definition: TCollectionProxyFactory.h:72
ROOT::Detail::TCollectionProxyInfo::Get
static TCollectionProxyInfo Get(const T &)
Definition: TCollectionProxyInfo.h:594
b
#define b(i)
Definition: RSha256.hxx:100
TCollectionProxyFactory::GenExplicitStreamer
static TGenCollectionStreamer * GenExplicitStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate streamer from static functions.
Definition: TCollectionProxyFactory.cxx:97
bool
TGenCollectionProxy::ReadBuffer
virtual void ReadBuffer(TBuffer &b, void *obj)
Definition: TGenCollectionProxy.cxx:1374
TCollectionClassStreamer::TCollectionClassStreamer
TCollectionClassStreamer(const TCollectionClassStreamer &c)
Copy constructor.
Definition: TCollectionProxyFactory.h:161
TCollectionClassStreamer::operator()
virtual void operator()(TBuffer &buff, void *obj)
Streamer for I/O handling.
Definition: TCollectionProxyFactory.h:170
TCollectionMemberStreamer::operator=
TCollectionMemberStreamer & operator=(const TCollectionMemberStreamer &rhs)
TGenCollectionProxy::GetCollectionClass
virtual TClass * GetCollectionClass() const
Return a pointer to the TClass representing the container.
Definition: TGenCollectionProxy.cxx:943
TCollectionProxyFactory::GenEmulatedProxy
static TVirtualCollectionProxy * GenEmulatedProxy(const char *class_name, Bool_t silent)
Generate emulated collection proxy for a given class.
Definition: TCollectionProxyFactory.cxx:63
TCollectionClassStreamer::Generate
virtual TClassStreamer * Generate() const
Virtual copy constructor.
Definition: TCollectionProxyFactory.h:188
TCollectionProxyFactory::Proxy_t
TVirtualCollectionProxy Proxy_t
Definition: TCollectionProxyFactory.h:68
TEmulatedCollectionProxy
Streamer around an arbitrary STL like container, which implements basic container functionality.
Definition: TEmulatedCollectionProxy.h:18
TCollectionStreamer::Streamer
void Streamer(TBuffer &refBuffer, void *obj, int siz, TClass *onFileClass)
Streamer for I/O handling.
Definition: TCollectionProxyFactory.cxx:160
TCollectionStreamer::operator=
TCollectionStreamer & operator=(const TCollectionStreamer &)
TCollectionProxyFactory::GenMemberStreamer
static TMemberStreamer * GenMemberStreamer(const T &arg, TClass *cl)
Generate member streamer from template.
Definition: TCollectionProxyFactory.h:111
TCollectionStreamer::TCollectionStreamer
TCollectionStreamer()
Initializing constructor.
Definition: TCollectionProxyFactory.cxx:127
TCollectionMemberStreamer::TCollectionMemberStreamer
TCollectionMemberStreamer(const TCollectionMemberStreamer &c)
Copy constructor.
Definition: TCollectionProxyFactory.h:212
TCollectionProxyFactory::GenExplicitMemberStreamer
static TMemberStreamer * GenExplicitMemberStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate member streamer from static functions.
Definition: TCollectionProxyFactory.cxx:114
TCollectionProxyFactory
TCollectionProxyFactory Interface to collection proxy and streamer generator.
Definition: TCollectionProxyFactory.h:65
TCollectionClassStreamer::GetXYZ
TGenCollectionProxy * GetXYZ()
Definition: TCollectionProxyFactory.h:192
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TCollectionClassStreamer::~TCollectionClassStreamer
virtual ~TCollectionClassStreamer()
Standard destructor.
Definition: TCollectionProxyFactory.h:168
TCollectionProxyFactory::GenClassStreamer
static TClassStreamer * GenClassStreamer(const T &arg, TClass *cl)
Generate class streamer from template.
Definition: TCollectionProxyFactory.h:102
TCollectionClassStreamer
Class streamer object to implement TClassStreamer functionality for I/O emulation.
Definition: TCollectionProxyFactory.h:157
ROOT::Math::Chebyshev::T
double T(double x)
Definition: ChebyshevPol.h:34
TGenCollectionProxy
Proxy around an arbitrary container, which implements basic functionality and iteration.
Definition: TGenCollectionProxy.h:31
TCollectionMemberStreamer::TCollectionMemberStreamer
TCollectionMemberStreamer()
Initializing constructor.
Definition: TCollectionProxyFactory.h:210
TClassStreamer
Definition: TClassStreamer.h:26
TCollectionStreamer::fStreamer
TGenCollectionProxy * fStreamer
Pointer to worker streamer.
Definition: TCollectionProxyFactory.h:130
TClassStreamer::fOnFileClass
TClassRef fOnFileClass
Definition: TClassStreamer.h:72
TGenCollectionStreamer
Definition: TGenCollectionStreamer.h:17
TClassStreamer.h
TCollectionProxyFactory::GenEmulatedMemberStreamer
static TMemberStreamer * GenEmulatedMemberStreamer(const char *class_name, Bool_t silent)
Generate emulated member streamer for a given collection class.
Definition: TCollectionProxyFactory.cxx:81
TMemberStreamer
Definition: TMemberStreamer.h:26
TCollectionMemberStreamer::operator()
virtual void operator()(TBuffer &buff, void *obj, Int_t siz=0)
Streamer for I/O handling.
Definition: TCollectionProxyFactory.h:217
TCollectionProxyFactory::GenProxy
static Proxy_t * GenProxy(const T &arg, TClass *cl)
Generate proxy from template.
Definition: TCollectionProxyFactory.h:89
TCollectionProxyFactory::GenExplicitClassStreamer
static TClassStreamer * GenExplicitClassStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate class streamer from static functions.
Definition: TCollectionProxyFactory.cxx:105
TCollectionStreamer::~TCollectionStreamer
virtual ~TCollectionStreamer()
Standard destructor.
Definition: TCollectionProxyFactory.cxx:143
TVirtualCollectionProxy
Definition: TVirtualCollectionProxy.h:38
TMemberStreamer.h
int