File indexing completed on 2025-01-18 10:12:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TKey
0013 #define ROOT_TKey
0014
0015 #include "TNamed.h"
0016 #include "TDatime.h"
0017 #include "TClass.h"
0018 #ifdef R__LESS_INCLUDES
0019 class TBuffer;
0020 #else
0021 #include "TBuffer.h"
0022 #endif
0023
0024 class TBrowser;
0025 class TDirectory;
0026 class TFile;
0027
0028 class TKey : public TNamed {
0029
0030 private:
0031 enum EStatusBits {
0032 kIsDirectoryFile = BIT(14),
0033 kReproducible = BIT(15)
0034 };
0035 TKey(const TKey&) = delete;
0036 TKey& operator=(const TKey&) = delete;
0037
0038 protected:
0039 Int_t fVersion;
0040 Int_t fNbytes;
0041 Int_t fObjlen;
0042 TDatime fDatime;
0043 Short_t fKeylen;
0044 Short_t fCycle;
0045 Long64_t fSeekKey;
0046 Long64_t fSeekPdir;
0047 TString fClassName;
0048 Int_t fLeft;
0049 char *fBuffer;
0050 TBuffer *fBufferRef;
0051 UShort_t fPidOffset;
0052 TDirectory *fMotherDir;
0053
0054 Int_t Read(const char *name) override { return TObject::Read(name); }
0055 virtual void Create(Int_t nbytes, TFile* f = nullptr);
0056 void Build(TDirectory* motherDir, const char* classname, Long64_t filepos);
0057 void Reset();
0058 virtual Int_t WriteFileKeepBuffer(TFile *f = nullptr);
0059
0060 public:
0061 TKey();
0062 TKey(TDirectory* motherDir);
0063 TKey(TDirectory* motherDir, const TKey &orig, UShort_t pidOffset);
0064 TKey(const char *name, const char *title, const TClass *cl, Int_t nbytes, TDirectory* motherDir);
0065 TKey(const TString &name, const TString &title, const TClass *cl, Int_t nbytes, TDirectory* motherDir);
0066 TKey(const TObject *obj, const char *name, Int_t bufsize, TDirectory* motherDir);
0067 TKey(const void *obj, const TClass *cl, const char *name, Int_t bufsize, TDirectory* motherDir);
0068 TKey(Long64_t pointer, Int_t nbytes, TDirectory* motherDir = nullptr);
0069 ~TKey() override;
0070
0071 void Browse(TBrowser *b) override;
0072 void Delete(Option_t *option="") override;
0073 virtual void DeleteBuffer();
0074 void FillBuffer(char *&buffer) override;
0075 virtual const char *GetClassName() const {return fClassName.Data();}
0076 const char *GetIconName() const override;
0077 const char *GetTitle() const override;
0078 virtual char *GetBuffer() const {return fBuffer+fKeylen;}
0079 TBuffer *GetBufferRef() const {return fBufferRef;}
0080 Short_t GetCycle() const;
0081 const TDatime &GetDatime() const {return fDatime;}
0082 TFile *GetFile() const;
0083 Short_t GetKeep() const;
0084 Int_t GetKeylen() const {return fKeylen;}
0085 TDirectory* GetMotherDir() const { return fMotherDir; }
0086 Int_t GetNbytes() const {return fNbytes;}
0087 Int_t GetObjlen() const {return fObjlen;}
0088 Int_t GetVersion() const {return fVersion;}
0089 virtual Long64_t GetSeekKey() const {return fSeekKey;}
0090 virtual Long64_t GetSeekPdir() const {return fSeekPdir;}
0091 virtual void IncrementPidOffset(UShort_t offset);
0092 Bool_t IsFolder() const override;
0093 virtual void Keep();
0094 virtual void ls(Bool_t current) const;
0095 void ls(Option_t *option="") const override;
0096 void Print(Option_t *option="") const override;
0097 virtual Int_t Read(TObject *obj);
0098 virtual TObject *ReadObj();
0099 virtual TObject *ReadObjWithBuffer(char *bufferRead);
0100
0101
0102
0103 template <typename T> T *ReadObject() {
0104 return reinterpret_cast<T*>(ReadObjectAny(TClass::GetClass<T>()));
0105 }
0106 virtual void *ReadObjectAny(const TClass *expectedClass);
0107 virtual void ReadBuffer(char *&buffer);
0108 void ReadKeyBuffer(char *&buffer);
0109 virtual Bool_t ReadFile();
0110 virtual void SetBuffer() { DeleteBuffer(); fBuffer = new char[fNbytes];}
0111 virtual void SetParent(const TObject *parent);
0112 void SetMotherDir(TDirectory* dir) { fMotherDir = dir; }
0113 Int_t Sizeof() const override;
0114 virtual Int_t WriteFile(Int_t cycle = 1, TFile* f = nullptr);
0115
0116 ClassDefOverride(TKey,4);
0117 };
0118
0119 #endif