File indexing completed on 2025-01-18 10:11:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef ROOT_TCollectionProxyFactory
0012 #define ROOT_TCollectionProxyFactory
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "TCollectionProxyInfo.h"
0022
0023 #include "TClassStreamer.h"
0024
0025 #include "TMemberStreamer.h"
0026
0027 #include "TGenCollectionProxy.h"
0028
0029
0030 class TBuffer;
0031 class TGenCollectionProxy;
0032 class TGenCollectionStreamer;
0033 class TVirtualCollectionProxy;
0034 class TEmulatedCollectionProxy;
0035
0036 #if defined(_WIN32)
0037 #if _MSC_VER<1300
0038 #define TYPENAME
0039 #define R__VCXX6
0040 #else
0041 #define TYPENAME typename
0042 #endif
0043 #else
0044 #define TYPENAME typename
0045 #endif
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 class TCollectionProxyFactory {
0066 public:
0067
0068 typedef TVirtualCollectionProxy Proxy_t;
0069 #ifdef R__HPUX
0070 typedef const std::type_info& Info_t;
0071 #else
0072 typedef const std::type_info& Info_t;
0073 #endif
0074
0075
0076 static TVirtualCollectionProxy* GenEmulatedProxy(const char* class_name, Bool_t silent);
0077
0078
0079 static TClassStreamer* GenEmulatedClassStreamer(const char* class_name, Bool_t silent);
0080
0081
0082 static TMemberStreamer* GenEmulatedMemberStreamer(const char* class_name, Bool_t silent);
0083
0084
0085
0086 static Proxy_t* GenExplicitProxy( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
0087
0088
0089 template <class T> static Proxy_t* GenProxy(const T &arg, TClass *cl) {
0090 return GenExplicitProxy( ::ROOT::TCollectionProxyInfo::Get(arg), cl );
0091 }
0092
0093
0094 static TGenCollectionStreamer*
0095 GenExplicitStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
0096
0097
0098 static TClassStreamer*
0099 GenExplicitClassStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
0100
0101
0102 template <class T> static TClassStreamer* GenClassStreamer(const T &arg, TClass *cl) {
0103 return GenExplicitClassStreamer(::ROOT::TCollectionProxyInfo::Get(arg), cl);
0104 }
0105
0106
0107 static TMemberStreamer*
0108 GenExplicitMemberStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl);
0109
0110
0111 template <class T> static TMemberStreamer* GenMemberStreamer(const T &arg, TClass *cl) {
0112 return GenExplicitMemberStreamer(::ROOT::TCollectionProxyInfo::Get(arg), cl);
0113 }
0114 };
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125 class TCollectionStreamer {
0126 private:
0127 TCollectionStreamer& operator=(const TCollectionStreamer&) = delete;
0128
0129 protected:
0130 TGenCollectionProxy* fStreamer;
0131
0132
0133 void InvalidProxyError();
0134
0135 public:
0136
0137 TCollectionStreamer();
0138
0139 TCollectionStreamer(const TCollectionStreamer& c);
0140
0141 virtual ~TCollectionStreamer();
0142
0143 void AdoptStreamer(TGenCollectionProxy* streamer);
0144
0145 void Streamer(TBuffer &refBuffer, void *obj, int siz, TClass *onFileClass );
0146 };
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157 class TCollectionClassStreamer : public TClassStreamer, public TCollectionStreamer {
0158 protected:
0159 TCollectionClassStreamer &operator=(const TCollectionClassStreamer &rhs) = delete;
0160
0161 TCollectionClassStreamer(const TCollectionClassStreamer& c)
0162 : TClassStreamer(c), TCollectionStreamer(c) { }
0163
0164 public:
0165
0166 TCollectionClassStreamer() : TClassStreamer(nullptr) { }
0167
0168 ~TCollectionClassStreamer() override { }
0169
0170 void operator()(TBuffer &buff, void *obj) override { Streamer(buff,obj,0,fOnFileClass); }
0171
0172 void Stream(TBuffer &b, void *obj, const TClass *onfileClass) override
0173 {
0174 if (b.IsReading()) {
0175 TGenCollectionProxy *proxy = TCollectionStreamer::fStreamer;
0176 if (!onfileClass || onfileClass == proxy->GetCollectionClass()) {
0177 proxy->ReadBuffer(b,obj);
0178 } else {
0179 proxy->ReadBuffer(b,obj,onfileClass);
0180 }
0181 } else {
0182
0183 Streamer(b,obj,0,(TClass*)onfileClass);
0184 }
0185 }
0186
0187
0188 TClassStreamer *Generate() const override {
0189 return new TCollectionClassStreamer(*this);
0190 }
0191
0192 TGenCollectionProxy *GetXYZ() { return TCollectionStreamer::fStreamer; }
0193
0194 };
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205 class TCollectionMemberStreamer : public TMemberStreamer, public TCollectionStreamer {
0206 private:
0207 TCollectionMemberStreamer &operator=(const TCollectionMemberStreamer &rhs) = delete;
0208 public:
0209
0210 TCollectionMemberStreamer() : TMemberStreamer(nullptr) { }
0211
0212 TCollectionMemberStreamer(const TCollectionMemberStreamer& c)
0213 : TMemberStreamer(c), TCollectionStreamer(c) { }
0214
0215 ~TCollectionMemberStreamer() override { }
0216
0217 void operator()(TBuffer &buff,void *obj, Int_t siz = 0) override
0218 { Streamer(buff, obj, siz, nullptr); }
0219 };
0220
0221 #endif