#ifndef ROOT_TGenCollectionProxy
#define ROOT_TGenCollectionProxy
#include "TVirtualCollectionProxy.h"
#include "TCollectionProxyFactory.h"
#include <typeinfo>
#include <string>
class TGenCollectionProxy
: public TVirtualCollectionProxy
{
friend class TCollectionProxyFactory;
public:
#ifdef R__HPUX
typedef const type_info& Info_t;
#else
typedef const std::type_info& Info_t;
#endif
enum {
kBIT_ISSTRING = 0x20000000,
kBIT_ISTSTRING = 0x40000000,
kBOOL_t = 21
};
struct Value {
ROOT::NewFunc_t fCtor;
ROOT::DesFunc_t fDtor;
ROOT::DelFunc_t fDelete;
unsigned int fCase;
TClassRef fType;
EDataType fKind;
size_t fSize;
Value(const Value& inside);
Value(const std::string& info);
void DeleteItem(void* ptr);
};
union StreamHelper {
Bool_t boolean;
Char_t s_char;
Short_t s_short;
Int_t s_int;
Long_t s_long;
Long64_t s_longlong;
Float_t flt;
Double_t dbl;
UChar_t u_char;
UShort_t u_short;
UInt_t u_int;
ULong_t u_long;
ULong64_t u_longlong;
void* p_void;
void** pp_void;
char* kchar;
TString* tstr;
void* ptr() {
return *(&this->p_void);
}
std::string* str() {
return (std::string*)this;
}
const char* c_str() {
return ((std::string*)this)->c_str();
}
const char* c_pstr() {
return (*(std::string**)this)->c_str();
}
void set(void* p) {
*(&this->p_void) = p;
}
void read_std_string(TBuffer& b) {
TString s;
s.Streamer(b);
((std::string*)this)->assign(s.Data());
}
void* read_tstring(TBuffer& b) {
*((TString*)this) = "";
((TString*)this)->Streamer(b);
return this;
}
void read_std_string_pointer(TBuffer& b) {
TString s;
std::string* str2 = (std::string*)ptr();
if (!str2) str2 = new std::string();
s.Streamer(b);
*str2 = s;
set(str2);
}
void write_std_string_pointer(TBuffer& b) {
const char* c;
if (ptr()) {
std::string* strptr = (*(std::string**)this);
c = (const char*)(strptr->c_str());
} else c = "";
TString(c).Streamer(b);
}
void read_any_object(Value* v, TBuffer& b) {
void* p = ptr();
if ( p ) {
if ( v->fDelete ) {
(*v->fDelete)(p);
}
else if ( v->fType ) {
v->fType->Destructor(p);
}
else if ( v->fDtor ) {
(*v->fDtor)(p);
::operator delete(p);
}
else {
::operator delete(p);
}
}
set( b.ReadObjectAny(v->fType) );
}
void read_tstring_pointer(Bool_t vsn3, TBuffer& b) {
TString* s = (TString*)ptr();
if ( vsn3 ) {
if ( !s ) s = new TString();
s->Replace(0, s->Length(), 0, 0);
s->Streamer(b);
set(s);
return;
}
if ( s ) delete s;
set( b.ReadObjectAny(TString::Class()) );
}
void write_tstring_pointer(TBuffer& b) {
b.WriteObjectAny(ptr(), TString::Class());
}
};
struct Method {
typedef void* (*Call_t)(void*);
Call_t call;
Method() : call(0) { }
Method(Call_t c) : call(c) { }
Method(const Method& m) : call(m.call) { }
void* invoke(void* obj) const { return (*call)(obj); }
};
protected:
typedef ROOT::TCollectionProxyInfo::Environ<char[64]> Env_t;
typedef std::vector<Env_t*> Proxies_t;
std::string fName;
Bool_t fPointers;
Method fClear;
Method fSize;
Method fResize;
Method fFirst;
Method fNext;
Method fConstruct;
Method fDestruct;
Method fFeed;
Method fCollect;
Value* fValue;
Value* fVal;
Value* fKey;
Env_t* fEnv;
int fValOffset;
int fValDiff;
Proxies_t fProxyList;
Proxies_t fProxyKept;
int fSTL_type;
Info_t fTypeinfo;
TClass* fOnFileClass;
TGenCollectionProxy* Initialize() const;
virtual TGenCollectionProxy* InitializeEx();
virtual void DeleteItem(Bool_t force, void* ptr) const;
void CheckFunctions() const;
public:
virtual TVirtualCollectionProxy* Generate() const;
TGenCollectionProxy(const TGenCollectionProxy& copy);
TGenCollectionProxy(Info_t typ, size_t iter_size);
TGenCollectionProxy(const ROOT::TCollectionProxyInfo &info, TClass *cl);
virtual ~TGenCollectionProxy();
virtual TClass *GetCollectionClass();
virtual UInt_t Sizeof() const;
virtual void PushProxy(void *objstart);
virtual void PopProxy();
virtual Bool_t HasPointers() const;
virtual TClass *GetValueClass();
virtual void SetValueClass(TClass *newcl);
virtual EDataType GetType();
virtual void *At(UInt_t idx);
virtual void Clear(const char *opt = "");
virtual void Resize(UInt_t n, Bool_t force_delete);
virtual UInt_t Size() const;
virtual void* Allocate(UInt_t n, Bool_t forceDelete);
virtual void Commit(void* env);
virtual void Streamer(TBuffer &refBuffer);
virtual void Streamer(TBuffer &refBuffer, void *pObject, int siz);
virtual void operator()(TBuffer &refBuffer, void *pObject);
virtual void SetOnFileClass( TClass* cl ) { fOnFileClass = cl; }
virtual TClass* GetOnFileClass() const { return fOnFileClass; }
};
template <typename T>
struct AnyCollectionProxy : public TGenCollectionProxy {
AnyCollectionProxy()
: TGenCollectionProxy(typeid(T::Cont_t),sizeof(T::Iter_t))
{
fValDiff = sizeof(T::Value_t);
fValOffset = T::value_offset();
fSize.call = T::size;
fResize.call = T::resize;
fNext.call = T::next;
fFirst.call = T::first;
fClear.call = T::clear;
fConstruct.call = T::construct;
fDestruct.call = T::destruct;
fFeed.call = T::feed;
CheckFunctions();
}
virtual ~AnyCollectionProxy() { }
};
#endif
Last change: Fri Sep 19 09:32:43 2008
Last generated: 2008-09-19 09:32
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.