TStreamerInfo.h

Go to the documentation of this file.
00001 // @(#)root/io:$Id: TStreamerInfo.h 37697 2011-01-03 10:29:59Z rdm $
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_TStreamerInfo
00013 #define ROOT_TStreamerInfo
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TStreamerInfo                                                        //
00019 //                                                                      //
00020 // Describe Streamer information for one class version                  //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_TVirtualStreamerInfo
00025 #include "TVirtualStreamerInfo.h"
00026 #endif
00027 
00028 #include "TVirtualCollectionProxy.h"
00029 
00030 #if (defined(_MSC_VER) && (_MSC_VER < 1300)) || defined(R__ALPHA) || \
00031     (defined(R__MACOSX) && defined(R__GNU) && __GNUC__==3 && __GNUC_MINOR__<=3) || \
00032     (defined(R__MACOSX) && defined(__xlC__))
00033 #define R__BROKEN_FUNCTION_TEMPLATES
00034 #endif
00035 
00036 class TFile;
00037 class TClass;
00038 class TClonesArray;
00039 class TDataMember;
00040 class TMemberStreamer;
00041 class TStreamerElement;
00042 class TStreamerBasicType;
00043 class TClassStreamer;
00044 class TVirtualArray;
00045 namespace ROOT { class TCollectionProxyInfo; }
00046 
00047 namespace TStreamerInfoActions { class TActionSequence; }
00048 
00049 class TStreamerInfo : public TVirtualStreamerInfo {
00050 
00051 #ifdef R__BROKEN_FUNCTION_TEMPLATES
00052 public:
00053 #endif
00054    class TCompInfo {
00055    // Class used to cache information (see fComp)
00056    private:
00057       TCompInfo(const TCompInfo&); // Not implemented
00058       TCompInfo& operator=(const TCompInfo&); // Not implemented
00059    public:
00060       TClass          *fClass;
00061       TClass          *fNewClass;
00062       TString          fClassName;
00063       TMemberStreamer *fStreamer;
00064       TCompInfo() : fClass(0), fNewClass(0), fClassName(""), fStreamer(0) {};
00065       ~TCompInfo() {};
00066       void Update(const TClass *oldcl, TClass *newcl);
00067    };
00068 
00069 protected:
00070    //---------------------------------------------------------------------------
00071    // Adatper class used to handle streaming collection of pointers
00072    //---------------------------------------------------------------------------
00073    class TPointerCollectionAdapter
00074    {
00075    public:
00076       TPointerCollectionAdapter( TVirtualCollectionProxy *proxy ):
00077          fProxy( proxy ) {}
00078 
00079       char* operator[]( UInt_t idx ) const
00080       {
00081          char **el = (char**)fProxy->At(idx);
00082          return *el;
00083       }
00084    private:
00085       TVirtualCollectionProxy *fProxy;
00086    };
00087 
00088 private:
00089    UInt_t            fCheckSum;          //checksum of original class
00090    Int_t             fClassVersion;      //Class version identifier
00091    Int_t             fOnFileClassVersion;//!Class version identifier as stored on file.
00092    Int_t             fNumber;            //!Unique identifier
00093    Int_t             fNdata;             //!number of optmized types
00094    Int_t             fSize;              //!size of the persistent class
00095    Int_t            *fType;              //![fNdata]
00096    Int_t            *fNewType;           //![fNdata]
00097    Int_t            *fOffset;            //![fNdata]
00098    Int_t            *fLength;            //![fNdata]
00099    ULong_t          *fElem;              //![fNdata]
00100    ULong_t          *fMethod;            //![fNdata]
00101    TCompInfo        *fComp;              //![fNdata] additional info
00102    TClass           *fClass;             //!pointer to class
00103    TObjArray        *fElements;          //Array of TStreamerElements
00104    Version_t         fOldVersion;        //! Version of the TStreamerInfo object read from the file
00105    Int_t             fNVirtualInfoLoc;   //! Number of virtual info location to update.
00106    ULong_t          *fVirtualInfoLoc;    //![fNVirtualInfoLoc] Location of the pointer to the TStreamerInfo inside the object (when emulated)
00107    ULong_t           fLiveCount;         //! Number of outstanding pointer to this StreamerInfo.
00108 
00109    TStreamerInfoActions::TActionSequence *fReadObjectWise;      //! List of action resulting from the compilation.
00110    TStreamerInfoActions::TActionSequence *fReadMemberWise;      //! List of action resulting from the compilation for use in member wise streaming.
00111    
00112    static  Int_t     fgCount;            //Number of TStreamerInfo instances
00113    static TStreamerElement *fgElement;   //Pointer to current TStreamerElement
00114    static Double_t   GetValueAux(Int_t type, void *ladd, int k, Int_t len);
00115    static void       PrintValueAux(char *ladd, Int_t atype, TStreamerElement * aElement, Int_t aleng, Int_t *count);
00116 
00117    UInt_t            GenerateIncludes(FILE *fp, char *inclist, const TList *extrainfos);
00118    void              GenerateDeclaration(FILE *fp, FILE *sfp, const TList *subClasses, Bool_t top = kTRUE);
00119    void              InsertArtificialElements(const TObjArray *rules);
00120    void              DestructorImpl(void* p, Bool_t dtorOnly);
00121 
00122 private:
00123    TStreamerInfo(const TStreamerInfo&);            // TStreamerInfo are copiable.  Not Implemented.
00124    TStreamerInfo& operator=(const TStreamerInfo&); // TStreamerInfo are copiable.  Not Implemented.
00125 
00126 public:
00127 
00128    //status bits
00129    enum { kCannotOptimize        = BIT(12),
00130           kIgnoreTObjectStreamer = BIT(13),  // eventhough BIT(13) is taken up by TObject (to preserverse forward compatibility)
00131           kRecovered             = BIT(14),
00132           kNeedCheck             = BIT(15),
00133           kIsCompiled            = BIT(16)
00134    };
00135 
00136    enum EReadWrite {
00137       kBase        =  0,  kOffsetL = 20,  kOffsetP = 40,  kCounter =  6,  kCharStar = 7,
00138       kChar        =  1,  kShort   =  2,  kInt     =  3,  kLong    =  4,  kFloat    = 5,
00139       kDouble      =  8,  kDouble32=  9,
00140       kUChar       = 11,  kUShort  = 12,  kUInt    = 13,  kULong   = 14,  kBits     = 15,
00141       kLong64      = 16,  kULong64 = 17,  kBool    = 18,  kFloat16 = 19,
00142       kObject      = 61,  kAny     = 62,  kObjectp = 63,  kObjectP = 64,  kTString  = 65,
00143       kTObject     = 66,  kTNamed  = 67,  kAnyp    = 68,  kAnyP    = 69,  kAnyPnoVT = 70,
00144       kSTLp        = 71,
00145       kSkip        = 100, kSkipL = 120, kSkipP   = 140,
00146       kConv        = 200, kConvL = 220, kConvP   = 240,
00147       kSTL         = 300, kSTLstring = 365,
00148       kStreamer    = 500, kStreamLoop = 501,
00149       kCache       = 600,  // Cache the value in memory than is not part of the object but is accessible via a SchemaRule
00150       kArtificial  = 1000, 
00151       kCacheNew    = 1001,
00152       kCacheDelete = 1002,
00153       kMissing     = 99999
00154    };
00155 
00156 //      Some comments about EReadWrite
00157 //      kBase    : base class element
00158 //      kOffsetL : fixed size array
00159 //      kOffsetP : pointer to object
00160 //      kCounter : counter for array size
00161 //      kCharStar: pointer to array of char
00162 //      kBits    : TObject::fBits in case of a referenced object
00163 //      kObject  : Class  derived from TObject
00164 //      kObjectp : Class* derived from TObject and with    comment field //->Class
00165 //      kObjectP : Class* derived from TObject and with NO comment field //->Class
00166 //      kAny     : Class  not derived from TObject
00167 //      kAnyp    : Class* not derived from TObject with    comment field //->Class
00168 //      kAnyP    : Class* not derived from TObject with NO comment field //->Class
00169 // kAnyPnoVT: Class* not derived from TObject with NO comment field //->Class and Class has NO virtual table
00170 // kSTLp    : Pointer to STL container.
00171 //      kTString        : TString, special case
00172 //      kTObject        : TObject, special case
00173 //      kTNamed  : TNamed , special case
00174 
00175 
00176 
00177    TStreamerInfo();
00178    TStreamerInfo(TClass *cl);
00179    virtual            ~TStreamerInfo();
00180    void                Build();
00181    void                BuildCheck();
00182    void                BuildEmulated(TFile *file);
00183    void                BuildOld();
00184    virtual Bool_t      BuildFor( const TClass *cl );
00185    void                CallShowMembers(void* obj, TMemberInspector &insp) const;
00186    void                Clear(Option_t *);
00187    TObject            *Clone(const char *newname = "") const;
00188    Bool_t              CompareContent(TClass *cl,TVirtualStreamerInfo *info, Bool_t warn, Bool_t complete);
00189    void                Compile();
00190    void                ComputeSize();
00191    void                ForceWriteInfo(TFile *file, Bool_t force=kFALSE);
00192    Int_t               GenerateHeaderFile(const char *dirname, const TList *subClasses = 0, const TList *extrainfos = 0);
00193    TClass             *GetActualClass(const void *obj) const;
00194    TClass             *GetClass() const {return fClass;}
00195    UInt_t              GetCheckSum() const {return fCheckSum;}
00196    UInt_t              GetCheckSum(UInt_t code) const;
00197    Int_t               GetClassVersion() const {return fClassVersion;}
00198    Int_t               GetDataMemberOffset(TDataMember *dm, TMemberStreamer *&streamer) const;
00199    TObjArray          *GetElements() const {return fElements;}
00200    ULong_t            *GetElems()   const {return fElem;}
00201    TStreamerInfoActions::TActionSequence *GetReadMemberWiseActions(Bool_t forCollection) { return forCollection ? fReadMemberWise : fReadObjectWise; }
00202    TStreamerInfoActions::TActionSequence *GetReadObjectWiseActions() { return fReadObjectWise; }
00203    Int_t               GetNdata()   const {return fNdata;}
00204    Int_t               GetNumber()  const {return fNumber;}
00205    Int_t              *GetLengths() const {return fLength;}
00206    ULong_t            *GetMethods() const {return fMethod;}
00207    Int_t              *GetNewTypes() const {return fNewType;}
00208    Int_t               GetOffset(const char *) const;
00209    Int_t              *GetOffsets() const {return fOffset;}
00210    Version_t           GetOldVersion() const {return fOldVersion;}
00211    Int_t               GetOnFileClassVersion() const {return fOnFileClassVersion;}
00212    Int_t               GetSize()    const;
00213    Int_t               GetSizeElements()    const;
00214    TStreamerElement   *GetStreamerElement(const char*datamember, Int_t& offset) const;
00215    TStreamerElement   *GetStreamerElementReal(Int_t i, Int_t j) const;
00216    Int_t              *GetTypes()   const {return fType;}
00217    Double_t            GetValue(char *pointer, Int_t i, Int_t j, Int_t len) const;
00218    Double_t            GetValueClones(TClonesArray *clones, Int_t i, Int_t j, Int_t k, Int_t eoffset) const;
00219    Double_t            GetValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_t j, Int_t k, Int_t eoffset) const;
00220    Double_t            GetValueSTLP(TVirtualCollectionProxy *cont, Int_t i, Int_t j, Int_t k, Int_t eoffset) const;
00221    void                ls(Option_t *option="") const;
00222    TVirtualStreamerInfo *NewInfo(TClass *cl) {return new TStreamerInfo(cl);}
00223    void               *New(void *obj = 0);
00224    void               *NewArray(Long_t nElements, void* ary = 0);
00225    void                Destructor(void* p, Bool_t dtorOnly = kFALSE);
00226    void                DeleteArray(void* p, Bool_t dtorOnly = kFALSE);
00227    void                PrintValue(const char *name, char *pointer, Int_t i, Int_t len, Int_t lenmax=1000) const;
00228    void                PrintValueClones(const char *name, TClonesArray *clones, Int_t i, Int_t eoffset, Int_t lenmax=1000) const;
00229    void                PrintValueSTL(const char *name, TVirtualCollectionProxy *cont, Int_t i, Int_t eoffset, Int_t lenmax=1000) const;
00230 
00231 #ifdef R__BROKEN_FUNCTION_TEMPLATES
00232    // Support for non standard compilers
00233    Int_t               ReadBuffer(TBuffer &b,  char** const &arrptr, Int_t first,Int_t narr=1,Int_t eoffset=0,Int_t mode=0);
00234    Int_t               ReadBufferSkip(TBuffer &b, char** const &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00235    Int_t               ReadBufferConv(TBuffer &b, char** const &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00236    Int_t               ReadBufferArtificial(TBuffer &b, char** const &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00237    Int_t               ReadBuffer(TBuffer &b, const TVirtualCollectionProxy &arrptr, Int_t first,Int_t narr=1,Int_t eoffset=0,Int_t mode=0);
00238    Int_t               ReadBufferSkip(TBuffer &b, const TVirtualCollectionProxy &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00239    Int_t               ReadBufferConv(TBuffer &b, const TVirtualCollectionProxy &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00240    Int_t               ReadBufferArtificial(TBuffer &b, const TVirtualCollectionProxy &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00241    Int_t               ReadBuffer(TBuffer &b, const TVirtualArray &arrptr, Int_t first,Int_t narr=1,Int_t eoffset=0,Int_t mode=0);
00242    Int_t               ReadBufferSkip(TBuffer &b, const TVirtualArray &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00243    Int_t               ReadBufferConv(TBuffer &b, const TVirtualArray &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00244    Int_t               ReadBufferArtificial(TBuffer &b, const TVirtualArray &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00245 #else
00246    template <class T>
00247    Int_t               ReadBuffer(TBuffer &b, const T &arrptr, Int_t first,Int_t narr=1,Int_t eoffset=0,Int_t mode=0);
00248    template <class T>
00249    Int_t               ReadBufferSkip(TBuffer &b, const T &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00250    template <class T>
00251    Int_t               ReadBufferConv(TBuffer &b, const T &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00252    template <class T>
00253    Int_t               ReadBufferArtificial(TBuffer &b, const T &arrptr, Int_t i,Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset);
00254 #endif
00255 
00256    Int_t               ReadBufferClones(TBuffer &b, TClonesArray *clones, Int_t nc, Int_t first, Int_t eoffset);
00257    Int_t               ReadBufferSTL(TBuffer &b, TVirtualCollectionProxy *cont, Int_t nc, Int_t first, Int_t eoffset );
00258    void                SetCheckSum(UInt_t checksum) {fCheckSum = checksum;}
00259    void                SetClass(TClass *cl) {fClass = cl;}
00260    void                SetClassVersion(Int_t vers) {fClassVersion=vers;}
00261    void                TagFile(TFile *fFile);
00262    Int_t               WriteBuffer(TBuffer &b, char *pointer, Int_t first);
00263    Int_t               WriteBufferClones(TBuffer &b, TClonesArray *clones, Int_t nc, Int_t first, Int_t eoffset);
00264    Int_t               WriteBufferSTL   (TBuffer &b, TVirtualCollectionProxy *cont,   Int_t nc, Int_t first, Int_t eoffset );
00265    Int_t               WriteBufferSTLPtrs( TBuffer &b, TVirtualCollectionProxy *cont, Int_t nc, Int_t first, Int_t eoffset );
00266    virtual void        Update(const TClass *oldClass, TClass *newClass);
00267 
00268    virtual TVirtualCollectionProxy *GenEmulatedProxy(const char* class_name);
00269    virtual TClassStreamer *GenEmulatedClassStreamer(const char* class_name);
00270    virtual TVirtualCollectionProxy *GenExplicitProxy( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
00271    virtual TClassStreamer *GenExplicitClassStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
00272 
00273    static TStreamerElement   *GetCurrentElement();
00274 
00275 
00276 #ifdef R__BROKEN_FUNCTION_TEMPLATES
00277    // Support for non standard compilers
00278    Int_t               WriteBufferAux      (TBuffer &b, char ** const &arr, Int_t first,Int_t narr,Int_t eoffset,Int_t mode);
00279    Int_t               WriteBufferAux      (TBuffer &b, const TVirtualCollectionProxy &arr, Int_t first,Int_t narr,Int_t eoffset,Int_t mode);
00280    Int_t               WriteBufferAux      (TBuffer &b, const TPointerCollectionAdapter &arr, Int_t first,Int_t narr,Int_t eoffset,Int_t mode);
00281    Int_t               WriteBufferAux      (TBuffer &b, const TVirtualArray &arr, Int_t first,Int_t narr,Int_t eoffset,Int_t mode);
00282 #else
00283    template <class T>
00284    Int_t               WriteBufferAux      (TBuffer &b, const T &arr, Int_t first,Int_t narr,Int_t eoffset,Int_t mode);
00285 #endif
00286 
00287    //WARNING this class version must be the same as TVirtualStreamerInfo
00288    ClassDef(TStreamerInfo,9)  //Streamer information for one class version
00289 };
00290 
00291 
00292 #endif

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