Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:16:29

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    // clang-format off
0091    /// EReadWrite Enumerator
0092    /// | Enum Constant | Description   |
0093    /// |-------------|--------------------|
0094    /// | kBase       | Base class element |
0095    /// | kOffsetL    | Fixed size array |
0096    /// | kOffsetP    | Pointer to object |
0097    /// | kCounter    | Counter for array size |
0098    /// | kCharStar   | Pointer to array of char |
0099    /// | kLegacyChar | Equal to TDataType's kchar |
0100    /// | kBits       | TObject::fBits in case of a referenced object |
0101    /// | kObject     | Class  derived from TObject, or for TStreamerSTL::fCtype non-pointer elements |
0102    /// | kObjectp    | Class* derived from TObject and with    comment field //->Class, or for TStreamerSTL::fCtype: pointer elements |
0103    /// | kObjectP    | Class* derived from TObject and with NO comment field //->Class |
0104    /// | kAny        | Class  not derived from TObject |
0105    /// | kAnyp       | Class* not derived from TObject with    comment field //->Class |
0106    /// | kAnyP       | Class* not derived from TObject with NO comment field //->Class |
0107    /// | kAnyPnoVT   | Class* not derived from TObject with NO comment field //->Class and Class has NO virtual table |
0108    /// | kSTLp       | Pointer to STL container |
0109    /// | kTString    | TString, special case |
0110    /// | kTObject    | TObject, special case |
0111    /// | kTNamed     | TNamed , special case |
0112    /// | kCache      | Cache the value in memory than is not part of the object but is accessible via a SchemaRule |
0113    /// | kNoType     | Indicator that we don't know the current type because the member does not exist in memory |
0114    /// | kUnsupportedConversion | The member type onfile and in memory can not be converted |
0115    /// | kUnset      | default value |
0116    enum EReadWrite {
0117       kBase        =  0,  kOffsetL = 20,  kOffsetP = 40,  kCounter =  6,  kCharStar = 7,
0118       kChar        =  1,  kShort   =  2,  kInt     =  3,  kLong    =  4,  kFloat    = 5,
0119       kDouble      =  8,  kDouble32=  9,
0120       kLegacyChar  = 10, /// Equal to TDataType's kchar
0121       kUChar       = 11,  kUShort  = 12,  kUInt    = 13,  kULong   = 14,  kBits     = 15,
0122       kLong64      = 16,  kULong64 = 17,  kBool    = 18,  kFloat16 = 19,
0123       kObject      = 61,  kAny     = 62,  kObjectp = 63,  kObjectP = 64,  kTString  = 65,
0124       kTObject     = 66,  kTNamed  = 67,  kAnyp    = 68,  kAnyP    = 69,  kAnyPnoVT = 70,
0125       kSTLp        = 71,
0126       kSkip        = 100, kSkipL = 120, kSkipP   = 140,
0127       kConv        = 200, kConvL = 220, kConvP   = 240,
0128       kSTL         = ROOT::kSTLany /* 300 */,
0129       kSTLstring   = ROOT::kSTLstring /* 365 */,
0130       kStreamer    = 500, kStreamLoop = 501,
0131       kCache       = 600,  // Cache the value in memory than is not part of the object but is accessible via a SchemaRule
0132       kArtificial  = 1000,
0133       kCacheNew    = 1001,
0134       kCacheDelete = 1002,
0135       kNeedObjectForVirtualBaseClass = 99997,
0136       kMissing     = 99999,
0137       kNoType      = -1,   /// Type corresponding to a 'missing' data member (with kMissing offset)
0138       kUnsupportedConversion = -2,
0139       kUnset       = -3
0140    };
0141    // clang-format off
0142 
0143    TVirtualStreamerInfo();
0144    TVirtualStreamerInfo(TClass * /*cl*/);
0145    virtual            ~TVirtualStreamerInfo();
0146    virtual void        Build(Bool_t isTransient = kFALSE) = 0;
0147    virtual void        BuildCheck(TFile *file = nullptr, Bool_t load = kTRUE) = 0;
0148    virtual void        BuildEmulated(TFile *file) = 0;
0149    virtual void        BuildOld() = 0;
0150    virtual Bool_t      BuildFor( const TClass *cl ) = 0;
0151    virtual void        CallShowMembers(const void* obj, TMemberInspector &insp, Bool_t isTransient) const = 0;
0152    virtual void        Clear(Option_t * = "") override = 0;
0153    virtual Bool_t      CompareContent(TClass *cl,TVirtualStreamerInfo *info, Bool_t warn, Bool_t complete, TFile *file) = 0;
0154    virtual void        Compile() = 0;
0155    virtual void        ForceWriteInfo(TFile *file, Bool_t force=kFALSE) = 0;
0156    virtual Int_t       GenerateHeaderFile(const char *dirname, const TList *subClasses = nullptr, const TList *extrainfos = nullptr) = 0;
0157    virtual TClass     *GetActualClass(const void *obj) const = 0;
0158    virtual TClass     *GetClass() const  = 0;
0159    virtual UInt_t      GetCheckSum() const = 0;
0160    virtual Int_t       GetClassVersion() const = 0;
0161    virtual TStreamerElement *GetElem(Int_t id) const = 0;
0162    virtual TStreamerElement *GetElement(Int_t id) const = 0;
0163    virtual TObjArray  *GetElements() const = 0;
0164    virtual Int_t       GetOffset(const char *) const = 0;
0165    virtual Int_t       GetOffset(Int_t id) const = 0;
0166    virtual Int_t       GetElementOffset(Int_t id) const = 0;
0167    virtual Version_t   GetOldVersion() const = 0;
0168    virtual Int_t       GetOnFileClassVersion() const = 0;
0169    virtual Int_t       GetNumber()  const = 0;
0170    virtual Int_t       GetSize()    const = 0;
0171    virtual TStreamerElement *GetStreamerElement(const char*datamember, Int_t& offset) const = 0;
0172            Bool_t      IsBuilt() const { return fIsBuilt; }
0173            Bool_t      IsCompiled() const { return fIsCompiled; }
0174            Bool_t      IsOptimized() const { return fOptimized; }
0175            Int_t       IsRecovered() const { return TestBit(kRecovered); }
0176    virtual void        ls(Option_t * = "") const override = 0;
0177    virtual TVirtualStreamerInfo *NewInfo(TClass *cl) = 0;
0178    virtual void       *New(void *obj = nullptr) = 0;
0179    virtual void       *NewArray(Long_t nElements, void* ary = nullptr) = 0;
0180    virtual void        Destructor(void* p, Bool_t dtorOnly = kFALSE) = 0;
0181    virtual void        DeleteArray(void* p, Bool_t dtorOnly = kFALSE) = 0;
0182 
0183    virtual void        SetCheckSum(UInt_t checksum) = 0;
0184    virtual void        SetClass(TClass *cl) = 0;
0185    virtual void        SetClassVersion(Int_t vers) = 0;
0186    static  Bool_t      SetStreamMemberWise(Bool_t enable = kTRUE);
0187    virtual void        TagFile(TFile *fFile) = 0;
0188    virtual void        Update(const TClass *oldClass, TClass *newClass) = 0;
0189 
0190    static const char         *GetElementCounterStart(const char *dmTitle);
0191    static TStreamerBasicType *GetElementCounter(const char *countName, TClass *cl);
0192 
0193    static Bool_t       CanOptimize();
0194    static Bool_t       GetStreamMemberWise();
0195    static void         Optimize(Bool_t opt=kTRUE);
0196    static Bool_t       CanDelete();
0197    static void         SetCanDelete(Bool_t opt=kTRUE);
0198    static void         SetFactory(TVirtualStreamerInfo *factory);
0199 
0200    /// \brief Generate the TClass and TStreamerInfo for the requested pair.
0201    /// This creates a TVirtualStreamerInfo for the pair and trigger the BuildCheck/Old to
0202    /// provokes the creation of the corresponding TClass.  This relies on the dictionary for
0203    /// std::pair<const int, int> to already exist (or the interpreter information being available)
0204    /// as it is used as a template.
0205    /// \note The returned object is owned by the caller.
0206    virtual TVirtualStreamerInfo *GenerateInfoForPair(const std::string &pairclassname, bool silent, size_t hint_pair_offset, size_t hint_pair_size) = 0;
0207    virtual TVirtualStreamerInfo *GenerateInfoForPair(const std::string &firstname, const std::string &secondname, bool silent, size_t hint_pair_offset, size_t hint_pair_size) = 0;
0208 
0209    virtual TVirtualCollectionProxy *GenEmulatedProxy(const char* class_name, Bool_t silent) = 0;
0210    virtual TClassStreamer *GenEmulatedClassStreamer(const char* class_name, Bool_t silent) = 0;
0211    virtual TVirtualCollectionProxy *GenExplicitProxy( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0;
0212    virtual TClassStreamer *GenExplicitClassStreamer( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0;
0213    static TVirtualStreamerInfo *Factory();
0214 
0215    //WARNING this class version must be the same as TStreamerInfo
0216    ClassDefOverride(TVirtualStreamerInfo,6)  //Abstract Interface describing Streamer information for one class
0217 };
0218 
0219 #ifdef _MSC_VER
0220 #pragma warning( pop )
0221 #endif
0222 
0223 #endif