ROOT  6.06/09
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 #ifndef ROOT_Rtypeinfo
22 #include "Rtypeinfo.h"
23 #endif
24 
25 #include <vector>
26 
27 #ifndef ROOT_TCollectionProxyInfo
28 #include "TCollectionProxyInfo.h"
29 #endif
30 
31 #ifndef ROOT_TClassStreamer
32 #include "TClassStreamer.h"
33 #endif
34 
35 #ifndef ROOT_TMemberStreamer
36 #include "TMemberStreamer.h"
37 #endif
38 
39 #ifndef ROOT_TGenCollectionProxy
40 #include "TGenCollectionProxy.h"
41 #endif
42 
43 // Forward declarations
44 class TBuffer;
49 
50 #if defined(_WIN32)
51  #if _MSC_VER<1300
52  #define TYPENAME
53  #define R__VCXX6
54  #else
55  #define TYPENAME typename
56  #endif
57 #else
58  #define TYPENAME typename
59 #endif
60 
61 
62 /** \class TCollectionProxyFactory TCollectionProxyFactory.h
63  TCollectionProxyFactory
64  Interface to collection proxy and streamer generator.
65  Proxy around an arbitrary container, which implements basic
66  functionality and iteration. The purpose of this implementation
67  is to shield any generated dictionary implementation from the
68  underlying streamer/proxy implementation and only expose
69  the creation functions.
70 
71  In particular this is used to implement splitting and abstract
72  element access of any container. Access to compiled code is necessary
73  to implement the abstract iteration sequence and functionality like
74  size(), clear(), resize(). resize() may be a void operation.
75 
76  \author M.Frank
77  \version 1.0
78 */
80 public:
81 
83 #ifdef R__HPUX
84  typedef const type_info& Info_t;
85 #else
86  typedef const std::type_info& Info_t;
87 #endif
88 
89  /// Generate emulated collection proxy for a given class
90  static TVirtualCollectionProxy* GenEmulatedProxy(const char* class_name, Bool_t silent);
91 
92  /// Generate emulated class streamer for a given collection class
93  static TClassStreamer* GenEmulatedClassStreamer(const char* class_name, Bool_t silent);
94 
95  /// Generate emulated member streamer for a given collection class
96  static TMemberStreamer* GenEmulatedMemberStreamer(const char* class_name, Bool_t silent);
97 
98 
99  /// Generate proxy from static functions
100  static Proxy_t* GenExplicitProxy( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
101 
102  /// Generate proxy from template
103  template <class T> static Proxy_t* GenProxy(const T &arg, TClass *cl) {
105  }
106 
107  /// Generate streamer from static functions
108  static TGenCollectionStreamer*
109  GenExplicitStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
110 
111  /// Generate class streamer from static functions
112  static TClassStreamer*
113  GenExplicitClassStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
114 
115  /// Generate class streamer from template
116  template <class T> static TClassStreamer* GenClassStreamer(const T &arg, TClass *cl) {
118  }
119 
120  /// Generate member streamer from static functions
121  static TMemberStreamer*
122  GenExplicitMemberStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl);
123 
124  /// Generate member streamer from template
125  template <class T> static TMemberStreamer* GenMemberStreamer(const T &arg, TClass *cl) {
127  }
128 };
129 
130 /**
131  \class TCollectionStreamer TCollectionProxyFactory.h
132  \ingroup IO
133 
134  Class streamer object to implement TClassStreamer functionality for I/O emulation.
135 
136  @author M.Frank
137  @version 1.0
138 */
140 private:
141  TCollectionStreamer& operator=(const TCollectionStreamer&); // not implemented
142 
143 protected:
144  TGenCollectionProxy* fStreamer; ///< Pointer to worker streamer
145 
146  /// Issue Error about invalid proxy
147  void InvalidProxyError();
148 
149 public:
150  /// Initializing constructor
152  /// Copy constructor
154  /// Standard destructor
155  virtual ~TCollectionStreamer();
156  /// Attach worker proxy
157  void AdoptStreamer(TGenCollectionProxy* streamer);
158  /// Streamer for I/O handling
159  void Streamer(TBuffer &refBuffer, void *obj, int siz, TClass *onFileClass );
160 };
161 
162 /**
163  \class TCollectionClassStreamer TCollectionProxy.h
164  \ingroup IO
165 
166  Class streamer object to implement TClassStreamer functionality
167  for I/O emulation.
168  \author M.Frank
169  \version 1.0
170 */
172  protected:
173  TCollectionClassStreamer &operator=(const TCollectionClassStreamer &rhs); // Not implemented.
174  /// Copy constructor
177 
178 public:
179  /// Initializing constructor
181  /// Standard destructor
183  /// Streamer for I/O handling
184  virtual void operator()(TBuffer &buff, void *obj ) { Streamer(buff,obj,0,fOnFileClass); }
185 
186  virtual void Stream(TBuffer &b, void *obj, const TClass *onfileClass)
187  {
188  if (b.IsReading()) {
190  if (onfileClass==0 || onfileClass == proxy->GetCollectionClass()) {
191  proxy->ReadBuffer(b,obj);
192  } else {
193  proxy->ReadBuffer(b,obj,onfileClass);
194  }
195  } else {
196  // fStreamer->WriteBuffer(b,objp,onfileClass);
197  Streamer(b,obj,0,(TClass*)onfileClass);
198  }
199  }
200 
201  /// Virtual copy constructor.
202  virtual TClassStreamer *Generate() const {
203  return new TCollectionClassStreamer(*this);
204  }
205 
207 
208 };
209 
210 /**
211  \class TCollectionMemberStreamer TCollectionProxyFactory.h
212  \ingroup IO
213 
214  Class streamer object to implement TMemberStreamer functionality
215  for I/O emulation.
216  \author M.Frank
217  \version 1.0
218  */
220 private:
221  TCollectionMemberStreamer &operator=(const TCollectionMemberStreamer &rhs); // Not implemented.
222 public:
223  /// Initializing constructor
225  /// Copy constructor
228  /// Standard destructor
230  /// Streamer for I/O handling
231  virtual void operator()(TBuffer &buff,void *obj,Int_t siz=0)
232  { Streamer(buff, obj, siz, 0); /* FIXME */ }
233 };
234 
235 #endif
virtual ~TCollectionStreamer()
Standard destructor.
static TMemberStreamer * GenEmulatedMemberStreamer(const char *class_name, Bool_t silent)
Generate emulated member streamer for a given collection class.
Class streamer object to implement TClassStreamer functionality for I/O emulation.
TCollectionMemberStreamer()
Initializing constructor.
Bool_t IsReading() const
Definition: TBuffer.h:81
Class streamer object to implement TMemberStreamer functionality for I/O emulation.
double T(double x)
Definition: ChebyshevPol.h:34
void AdoptStreamer(TGenCollectionProxy *streamer)
Attach worker proxy.
TGenCollectionProxy * GetXYZ()
static TClassStreamer * GenEmulatedClassStreamer(const char *class_name, Bool_t silent)
Generate emulated class streamer for a given collection class.
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual ~TCollectionMemberStreamer()
Standard destructor.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual TClassStreamer * Generate() const
Virtual copy constructor.
virtual ~TCollectionClassStreamer()
Standard destructor.
Streamer around an arbitrary STL like container, which implements basic container functionality...
static Proxy_t * GenExplicitProxy(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate proxy from static functions.
static TGenCollectionStreamer * GenExplicitStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate streamer from static functions.
const std::type_info & Info_t
static TMemberStreamer * GenExplicitMemberStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate member streamer from static functions.
Class streamer object to implement TClassStreamer functionality for I/O emulation.
TCollectionStreamer & operator=(const TCollectionStreamer &)
virtual void operator()(TBuffer &buff, void *obj, Int_t siz=0)
Streamer for I/O handling.
virtual void operator()(TBuffer &buff, void *obj)
Streamer for I/O handling.
TGenCollectionProxy * fStreamer
Pointer to worker streamer.
TCollectionStreamer()
Initializing constructor.
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
TCollectionClassStreamer & operator=(const TCollectionClassStreamer &rhs)
static TVirtualCollectionProxy * GenEmulatedProxy(const char *class_name, Bool_t silent)
Generate emulated collection proxy for a given class.
static TClassStreamer * GenClassStreamer(const T &arg, TClass *cl)
Generate class streamer from template.
TVirtualCollectionProxy Proxy_t
virtual void Stream(TBuffer &b, void *obj, const TClass *onfileClass)
TCollectionProxyFactory Interface to collection proxy and streamer generator.
static TCollectionProxyInfo Get(const T &)
TCollectionMemberStreamer(const TCollectionMemberStreamer &c)
Copy constructor.
TCollectionClassStreamer()
Initializing constructor.
static TMemberStreamer * GenMemberStreamer(const T &arg, TClass *cl)
Generate member streamer from template.
virtual void ReadBuffer(TBuffer &b, void *obj)
TCollectionMemberStreamer & operator=(const TCollectionMemberStreamer &rhs)
TClassRef fOnFileClass
Proxy around an arbitrary container, which implements basic functionality and iteration.
static Proxy_t * GenProxy(const T &arg, TClass *cl)
Generate proxy from template.
void InvalidProxyError()
Issue Error about invalid proxy.
void Streamer(TBuffer &refBuffer, void *obj, int siz, TClass *onFileClass)
Streamer for I/O handling.
TObject * obj
virtual TClass * GetCollectionClass() const
Return a pointer to the TClass representing the container.
TCollectionClassStreamer(const TCollectionClassStreamer &c)
Copy constructor.
static TClassStreamer * GenExplicitClassStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate class streamer from static functions.