TStreamerElement.h

Go to the documentation of this file.
00001 // @(#)root/meta:$Id: TStreamerElement.h 36543 2010-11-08 17:51:01Z pcanal $
00002 // Author: Rene Brun   12/10/2000
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TStreamerElement
00013 #define ROOT_TStreamerElement
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TStreamerElement                                                     //
00019 //                                                                      //
00020 // Describe one element (data member) to be Streamed                    //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_TNamed
00025 #include "TNamed.h"
00026 #endif
00027 
00028 class TMethodCall;
00029 class TClass;
00030 class TStreamerBasicType;
00031 
00032 class TStreamerElement : public TNamed {
00033 
00034 private:
00035    TStreamerElement(const TStreamerElement &);          // Not implemented
00036    TStreamerElement&operator=(const TStreamerElement&); // Not implemented
00037 
00038 protected:
00039    Int_t            fType;            //element type
00040    Int_t            fSize;            //sizeof element
00041    Int_t            fArrayLength;     //cumulative size of all array dims
00042    Int_t            fArrayDim;        //number of array dimensions
00043    Int_t            fMaxIndex[5];     //Maximum array index for array dimension "dim"
00044    Int_t            fOffset;          //!element offset in class
00045    Int_t            fTObjectOffset;   //!base offset for TObject if the element inherits from it
00046    Int_t            fNewType;         //!new element type when reading
00047    TString          fTypeName;        //Data type name of data member
00048    TClass          *fClassObject;     //!pointer to class of object
00049    TClass          *fNewClass;        //!new element class when reading
00050    TMemberStreamer *fStreamer;        //!pointer to element Streamer
00051    Double_t         fXmin;            //!Minimum of data member if a range is specified  [xmin,xmax,nbits]
00052    Double_t         fXmax;            //!Maximum of data member if a range is specified  [xmin,xmax,nbits]
00053    Double_t         fFactor;          //!Conversion factor if a range is specified fFactor = (1<<nbits/(xmax-xmin)
00054 
00055 public:
00056 
00057    enum ESTLtype { kSTL       = 300 /* TVirtualStreamerInfo::kSTL */, 
00058                    kSTLstring = 365 /* TVirtualStreamerInfo::kSTLstring */,   
00059                    kSTLvector =  1,
00060                    kSTLlist   =  2,  kSTLdeque   =  3,   kSTLmap      = 4,
00061                    kSTLset    =  5,  kSTLmultimap=  6,   kSTLmultiset = 7, 
00062                    kSTLbitset =  8
00063    };
00064    // TStreamerElement status bits
00065    enum {
00066       kHasRange     = BIT(6),
00067       kCache        = BIT(9),
00068       kRepeat       = BIT(10),
00069       kRead         = BIT(11),
00070       kWrite        = BIT(12),
00071       kDoNotDelete  = BIT(13)
00072    };
00073 
00074    TStreamerElement();
00075    TStreamerElement(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName);
00076    virtual         ~TStreamerElement();
00077    virtual Bool_t   CannotSplit() const;
00078    Int_t            GetArrayDim() const {return fArrayDim;}
00079    Int_t            GetArrayLength() const {return fArrayLength;}
00080    virtual TClass  *GetClassPointer() const;
00081            TClass  *GetClass()        const {return GetClassPointer();} 
00082    virtual Int_t    GetExecID() const;
00083    virtual const char *GetFullName() const;
00084    virtual const char *GetInclude() const {return "";}
00085    Int_t            GetMaxIndex(Int_t i) const {return fMaxIndex[i];}
00086    virtual ULong_t  GetMethod() const {return ULong_t(fStreamer);}
00087    TMemberStreamer *GetStreamer() const;
00088    virtual Int_t    GetSize() const;
00089    Int_t            GetNewType() const {return fNewType;}
00090    TClass*          GetNewClass() const { return fNewClass; }
00091    Int_t            GetType() const {return fType;}
00092    Int_t            GetOffset() const {return fOffset;}
00093    Int_t            GetTObjectOffset() const { return fTObjectOffset; }
00094    const char      *GetTypeName() const {return fTypeName.Data();}
00095    const char      *GetTypeNameBasic() const;
00096    Double_t         GetFactor() const {return fFactor;}
00097    Double_t         GetXmin()   const {return fXmin;}
00098    Double_t         GetXmax()   const {return fXmax;}
00099    virtual void     Init(TObject *obj=0);
00100    virtual Bool_t   IsaPointer() const {return kFALSE;}
00101    virtual Bool_t   HasCounter() const {return kFALSE;}
00102    virtual Bool_t   IsOldFormat(const char *newTypeName);
00103    virtual Bool_t   IsBase() const;
00104    virtual void     ls(Option_t *option="") const;
00105    virtual void     SetArrayDim(Int_t dim);
00106    virtual void     SetMaxIndex(Int_t dim, Int_t max);
00107    virtual void     SetOffset(Int_t offset) {fOffset=offset;}
00108    virtual void     SetTObjectOffset(Int_t tobjoffset) {fTObjectOffset=tobjoffset;}
00109    virtual void     SetStreamer(TMemberStreamer *streamer);
00110    virtual void     SetSize(Int_t dsize) {fSize = dsize;}
00111    virtual void     SetNewType(Int_t dtype) {fNewType = dtype;}
00112    virtual void     SetNewClass( TClass* cl ) { fNewClass= cl; }
00113    virtual void     SetType(Int_t dtype) {fType = dtype;}
00114    virtual void     SetTypeName(const char *name) {fTypeName = name; fClassObject = (TClass*)-1; }
00115    virtual void     Update(const TClass *oldClass, TClass *newClass);
00116 
00117    ClassDef(TStreamerElement,4)  //Base class for one element (data member) to be Streamed
00118 };
00119 
00120 //________________________________________________________________________
00121 class TStreamerBase : public TStreamerElement {
00122 
00123 private:
00124    TStreamerBase(const TStreamerBase &);          // Not implemented
00125    TStreamerBase&operator=(const TStreamerBase&); // Not implemented
00126    
00127 protected:
00128    Int_t             fBaseVersion;    //version number of the base class FIXME: What for? What about the schema evolution issues?
00129    TClass           *fBaseClass;      //!pointer to base class
00130    TClass           *fNewBaseClass;   //!pointer to new base class if renamed
00131    ClassStreamerFunc_t fStreamerFunc; //!Pointer to a wrapper around a custom streamer member function.
00132 
00133 public:
00134 
00135    TStreamerBase();
00136    TStreamerBase(const char *name, const char *title, Int_t offset);
00137    virtual         ~TStreamerBase();
00138    Int_t            GetBaseVersion() {return fBaseVersion;}
00139    virtual TClass  *GetClassPointer() const;
00140    const char      *GetInclude() const;
00141    TClass          *GetNewBaseClass() { return fNewBaseClass; }
00142    ULong_t          GetMethod() const {return 0;}
00143    Int_t            GetSize() const;
00144    virtual void     Init(TObject *obj=0);
00145    Bool_t           IsBase() const;
00146    virtual void     ls(Option_t *option="") const;
00147    Int_t            ReadBuffer (TBuffer &b, char *pointer);
00148    void             SetNewBaseClass( TClass* cl ) { fNewBaseClass = cl; }
00149    void             SetBaseVersion(Int_t v) {fBaseVersion = v;}
00150    virtual void     Update(const TClass *oldClass, TClass *newClass);
00151    Int_t            WriteBuffer(TBuffer &b, char *pointer);
00152 
00153    ClassDef(TStreamerBase,3)  //Streamer element of type base class
00154 };
00155 
00156 //________________________________________________________________________
00157 class TStreamerBasicPointer : public TStreamerElement {
00158 
00159 private:
00160    TStreamerBasicPointer(const TStreamerBasicPointer &);          // Not implemented
00161    TStreamerBasicPointer&operator=(const TStreamerBasicPointer&); // Not implemented
00162    
00163 protected:
00164    Int_t               fCountVersion;   //version number of the class with the counter
00165    TString             fCountName;      //name of data member holding the array count
00166    TString             fCountClass;     //name of the class with the counter
00167    TStreamerBasicType *fCounter;        //!pointer to basic type counter
00168 
00169 public:
00170 
00171    TStreamerBasicPointer();
00172    TStreamerBasicPointer(const char *name, const char *title, Int_t offset, Int_t dtype, 
00173                          const char *countName, const char *countClass, Int_t version, const char *typeName);
00174    virtual       ~TStreamerBasicPointer();
00175    const char    *GetCountClass()   const {return fCountClass.Data();}
00176    const char    *GetCountName()    const {return fCountName.Data();}
00177    Int_t          GetCountVersion() const {return fCountVersion;}
00178    ULong_t        GetMethod() const;
00179    Int_t          GetSize() const;
00180    virtual void   Init(TObject *obj=0);
00181    virtual Bool_t HasCounter() const                {return fCounter!=0;   }
00182    virtual Bool_t IsaPointer() const                {return kTRUE;         }
00183    void           SetArrayDim(Int_t dim);
00184    void           SetCountClass(const char *clname) {fCountClass = clname; }
00185    void           SetCountName(const char *name)    {fCountName = name;    }
00186    void           SetCountVersion(Int_t count)      {fCountVersion = count;}
00187    
00188    ClassDef(TStreamerBasicPointer,2)  //Streamer element for a pointer to a basic type
00189 };
00190 
00191 //________________________________________________________________________
00192 class TStreamerLoop : public TStreamerElement {
00193 
00194 private:
00195    TStreamerLoop(const TStreamerLoop&);          // Not implemented
00196    TStreamerLoop&operator=(const TStreamerLoop&); // Not implemented
00197    
00198 protected:
00199    Int_t               fCountVersion;   //version number of the class with the counter
00200    TString             fCountName;      //name of data member holding the array count
00201    TString             fCountClass;     //name of the class with the counter
00202    TStreamerBasicType *fCounter;        //!pointer to basic type counter
00203 
00204 public:
00205 
00206    TStreamerLoop();
00207    TStreamerLoop(const char *name, const char *title, Int_t offset, const char *countName, const char *countClass, Int_t version, const char *typeName);
00208    virtual       ~TStreamerLoop();
00209    const char    *GetCountClass()   const {return fCountClass.Data();}
00210    const char    *GetCountName()    const {return fCountName.Data();}
00211    Int_t          GetCountVersion() const {return fCountVersion;}
00212    const char    *GetInclude() const;
00213    ULong_t        GetMethod() const;
00214    Int_t          GetSize() const;
00215    virtual void   Init(TObject *obj=0);
00216    virtual Bool_t IsaPointer() const                {return kTRUE;         }
00217    virtual Bool_t HasCounter() const                {return fCounter!=0;   }
00218    void           SetCountClass(const char *clname) {fCountClass = clname; }
00219    void           SetCountName(const char *name)    {fCountName = name;    }
00220    void           SetCountVersion(Int_t count)      {fCountVersion = count;}
00221 
00222    ClassDef(TStreamerLoop,2)  //Streamer element for a pointer to an array of objects
00223 };
00224 
00225 //________________________________________________________________________
00226 class TStreamerBasicType : public TStreamerElement {
00227 
00228 private:
00229    TStreamerBasicType(const TStreamerBasicType&);          // Not implemented
00230    TStreamerBasicType&operator=(const TStreamerBasicType&); // Not implemented
00231    
00232 protected:
00233    Int_t             fCounter;     //!value of data member when referenced by an array
00234 
00235 public:
00236 
00237    TStreamerBasicType();
00238    TStreamerBasicType(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName);
00239    virtual       ~TStreamerBasicType();
00240    Int_t          GetCounter() const {return fCounter;}
00241    ULong_t        GetMethod() const;
00242    Int_t          GetSize() const;
00243 
00244    ClassDef(TStreamerBasicType,2)  //Streamer element for a basic type
00245 };
00246 
00247 //________________________________________________________________________
00248 class TStreamerObject : public TStreamerElement {
00249 
00250 private:
00251    TStreamerObject(const TStreamerObject&);          // Not implemented
00252    TStreamerObject&operator=(const TStreamerObject&); // Not implemented
00253    
00254 public:
00255 
00256    TStreamerObject();
00257    TStreamerObject(const char *name, const char *title, Int_t offset, const char *typeName);
00258    virtual       ~TStreamerObject();
00259    const char    *GetInclude() const;
00260    Int_t          GetSize() const;
00261    virtual void   Init(TObject *obj=0);
00262 
00263    ClassDef(TStreamerObject,2)  //Streamer element of type object
00264 };
00265 
00266 //________________________________________________________________________
00267 class TStreamerObjectAny : public TStreamerElement {
00268 
00269 private:
00270    TStreamerObjectAny(const TStreamerObjectAny&);          // Not implemented
00271    TStreamerObjectAny&operator=(const TStreamerObjectAny&); // Not implemented
00272    
00273 public:
00274 
00275    TStreamerObjectAny();
00276    TStreamerObjectAny(const char *name, const char *title, Int_t offset, const char *typeName);
00277    virtual       ~TStreamerObjectAny();
00278    const char    *GetInclude() const;
00279    Int_t          GetSize() const;
00280    virtual void   Init(TObject *obj=0);
00281 
00282    ClassDef(TStreamerObjectAny,2)  //Streamer element of type object other than TObject
00283 };
00284 
00285 //________________________________________________________________________
00286 class TStreamerObjectPointer : public TStreamerElement {
00287 
00288 private:
00289    TStreamerObjectPointer(const TStreamerObjectPointer&);          // Not implemented
00290    TStreamerObjectPointer&operator=(const TStreamerObjectPointer&); // Not implemented
00291    
00292 public:
00293 
00294    TStreamerObjectPointer();
00295    TStreamerObjectPointer(const char *name, const char *title, Int_t offset, const char *typeName);
00296    virtual       ~TStreamerObjectPointer();
00297    const char    *GetInclude() const;
00298    Int_t          GetSize() const;
00299    virtual void   Init(TObject *obj=0);
00300    virtual Bool_t IsaPointer() const {return kTRUE;}
00301    virtual void   SetArrayDim(Int_t dim);
00302 
00303    ClassDef(TStreamerObjectPointer,2)  //Streamer element of type pointer to a TObject
00304 };
00305 
00306 //________________________________________________________________________
00307 class TStreamerObjectAnyPointer : public TStreamerElement {
00308 
00309 private:
00310    TStreamerObjectAnyPointer(const TStreamerObjectAnyPointer&);          // Not implemented
00311    TStreamerObjectAnyPointer&operator=(const TStreamerObjectAnyPointer&); // Not implemented
00312    
00313 public:
00314 
00315    TStreamerObjectAnyPointer();
00316    TStreamerObjectAnyPointer(const char *name, const char *title, Int_t offset, const char *typeName);
00317    virtual       ~TStreamerObjectAnyPointer();
00318    const char    *GetInclude() const;
00319    Int_t          GetSize() const;
00320    virtual void   Init(TObject *obj=0);
00321    virtual Bool_t IsaPointer() const {return kTRUE;}
00322    virtual void   SetArrayDim(Int_t dim);
00323    
00324    ClassDef(TStreamerObjectAnyPointer,1)  //Streamer element of type pointer to a non TObject
00325 };
00326 
00327 //________________________________________________________________________
00328 class TStreamerString : public TStreamerElement {
00329 
00330 private:
00331    TStreamerString(const TStreamerString&);          // Not implemented
00332    TStreamerString&operator=(const TStreamerString&); // Not implemented
00333    
00334 public:
00335 
00336    TStreamerString();
00337    TStreamerString(const char *name, const char *title, Int_t offset);
00338    virtual       ~TStreamerString();
00339    const char    *GetInclude() const;
00340    Int_t          GetSize() const;
00341 
00342    ClassDef(TStreamerString,2)  //Streamer element of type TString
00343 };
00344 
00345 //________________________________________________________________________
00346 class TStreamerSTL : public TStreamerElement {
00347 
00348    enum {
00349       kWarned       = BIT(21)
00350    };
00351    
00352 private:
00353    TStreamerSTL(const TStreamerSTL&);          // Not implemented
00354    TStreamerSTL&operator=(const TStreamerSTL&); // Not implemented
00355    
00356 protected:
00357    Int_t       fSTLtype;       //type of STL vector
00358    Int_t       fCtype;         //STL contained type
00359 
00360 public:
00361 
00362    TStreamerSTL();
00363    TStreamerSTL(const char *name, const char *title, Int_t offset, 
00364                 const char *typeName, const char *trueType, Bool_t dmPointer);
00365    virtual       ~TStreamerSTL();
00366    Bool_t         CannotSplit() const;
00367    Bool_t         IsaPointer() const;
00368    Bool_t         IsBase() const;
00369    Int_t          GetSTLtype() const {return fSTLtype;}
00370    Int_t          GetCtype()   const {return fCtype;}
00371    const char    *GetInclude() const;
00372    Int_t          GetSize() const;
00373    virtual void   ls(Option_t *option="") const;
00374    void           SetSTLtype(Int_t t) {fSTLtype = t;}
00375    void           SetCtype(Int_t t) {fCtype = t;}
00376    virtual void   SetStreamer(TMemberStreamer *streamer);
00377 
00378    ClassDef(TStreamerSTL,3)  //Streamer element of type STL container
00379 };
00380 
00381 //________________________________________________________________________
00382 class TStreamerSTLstring : public TStreamerSTL {
00383 
00384 private:
00385    TStreamerSTLstring(const TStreamerSTLstring&);          // Not implemented
00386    TStreamerSTLstring&operator=(const TStreamerSTLstring&); // Not implemented
00387    
00388 public:
00389 
00390    TStreamerSTLstring();
00391    TStreamerSTLstring(const char *name, const char *title, Int_t offset,
00392                       const char *typeName, Bool_t dmPointer);
00393    virtual       ~TStreamerSTLstring();
00394    const char    *GetInclude() const;
00395    Int_t          GetSize() const;
00396 
00397    ClassDef(TStreamerSTLstring,2)  //Streamer element of type  C++ string
00398 };
00399 
00400 class TVirtualObject;
00401 class TBuffer;
00402 
00403 #include "TSchemaRule.h"
00404 
00405 //________________________________________________________________________
00406 class TStreamerArtificial : public TStreamerElement {
00407 private:
00408    TStreamerArtificial(const TStreamerArtificial&);          // Not implemented
00409    TStreamerArtificial&operator=(const TStreamerArtificial&); // Not implemented
00410    
00411 protected:
00412    ROOT::TSchemaRule::ReadFuncPtr_t     fReadFunc;    //!
00413    ROOT::TSchemaRule::ReadRawFuncPtr_t  fReadRawFunc; //!
00414 
00415 public:
00416 
00417    // TStreamerArtificial() : fReadFunc(0),fReadRawFunc(0) {}
00418 
00419    TStreamerArtificial(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName) : TStreamerElement(name,title,offset,dtype,typeName), fReadFunc(0), fReadRawFunc(0) {}
00420 
00421    void SetReadFunc( ROOT::TSchemaRule::ReadFuncPtr_t val ) { fReadFunc = val; };
00422    void SetReadRawFunc( ROOT::TSchemaRule::ReadRawFuncPtr_t val ) { fReadRawFunc = val; };
00423 
00424    ROOT::TSchemaRule::ReadFuncPtr_t     GetReadFunc();
00425    ROOT::TSchemaRule::ReadRawFuncPtr_t  GetReadRawFunc(); 
00426 
00427    ClassDef(TStreamerArtificial, 0); // StreamerElement injected by a TSchemaRule. Transient only to preverse forward compatibility.
00428 };
00429 
00430 #endif

Generated on Tue Jul 5 14:11:41 2011 for ROOT_528-00b_version by  doxygen 1.5.1