library: libCore #include "TStreamerInfo.h"

# TStreamerInfo

class description - source file - inheritance tree (.pdf)

## class TStreamerInfo : public TNamed

| Inheritance Chart:
`TObject`
| <- | `TNamed`
| <- | `TStreamerInfo` |

        private:

                     void BuildUserInfo(const char* info)
          static Double_t GetValueAux(Int_t type, void* ladd, int k, Int_t len)
              static void PrintValueAux(char* ladd, Int_t atype, TStreamerElement* aElement, Int_t aleng, Int_t* count)

        public:

                                     TStreamerInfo()
                                     TStreamerInfo(TClass* cl, const char* info)
                                     TStreamerInfo(const TStreamerInfo&)
                             virtual ~TStreamerInfo()
                                void Build()
                                void BuildCheck()
                                void BuildEmulated(TFile* file)
                                void BuildOld()
                       static Bool_t CanDelete()
                       static Bool_t CanOptimize()
                      static TClass* Class()
                                void Compile()
                                void ComputeSize()
                                void ForceWriteInfo(TFile* file, Bool_t force = kFALSE)
                               Int_t GenerateHeaderFile(const char* dirname)
                              UInt_t GetCheckSum() const
                             TClass* GetClass() const
                               Int_t GetClassVersion() const
            static TStreamerElement* GetCurrentElement()
                               Int_t GetDataMemberOffset(TDataMember* dm, TMemberStreamer*& streamer) const
          static TStreamerBasicType* GetElementCounter(const char* countName, TClass* cl)
                          TObjArray* GetElements() const
                            ULong_t* GetElems() const
                              Int_t* GetLengths() const
                            ULong_t* GetMethods() const
                               Int_t GetNdata() const
                              Int_t* GetNewTypes() const
                               Int_t GetNumber() const
                               Int_t GetOffset(const char*) const
                              Int_t* GetOffsets() const
                           Version_t GetOldVersion() const
                               Int_t GetSize() const
                               Int_t GetSizeElements() const
                   TStreamerElement* GetStreamerElement(const char* datamember, Int_t& offset) const
                   TStreamerElement* GetStreamerElementReal(Int_t i, Int_t j) const
                       static Bool_t GetStreamMemberWise()
                              Int_t* GetTypes() const
                            Double_t GetValue(char* pointer, Int_t i, Int_t j, Int_t len) const
                            Double_t GetValueClones(TClonesArray* clones, Int_t i, Int_t j, Int_t k, Int_t eoffset) const
                            Double_t GetValueSTL(TVirtualCollectionProxy* cont, Int_t i, Int_t j, Int_t k, Int_t eoffset) const
                     virtual TClass* IsA() const
                              Bool_t IsBuilt() const
                              Bool_t IsOptimized() const
                               Int_t IsRecovered() const
                        virtual void ls(Option_t* option = "") const
                               Int_t New(const char* p)
                      TStreamerInfo& operator=(const TStreamerInfo&)
                         static void Optimize(Bool_t opt = kTRUE)
                                void PrintValue(const char* name, char* pointer, Int_t i, Int_t len, Int_t lenmax = 1000) const
                                void PrintValueClones(const char* name, TClonesArray* clones, Int_t i, Int_t eoffset, Int_t lenmax = 1000) const
                                void PrintValueSTL(const char* name, TVirtualCollectionProxy* cont, Int_t i, Int_t eoffset, Int_t lenmax = 1000) const
                               Int_t ReadBufferClones(TBuffer& b, TClonesArray* clones, Int_t nc, Int_t first, Int_t eoffset)
                               Int_t ReadBufferSTL(TBuffer& b, TVirtualCollectionProxy* cont, Int_t nc, Int_t first, Int_t eoffset)
                         static void SetCanDelete(Bool_t opt = kTRUE)
                                void SetCheckSum(UInt_t checksum)
                                void SetClass(TClass* cl)
                                void SetClassVersion(Int_t vers)
                       static Bool_t SetStreamMemberWise(Bool_t enable = kTRUE)
                        virtual void ShowMembers(TMemberInspector& insp, char* parent)
                        virtual void Streamer(TBuffer& b)
                                void StreamerNVirtual(TBuffer& b)
                                void TagFile(TFile* fFile)
                        virtual void Update(const TClass* oldClass, TClass* newClass)
                               Int_t WriteBuffer(TBuffer& b, char* pointer, Int_t first)
                               Int_t WriteBufferClones(TBuffer& b, TClonesArray* clones, Int_t nc, Int_t first, Int_t eoffset)
                               Int_t WriteBufferSTL(TBuffer& b, TVirtualCollectionProxy* cont, Int_t nc, Int_t first, Int_t eoffset)

### Data Members

        private:

                            UInt_t fCheckSum           checksum of original class
                             Int_t fClassVersion       Class version identifier
                             Int_t fNumber             !Unique identifier
                             Int_t fNdata              !number of optmized types
                             Int_t fSize               !size of the persistent class
                            Int_t* fType               ![fNdata]
                            Int_t* fNewType            ![fNdata]
                            Int_t* fOffset             ![fNdata]
                            Int_t* fLength             ![fNdata]
                          ULong_t* fElem               ![fNdata]
                          ULong_t* fMethod             ![fNdata]
          TStreamerInfo::CompInfo* fComp               ![fNdata] additional info
                            Bool_t fOptimized          ! true if has been optimized
                           TClass* fClass              !pointer to class
                        TObjArray* fElements           Array of TStreamerElements
                         Version_t fOldVersion         ! Version of the TStreamerInfo object read from the file
                            Bool_t fIsBuilt            ! true if the TStreamerInfo has been 'built'
                      static Int_t fgCount             Number of TStreamerInfo instances
                     static Bool_t fgCanDelete         True if ReadBuffer can delete object
                     static Bool_t fgOptimize          True if optimization on
                     static Bool_t fgStreamMemberWise  True if the collections are to be stream "member-wise" (when possible).
          static TStreamerElement* fgElement           Pointer to current TStreamerElement

        public:

               static const enum TStreamerInfo:: kCannotOptimize
               static const enum TStreamerInfo:: kRecovered
          static const TStreamerInfo::EReadWrite kBase
          static const TStreamerInfo::EReadWrite kOffsetL
          static const TStreamerInfo::EReadWrite kOffsetP
          static const TStreamerInfo::EReadWrite kCounter
          static const TStreamerInfo::EReadWrite kCharStar
          static const TStreamerInfo::EReadWrite kChar
          static const TStreamerInfo::EReadWrite kShort
          static const TStreamerInfo::EReadWrite kInt
          static const TStreamerInfo::EReadWrite kLong
          static const TStreamerInfo::EReadWrite kFloat
          static const TStreamerInfo::EReadWrite kDouble
          static const TStreamerInfo::EReadWrite kDouble32
          static const TStreamerInfo::EReadWrite kUChar
          static const TStreamerInfo::EReadWrite kUShort
          static const TStreamerInfo::EReadWrite kUInt
          static const TStreamerInfo::EReadWrite kULong
          static const TStreamerInfo::EReadWrite kBits
          static const TStreamerInfo::EReadWrite kLong64
          static const TStreamerInfo::EReadWrite kULong64
          static const TStreamerInfo::EReadWrite kBool
          static const TStreamerInfo::EReadWrite kObject
          static const TStreamerInfo::EReadWrite kAny
          static const TStreamerInfo::EReadWrite kObjectp
          static const TStreamerInfo::EReadWrite kObjectP
          static const TStreamerInfo::EReadWrite kTString
          static const TStreamerInfo::EReadWrite kTObject
          static const TStreamerInfo::EReadWrite kTNamed
          static const TStreamerInfo::EReadWrite kAnyp
          static const TStreamerInfo::EReadWrite kAnyP
          static const TStreamerInfo::EReadWrite kAnyPnoVT
          static const TStreamerInfo::EReadWrite kSTLp
          static const TStreamerInfo::EReadWrite kSkip
          static const TStreamerInfo::EReadWrite kSkipL
          static const TStreamerInfo::EReadWrite kSkipP
          static const TStreamerInfo::EReadWrite kConv
          static const TStreamerInfo::EReadWrite kConvL
          static const TStreamerInfo::EReadWrite kConvP
          static const TStreamerInfo::EReadWrite kSTL
          static const TStreamerInfo::EReadWrite kSTLstring
          static const TStreamerInfo::EReadWrite kStreamer
          static const TStreamerInfo::EReadWrite kStreamLoop
          static const TStreamerInfo::EReadWrite kMissing

## Class Description

TStreamerInfo()

     Default ctor.

TStreamerInfo(TClass *cl, const char *info) : TNamed(cl->GetName(),info)

     Create a TStreamerInfo object.

~TStreamerInfo()

     TStreamerInfo dtor.

void Build()

     Build the I/O data structure for the current class version
     A list of TStreamerElement derived classes is built by scanning
     one by one the list of data members of the analyzed class.

void BuildCheck()

     check if the TStreamerInfo structure is already created
     called by TFile::ReadStreamerInfo

void BuildEmulated(TFile *file)

     Create an Emulation TStreamerInfo object.

void BuildOld()

     rebuild the TStreamerInfo structure

void BuildUserInfo(const char * /*info*/)

     Build the I/O data structure for the current class version

Bool_t CanDelete()

     static function returning true if ReadBuffer can delete object

Bool_t CanOptimize()

     static function returning true if optimization can be on

void Compile()

     loop on the TStreamerElement list
     regroup members with same type
     Store predigested information into local arrays. This saves a huge amount
     of time compared to an explicit iteration on all elements.

void ComputeSize()

     Compute total size of all persistent elements of the class

void ForceWriteInfo(TFile *file, Bool_t force)

     will force this TStreamerInfo to the file and also
     all the dependencies.
     This function is called when streaming a class that contains
     a null pointer. In this case, the TStreamerInfo for the class
     with the null pointer must be written to the file and also all the
     TStreamerInfo of all the classes referenced by the class.

     if argument force > 0 the loop on class dependencies is forced

Int_t GenerateHeaderFile(const char *dirname)

     Generate header file for the class described by this TStreamerInfo
     the function is called by TFile::MakeProject for each class in the file

TStreamerElement* GetCurrentElement()

    static function returning a pointer to the current TStreamerElement
    fgElement points to the current TStreamerElement being read in ReadBuffer

Int_t GetDataMemberOffset(TDataMember *dm, TMemberStreamer *&streamer) const

     Compute data member offset
     return pointer to the Streamer function if one exists

TStreamerBasicType* GetElementCounter(const char *countName, TClass *cl)

     Get pointer to a TStreamerBasicType in TClass *cl
    static function

Int_t GetOffset(const char *elementName) const

     return the offset of the data member as indicated by this StreamerInfo

Int_t GetSize() const

      return total size of all persistent elements of the class (with offsets)

Int_t GetSizeElements() const

      return total size of all persistent elements of the class
      use GetSize if you want to get the real size in memory

TStreamerElement* GetStreamerElement(const char* datamember, Int_t &offset) const

      Return the StreamerElement of "datamember" inside this class of any of its
      base class.  The offset information contained in the StreamerElement is related
      to its immediate containing class, so we return in 'offset' the offset inside
      the class of this streamerInfo.

TStreamerElement* GetStreamerElementReal(Int_t i, Int_t j) const

      TStreamerInfo  holds two types of data structures
        -TObjArray* fElements; containing the list of all TStreamerElement
           objects for this class version.
        -ULong_t*  fElem;  containing the preprocessed information
           by TStreamerInfo::Compile In case consecutive data members
           are of the same type, the Compile function declares the consecutive
           elements as one single element in fElems.

      example with the class TAttLine
       gROOT->GetClass("TAttLine")->GetStreamerInfo()->ls(); produces;
          StreamerInfo for class: TAttLine, version=1
           short        fLineColor      offset=  4 type= 2 line color
           short        fLineStyle      offset=  6 type= 2 line style
           short        fLineWidth      offset=  8 type= 2 line width
            i= 0, fLineColor      type= 22, offset=  4, len=3, method=0
      For I/O implementations (eg. XML) , one has to know the original name
      of the data member. This function can be used to return a pointer
      to the original TStreamerElement object corresponding to the j-th
      element of a compressed array in fElems.

      parameters description:
        - i: the serial number in array fElem
        - j: the element number in the array of consecutive types
      In the above example the class TAttLine has 3 consecutive data members
      of the same type "short". Compile makes one single array of 3 elements.
      To access the TStreamerElement for the second element
      of this array, one can call:
         TStreamerElement *el = GetStreamerElementReal(0,1);
         const char* membername = el->GetName();
      This function is typically called from Tbuffer, TXmlBuffer

Bool_t GetStreamMemberWise()

     Return whether the TStreamerInfos will save the collections in
     "member-wise" order whenever possible.    The default is to store member-wise.
     kTRUE indicates member-wise storing
     kFALSE inddicates object-wise storing

     A collection can be saved member wise when it contain is guaranteed to be
     homogeneous.  For example std::vector<THit> can be stored member wise,
     while std::vector<THit*> can not (possible use of polymorphism).

Double_t GetValueAux(Int_t type, void *ladd, Int_t k, Int_t len)

Double_t GetValue(char *pointer, Int_t i, Int_t j, Int_t len) const

      return value of element i in object at pointer.
      The function may be called in two ways:
        -method1  len < 0
               i is assumed to be the TStreamerElement number i in StreamerInfo
        -method2  len >= 0
               i is the type
               address of variable is directly pointer.

Double_t GetValueClones(TClonesArray *clones, Int_t i, Int_t j, int k, Int_t eoffset) const

      return value of element i in object number j in a TClonesArray and eventually
     element k in a sub-array.

Double_t GetValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const

      return value of element i in object number j in a TClonesArray and eventually
     element k in a sub-array.

void ls(Option_t *option) const

      List the TStreamerElement list and also the precomputed tables

Int_t New(const char *p)

      emulated constructor for this class.
      An emulated object is created at address p

void Optimize(Bool_t opt)

      This is a static function.
      Set optimization option.
      When this option is activated (default), consecutive data members
      of the same type are merged into an array (faster).
      Optimization must be off in TTree split mode.

void PrintValue(const char *name, char *pointer, Int_t i, Int_t len, Int_t lenmax) const

      print value of element i in object at pointer
      The function may be called in two ways:
        -method1  len < 0
               i is assumed to be the TStreamerElement number i in StreamerInfo
        -method2  len >= 0
               i is the type
               address of variable is directly pointer.
               len is the number of elements to be printed starting at pointer.

void PrintValueClones(const char *name, TClonesArray *clones, Int_t i, Int_t eoffset, Int_t lenmax) const

      print value of element i in a TClonesArray

void PrintValueSTL(const char *name, TVirtualCollectionProxy *cont, Int_t i, Int_t eoffset, Int_t lenmax) const

      print value of element i in a TClonesArray

void SetCanDelete(Bool_t opt)

      This is a static function.
      Set object delete option.
      When this option is activated (default), ReadBuffer automatically
      delete objects when a data member is a pointer to an object.
      If your constructor is not presetting pointers to 0, you must
      call this static function TStreamerInfo::SetCanDelete(kFALSE);

Bool_t SetStreamMemberWise(Bool_t enable)

     Set whether the TStreamerInfos will save the collections in
     "member-wise" order whenever possible.  The default is to store member-wise.
     kTRUE indicates member-wise storing
     kFALSE inddicates object-wise storing
     This function returns the previous value of fgStreamMemberWise.

void Streamer(TBuffer &R__b)

     Stream an object of class TStreamerInfo.

void TagFile(TFile *file)

     Mark the classindex of the current file as using this TStreamerInfo

void PrintValueAux(char *ladd, Int_t atype, TStreamerElement * aElement, Int_t aleng, Int_t *count)

      print value of element  in object at pointer, type atype, leng aleng or *count
      The function may be called in two ways:
        -method1  len < 0
               i is assumed to be the TStreamerElement number i in StreamerInfo
        -method2  len >= 0
               i is the type
               address of variable is directly pointer.
               len is the number of elements to be printed starting at pointer.

void Update(const TClass *oldcl, TClass *newcl)

    function called by the TClass constructor when replacing an emulated class
    by the real class

### Inline Functions

                   TClass* GetClass() const
                    UInt_t GetCheckSum() const
                     Int_t GetClassVersion() const
                TObjArray* GetElements() const
                  ULong_t* GetElems() const
                     Int_t GetNdata() const
                     Int_t GetNumber() const
                    Int_t* GetLengths() const
                  ULong_t* GetMethods() const
                    Int_t* GetNewTypes() const
                    Int_t* GetOffsets() const
                 Version_t GetOldVersion() const
                    Int_t* GetTypes() const
                    Bool_t IsBuilt() const
                    Bool_t IsOptimized() const
                     Int_t IsRecovered() const
                     Int_t ReadBufferClones(TBuffer& b, TClonesArray* clones, Int_t nc, Int_t first, Int_t eoffset)
                     Int_t ReadBufferSTL(TBuffer& b, TVirtualCollectionProxy* cont, Int_t nc, Int_t first, Int_t eoffset)
                      void SetCheckSum(UInt_t checksum)
                      void SetClass(TClass* cl)
                      void SetClassVersion(Int_t vers)
                     Int_t WriteBuffer(TBuffer& b, char* pointer, Int_t first)
                     Int_t WriteBufferClones(TBuffer& b, TClonesArray* clones, Int_t nc, Int_t first, Int_t eoffset)
                     Int_t WriteBufferSTL(TBuffer& b, TVirtualCollectionProxy* cont, Int_t nc, Int_t first, Int_t eoffset)
                   TClass* Class()
                   TClass* IsA() const
                      void ShowMembers(TMemberInspector& insp, char* parent)
                      void StreamerNVirtual(TBuffer& b)
             TStreamerInfo TStreamerInfo(const TStreamerInfo&)
            TStreamerInfo& operator=(const TStreamerInfo&)

Author: Rene Brun 12/10/2000
Last update: root/meta:$Name: $:$Id: TStreamerInfo.cxx,v 1.226 2005/06/23 18:19:26 pcanal Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *