Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TBufferIO.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/io:$Id$
0002 // Author: Sergey Linev  21/02/2018
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2018, 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_TBufferIO
0013 #define ROOT_TBufferIO
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TBufferIO                                                            //
0018 //                                                                      //
0019 // Direct subclass of TBuffer, implements common methods for            //
0020 // TBufferFile and TBufferText classes                                  //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TBuffer.h"
0025 
0026 #include "TString.h"
0027 
0028 class TExMap;
0029 
0030 class TBufferIO : public TBuffer {
0031 
0032 protected:
0033    enum { kNullTag = 0 }; ///< tag value for nullptr in objects map
0034 
0035    Int_t fMapCount{0};         ///< Number of objects or classes in map
0036    Int_t fMapSize{0};          ///< Default size of map
0037    Int_t fDisplacement{0};     ///< Value to be added to the map offsets
0038    UShort_t fPidOffset{0};     ///< Offset to be added to the pid index in this key/buffer.
0039    TExMap *fMap{nullptr};      ///< Map containing object,offset pairs for reading/writing
0040    TExMap *fClassMap{nullptr}; ///< Map containing object,class pairs for reading
0041 
0042    static Int_t fgMapSize; ///< Default map size for all TBuffer objects
0043 
0044    TBufferIO() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
0045 
0046    TBufferIO(TBuffer::EMode mode);
0047    TBufferIO(TBuffer::EMode mode, Int_t bufsiz);
0048    TBufferIO(TBuffer::EMode mode, Int_t bufsiz, void *buf, Bool_t adopt = kTRUE,
0049              ReAllocCharFun_t reallocfunc = nullptr);
0050 
0051    ////////////////////////////////////////////////////////////////////////////////
0052    /// Return hash value for provided object.
0053    static R__ALWAYS_INLINE ULong_t Void_Hash(const void *ptr) { return TString::Hash(&ptr, sizeof(void *)); }
0054 
0055    // method used in TBufferFile, keep here for full compatibility
0056    virtual void CheckCount(UInt_t) {}
0057 
0058    Long64_t GetObjectTag(const void *obj);
0059 
0060    virtual void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse) = 0;
0061 
0062 public:
0063    enum { kMapSize = 503 }; ///< default objects map size
0064 
0065    enum EStatusBits {
0066       kNotDecompressed = BIT(15),    // indicates a weird buffer, used by TBasket
0067       kTextBasedStreaming = BIT(18), // indicates if buffer used for XML/SQL object streaming
0068 
0069       kUser1 = BIT(21), // free for user
0070       kUser2 = BIT(22), // free for user
0071       kUser3 = BIT(23)  // free for user
0072    };
0073 
0074    ~TBufferIO() override;
0075 
0076    Int_t GetVersionOwner() const override;
0077 
0078    // See comment in TBuffer::SetPidOffset
0079    UShort_t GetPidOffset() const override { return fPidOffset; }
0080    void SetPidOffset(UShort_t offset) override;
0081    Int_t GetBufferDisplacement() const override { return fDisplacement; }
0082    void SetBufferDisplacement() override { fDisplacement = 0; }
0083    void SetBufferDisplacement(Int_t skipped) override { fDisplacement = (Int_t)(Length() - skipped); }
0084 
0085    // Utilities for objects map
0086    void SetReadParam(Int_t mapsize) override;
0087    void SetWriteParam(Int_t mapsize) override;
0088    void InitMap() override;
0089    void ResetMap() override;
0090    void Reset() override;
0091    Int_t GetMapCount() const override { return fMapCount; }
0092    void MapObject(const TObject *obj, UInt_t offset = 1) override;
0093    void MapObject(const void *obj, const TClass *cl, UInt_t offset = 1) override;
0094    Bool_t CheckObject(const TObject *obj) override;
0095    Bool_t CheckObject(const void *obj, const TClass *ptrClass) override;
0096    void GetMappedObject(UInt_t tag, void *&ptr, TClass *&ClassPtr) const override;
0097 
0098    // Utilities for TStreamerInfo
0099    void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) override;
0100    void ForceWriteInfoClones(TClonesArray *a) override;
0101    Int_t ReadClones(TClonesArray *a, Int_t nobjects, Version_t objvers) override;
0102    Int_t WriteClones(TClonesArray *a, Int_t nobjects) override;
0103    void TagStreamerInfo(TVirtualStreamerInfo *info) override;
0104 
0105    // Special basic ROOT objects and collections
0106    TProcessID *GetLastProcessID(TRefTable *reftable) const override;
0107    UInt_t GetTRefExecId() override;
0108    TProcessID *ReadProcessID(UShort_t pidf) override;
0109    UShort_t WriteProcessID(TProcessID *pid) override;
0110 
0111    Int_t WriteObjectAny(const void *obj, const TClass *ptrClass, Bool_t cacheReuse = kTRUE) override;
0112    void WriteObject(const TObject *obj, Bool_t cacheReuse = kTRUE) override;
0113    using TBuffer::WriteObject;
0114 
0115    static void SetGlobalReadParam(Int_t mapsize);
0116    static void SetGlobalWriteParam(Int_t mapsize);
0117    static Int_t GetGlobalReadParam();
0118    static Int_t GetGlobalWriteParam();
0119 
0120    ClassDefOverride(TBufferIO, 0) // base class, share methods for TBufferFile and TBufferText
0121 };
0122 
0123 #endif