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