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 <vector>
22
24
25#include "TClassStreamer.h"
26
27#include "TMemberStreamer.h"
28
29#include "TGenCollectionProxy.h"
30
31// Forward declarations
32class 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*/
68public:
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*/
128private:
130
131protected:
132 TGenCollectionProxy* fStreamer; ///< Pointer to worker streamer
133
134 /// Issue Error about invalid proxy
135 void InvalidProxyError();
136
137public:
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:
162 /// Copy constructor
165
166public:
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 */
208private:
210public:
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
#define b(i)
Definition: RSha256.hxx:100
#define c(i)
Definition: RSha256.hxx:101
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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:75
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