Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:34

0001 // @(#)root/meta:$Id$
0002 // Author: Rene Brun   05/02/2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TVirtualStreamerInfo
0013 #define ROOT_TVirtualStreamerInfo
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TVirtualStreamerInfo   Abstract Interface class                      //
0019 //                                                                      //
0020 // Abstract Interface describing Streamer information for one class.    //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TNamed.h"
0025 
0026 #include "ESTLType.h"
0027 
0028 #ifdef _MSC_VER
0029 // On Windows, Disable the warning:
0030 // 'kIgnoreTObjectStreamer': illegal qualified name in member declaration
0031 #pragma warning( push )
0032 #pragma warning( disable : 4596 )
0033 #endif
0034 
0035 class TFile;
0036 class TClass;
0037 class TObjArray;
0038 class TStreamerElement;
0039 class TStreamerBasicType;
0040 class TVirtualCollectionProxy;
0041 class TClassStreamer;
0042 namespace ROOT { namespace Detail { class TCollectionProxyInfo; } }
0043 
0044 class TVirtualStreamerInfo : public TNamed {
0045 
0046 protected:
0047    Bool_t              fOptimized : 1;     //! true if the StreamerInfo has been optimized
0048    Bool_t              fIsBuilt : 1;       //! true if the StreamerInfo has been 'built' (i.e. has all the StreamerElements it should have)
0049    std::atomic<Bool_t> fIsCompiled;        //! true if the StreamerInfo has been compiled (i.e. fully built, ready to use for streaming).
0050 
0051 protected:
0052    static  Bool_t    fgCanDelete;        //True if ReadBuffer can delete object
0053    static  Bool_t    fgOptimize;         //True if optimization on
0054    static  Bool_t    fgStreamMemberWise; //True if the collections are to be stream "member-wise" (when possible).
0055    static TVirtualStreamerInfo  *fgInfoFactory;
0056 
0057    TVirtualStreamerInfo(const TVirtualStreamerInfo& info);
0058    TVirtualStreamerInfo& operator=(const TVirtualStreamerInfo&);
0059 
0060    void  ResetIsCompiled() {
0061       fIsCompiled = kFALSE;
0062       ResetBit(kIsCompiled); /* for backward compatibility */
0063    }
0064    void  SetIsCompiled() {
0065       fIsCompiled = kTRUE;
0066       SetBit(kIsCompiled); /* for backward compatibility */
0067    }
0068 
0069 public:
0070 
0071    //status bits
0072    enum EStatusBits {
0073       kCannotOptimize        = BIT(12),
0074       kIgnoreTObjectStreamer = BIT(13),  // eventhough BIT(13) is taken up by TObject (to preserve forward compatibility)
0075       kRecovered             = BIT(14),
0076       kNeedCheck             = BIT(15),
0077       kIsCompiled            = BIT(16),
0078       kBuildOldUsed          = BIT(17),
0079       kBuildRunning          = BIT(18)
0080    };
0081 
0082    enum class EStatusBitsDupExceptions {
0083       // This bit duplicates TObject::kInvalidObject. As the semantic of kIgnoreTObjectStreamer is a persistent,
0084       // we can not change its value without breaking forward compatibility.
0085       // Furthermore, TObject::kInvalidObject and its semantic is not (and should not be)
0086       // used in TVirtualStreamerInfo
0087       kIgnoreTObjectStreamer  = TVirtualStreamerInfo::kIgnoreTObjectStreamer
0088    };
0089 
0090    enum EReadWrite {
0091       kBase        =  0,  kOffsetL = 20,  kOffsetP = 40,  kCounter =  6,  kCharStar = 7,
0092       kChar        =  1,  kShort   =  2,  kInt     =  3,  kLong    =  4,  kFloat    = 5,
0093       kDouble      =  8,  kDouble32=  9,
0094       kUChar       = 11,  kUShort  = 12,  kUInt    = 13,  kULong   = 14,  kBits     = 15,
0095       kLong64      = 16,  kULong64 = 17,  kBool    = 18,  kFloat16 = 19,
0096       kObject      = 61,  kAny     = 62,  kObjectp = 63,  kObjectP = 64,  kTString  = 65,
0097       kTObject     = 66,  kTNamed  = 67,  kAnyp    = 68,  kAnyP    = 69,  kAnyPnoVT = 70,
0098       kSTLp        = 71,
0099       kSkip        = 100, kSkipL = 120, kSkipP   = 140,
0100       kConv        = 200, kConvL = 220, kConvP   = 240,
0101       kSTL         = ROOT::kSTLany /* 300 */,
0102       kSTLstring   = ROOT::kSTLstring /* 365 */,
0103       kStreamer    = 500, kStreamLoop = 501,
0104       kCache       = 600,  // Cache the value in memory than is not part of the object but is accessible via a SchemaRule
0105       kArtificial  = 1000,
0106       kCacheNew    = 1001,
0107       kCacheDelete = 1002,
0108       kNeedObjectForVirtualBaseClass = 99997,
0109       kMissing     = 99999
0110    };
0111 
0112 // Some comments about EReadWrite
0113 // kBase    : base class element
0114 // kOffsetL : fixed size array
0115 // kOffsetP : pointer to object
0116 // kCounter : counter for array size
0117 // kCharStar: pointer to array of char
0118 // kBits    : TObject::fBits in case of a referenced object
0119 // kObject  : Class  derived from TObject
0120 // kObjectp : Class* derived from TObject and with    comment field //->Class
0121 // kObjectP : Class* derived from TObject and with NO comment field //->Class
0122 // kAny     : Class  not derived from TObject
0123 // kAnyp    : Class* not derived from TObject with    comment field //->Class
0124 // kAnyP    : Class* not derived from TObject with NO comment field //->Class
0125 // kAnyPnoVT: Class* not derived from TObject with NO comment field //->Class and Class has NO virtual table
0126 // kSTLp    : Pointer to STL container.
0127 // kTString : TString, special case
0128 // kTObject : TObject, special case
0129 // kTNamed  : TNamed , special case
0130 
0131 
0132 
0133    TVirtualStreamerInfo();
0134    TVirtualStreamerInfo(TClass * /*cl*/);
0135    virtual            ~TVirtualStreamerInfo();
0136    virtual void        Build(Bool_t isTransient = kFALSE) = 0;
0137    virtual void        BuildCheck(TFile *file = nullptr, Bool_t load = kTRUE) = 0;
0138    virtual void        BuildEmulated(TFile *file) = 0;
0139    virtual void        BuildOld() = 0;
0140    virtual Bool_t      BuildFor( const TClass *cl ) = 0;
0141    virtual void        CallShowMembers(const void* obj, TMemberInspector &insp, Bool_t isTransient) const = 0;
0142    virtual void        Clear(Option_t * = "") override = 0;
0143    virtual Bool_t      CompareContent(TClass *cl,TVirtualStreamerInfo *info, Bool_t warn, Bool_t complete, TFile *file) = 0;
0144    virtual void        Compile() = 0;
0145    virtual void        ForceWriteInfo(TFile *file, Bool_t force=kFALSE) = 0;
0146    virtual Int_t       GenerateHeaderFile(const char *dirname, const TList *subClasses = nullptr, const TList *extrainfos = nullptr) = 0;
0147    virtual TClass     *GetActualClass(const void *obj) const = 0;
0148    virtual TClass     *GetClass() const  = 0;
0149    virtual UInt_t      GetCheckSum() const = 0;
0150    virtual Int_t       GetClassVersion() const = 0;
0151    virtual TStreamerElement *GetElem(Int_t id) const = 0;
0152    virtual TStreamerElement *GetElement(Int_t id) const = 0;
0153    virtual TObjArray  *GetElements() const = 0;
0154    virtual Int_t       GetOffset(const char *) const = 0;
0155    virtual Int_t       GetOffset(Int_t id) const = 0;
0156    virtual Int_t       GetElementOffset(Int_t id) const = 0;
0157    virtual Version_t   GetOldVersion() const = 0;
0158    virtual Int_t       GetOnFileClassVersion() const = 0;
0159    virtual Int_t       GetNumber()  const = 0;
0160    virtual Int_t       GetSize()    const = 0;
0161    virtual TStreamerElement *GetStreamerElement(const char*datamember, Int_t& offset) const = 0;
0162            Bool_t      IsBuilt() const { return fIsBuilt; }
0163            Bool_t      IsCompiled() const { return fIsCompiled; }
0164            Bool_t      IsOptimized() const { return fOptimized; }
0165            Int_t       IsRecovered() const { return TestBit(kRecovered); }
0166    virtual void        ls(Option_t * = "") const override = 0;
0167    virtual TVirtualStreamerInfo *NewInfo(TClass *cl) = 0;
0168    virtual void       *New(void *obj = nullptr) = 0;
0169    virtual void       *NewArray(Long_t nElements, void* ary = nullptr) = 0;
0170    virtual void        Destructor(void* p, Bool_t dtorOnly = kFALSE) = 0;
0171    virtual void        DeleteArray(void* p, Bool_t dtorOnly = kFALSE) = 0;
0172 
0173    virtual void        SetCheckSum(UInt_t checksum) = 0;
0174    virtual void        SetClass(TClass *cl) = 0;
0175    virtual void        SetClassVersion(Int_t vers) = 0;
0176    static  Bool_t      SetStreamMemberWise(Bool_t enable = kTRUE);
0177    virtual void        TagFile(TFile *fFile) = 0;
0178    virtual void        Update(const TClass *oldClass, TClass *newClass) = 0;
0179 
0180    static const char         *GetElementCounterStart(const char *dmTitle);
0181    static TStreamerBasicType *GetElementCounter(const char *countName, TClass *cl);
0182 
0183    static Bool_t       CanOptimize();
0184    static Bool_t       GetStreamMemberWise();
0185    static void         Optimize(Bool_t opt=kTRUE);
0186    static Bool_t       CanDelete();
0187    static void         SetCanDelete(Bool_t opt=kTRUE);
0188    static void         SetFactory(TVirtualStreamerInfo *factory);
0189 
0190    /// \brief Generate the TClass and TStreamerInfo for the requested pair.
0191    /// This creates a TVirtualStreamerInfo for the pair and trigger the BuildCheck/Old to
0192    /// provokes the creation of the corresponding TClass.  This relies on the dictionary for
0193    /// std::pair<const int, int> to already exist (or the interpreter information being available)
0194    /// as it is used as a template.
0195    /// \note The returned object is owned by the caller.
0196    virtual TVirtualStreamerInfo *GenerateInfoForPair(const std::string &pairclassname, bool silent, size_t hint_pair_offset, size_t hint_pair_size) = 0;
0197    virtual TVirtualStreamerInfo *GenerateInfoForPair(const std::string &firstname, const std::string &secondname, bool silent, size_t hint_pair_offset, size_t hint_pair_size) = 0;
0198 
0199    virtual TVirtualCollectionProxy *GenEmulatedProxy(const char* class_name, Bool_t silent) = 0;
0200    virtual TClassStreamer *GenEmulatedClassStreamer(const char* class_name, Bool_t silent) = 0;
0201    virtual TVirtualCollectionProxy *GenExplicitProxy( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0;
0202    virtual TClassStreamer *GenExplicitClassStreamer( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0;
0203    static TVirtualStreamerInfo *Factory();
0204 
0205    //WARNING this class version must be the same as TStreamerInfo
0206    ClassDefOverride(TVirtualStreamerInfo,6)  //Abstract Interface describing Streamer information for one class
0207 };
0208 
0209 #ifdef _MSC_VER
0210 #pragma warning( pop )
0211 #endif
0212 
0213 #endif