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
22
23#include "TClassStreamer.h"
24
25#include "TMemberStreamer.h"
26
27#include "TGenCollectionProxy.h"
28
29// Forward declarations
30class 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*/
66public:
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*/
126private:
128
129protected:
130 TGenCollectionProxy* fStreamer; ///< Pointer to worker streamer
131
132 /// Issue Error about invalid proxy
133 void InvalidProxyError();
134
135public:
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
164public:
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 */
206private:
208public:
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
#define b(i)
Definition: RSha256.hxx:100
#define c(i)
Definition: RSha256.hxx:101
static TCollectionProxyInfo Get(const T &)
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
TClassRef fOnFileClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
Class streamer object to implement TClassStreamer functionality for I/O emulation.
virtual ~TCollectionClassStreamer()
Standard destructor.
TCollectionClassStreamer()
Initializing constructor.
virtual TClassStreamer * Generate() const
Virtual copy constructor.
TCollectionClassStreamer & operator=(const TCollectionClassStreamer &rhs)
TGenCollectionProxy * GetXYZ()
virtual void Stream(TBuffer &b, void *obj, const TClass *onfileClass)
TCollectionClassStreamer(const TCollectionClassStreamer &c)
Copy constructor.
virtual void operator()(TBuffer &buff, void *obj)
Streamer for I/O handling.
Class streamer object to implement TMemberStreamer functionality for I/O emulation.
virtual void operator()(TBuffer &buff, void *obj, Int_t siz=0)
Streamer for I/O handling.
virtual ~TCollectionMemberStreamer()
Standard destructor.
TCollectionMemberStreamer()
Initializing constructor.
TCollectionMemberStreamer & operator=(const TCollectionMemberStreamer &rhs)
TCollectionMemberStreamer(const TCollectionMemberStreamer &c)
Copy constructor.
TCollectionProxyFactory Interface to collection proxy and streamer generator.
static TVirtualCollectionProxy * GenEmulatedProxy(const char *class_name, Bool_t silent)
Generate emulated collection proxy for a given class.
TVirtualCollectionProxy Proxy_t
static TClassStreamer * GenEmulatedClassStreamer(const char *class_name, Bool_t silent)
Generate emulated class streamer for a given collection class.
static TMemberStreamer * GenMemberStreamer(const T &arg, TClass *cl)
Generate member streamer from template.
static Proxy_t * GenExplicitProxy(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate proxy from static functions.
static TMemberStreamer * GenEmulatedMemberStreamer(const char *class_name, Bool_t silent)
Generate emulated member streamer for a given collection class.
static TClassStreamer * GenClassStreamer(const T &arg, TClass *cl)
Generate class streamer from template.
static TClassStreamer * GenExplicitClassStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate class streamer from static functions.
const std::type_info & Info_t
static Proxy_t * GenProxy(const T &arg, TClass *cl)
Generate proxy from template.
static TMemberStreamer * GenExplicitMemberStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate member streamer from static functions.
static TGenCollectionStreamer * GenExplicitStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
Generate streamer from static functions.
Class streamer object to implement TClassStreamer functionality for I/O emulation.
TGenCollectionProxy * fStreamer
Pointer to worker streamer.
void InvalidProxyError()
Issue Error about invalid proxy.
virtual ~TCollectionStreamer()
Standard destructor.
void AdoptStreamer(TGenCollectionProxy *streamer)
Attach worker proxy.
TCollectionStreamer & operator=(const TCollectionStreamer &)
TCollectionStreamer()
Initializing constructor.
void Streamer(TBuffer &refBuffer, void *obj, int siz, TClass *onFileClass)
Streamer for I/O handling.
Streamer around an arbitrary STL like container, which implements basic container functionality.
Proxy around an arbitrary container, which implements basic functionality and iteration.
virtual TClass * GetCollectionClass() const
Return a pointer to the TClass representing the container.
virtual void ReadBuffer(TBuffer &b, void *obj)
double T(double x)
Definition: ChebyshevPol.h:34