Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TDirectoryFile.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: Rene Brun   22/01/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_TDirectoryFile
0013 #define ROOT_TDirectoryFile
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TDirectoryFile                                                       //
0019 //                                                                      //
0020 // Describe directory structure in a ROOT file.                         //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "Compression.h"
0025 #include "TDirectory.h"
0026 #include "TDatime.h"
0027 #include "TList.h"
0028 
0029 class TKey;
0030 class TFile;
0031 
0032 class TDirectoryFile : public TDirectory {
0033 
0034 protected:
0035    Bool_t      fModified{kFALSE};        ///< True if directory has been modified
0036    Bool_t      fWritable{kFALSE};        ///< True if directory is writable
0037    TDatime     fDatimeC;                 ///< Date and time when directory is created
0038    TDatime     fDatimeM;                 ///< Date and time of last modification
0039    Int_t       fNbytesKeys{0};           ///< Number of bytes for the keys
0040    Int_t       fNbytesName{0};           ///< Number of bytes in TNamed at creation time
0041    Int_t       fBufferSize{0};           ///< Default buffer size to create new TKeys
0042    Long64_t    fSeekDir{0};              ///< Location of directory on file
0043    Long64_t    fSeekParent{0};           ///< Location of parent directory on file
0044    Long64_t    fSeekKeys{0};             ///< Location of Keys record on file
0045    TFile      *fFile{nullptr};           ///< Pointer to current file in memory
0046    TList      *fKeys{nullptr};           ///< Pointer to keys list in memory
0047 
0048    void        CleanTargets();
0049    void        InitDirectoryFile(TClass *cl = nullptr);
0050    void        BuildDirectoryFile(TFile* motherFile, TDirectory* motherDir);
0051 
0052 private:
0053    TDirectoryFile(const TDirectoryFile &directory) = delete;  //Directories cannot be copied
0054    void operator=(const TDirectoryFile &) = delete; //Directories cannot be copied
0055 
0056 public:
0057    // TDirectory status bits
0058    enum EStatusBits { kCloseDirectory = BIT(7) }; // Unused in ROOT, never set. Maybe only in external code.
0059 
0060    TDirectoryFile();
0061    TDirectoryFile(const char *name, const char *title, Option_t *option="", TDirectory* motherDir = nullptr);
0062    ~TDirectoryFile() override;
0063 
0064           void        Append(TObject *obj, Bool_t replace = kFALSE) override;
0065           void        Add(TObject *obj, Bool_t replace = kFALSE) override { Append(obj,replace); }
0066           Int_t       AppendKey(TKey *key) override;
0067           void        Browse(TBrowser *b) override;
0068           void        Build(TFile* motherFile = nullptr, TDirectory* motherDir = nullptr) override { BuildDirectoryFile(motherFile, motherDir); }
0069           TObject    *CloneObject(const TObject *obj, Bool_t autoadd = kTRUE) override;
0070           void        Close(Option_t *option="") override;
0071           void        Copy(TObject &) const override { MayNotUse("Copy(TObject &)"); }
0072           Bool_t      cd() override;
0073           Bool_t      cd(const char *path) override;
0074           void        Delete(const char *namecycle="") override;
0075           void        FillBuffer(char *&buffer) override;
0076           TKey       *FindKey(const char *keyname) const override;
0077           TKey       *FindKeyAny(const char *keyname) const override;
0078           TObject    *FindObjectAny(const char *name) const override;
0079           TObject    *FindObjectAnyFile(const char *name) const override;
0080           TObject    *Get(const char *namecycle) override;
0081    /// See documentation of TDirectoryFile::Get(const char *namecycle)
0082    template <class T> inline T* Get(const char* namecycle)
0083    {
0084       return TDirectory::Get<T>(namecycle);
0085    }
0086            TDirectory *GetDirectory(const char *apath, Bool_t printError = false, const char *funcname = "GetDirectory") override;
0087            void       *GetObjectChecked(const char *namecycle, const char* classname) override;
0088            void       *GetObjectChecked(const char *namecycle, const TClass* cl) override;
0089            void       *GetObjectUnchecked(const char *namecycle) override;
0090            Int_t       GetBufferSize() const override;
0091    const TDatime      &GetCreationDate() const { return fDatimeC; }
0092            TFile      *GetFile() const override { return fFile; }
0093            TKey       *GetKey(const char *name, Short_t cycle=9999) const override;
0094            TList      *GetListOfKeys() const override { return fKeys; }
0095    const TDatime      &GetModificationDate() const { return fDatimeM; }
0096            Int_t       GetNbytesKeys() const override { return fNbytesKeys; }
0097            Int_t       GetNkeys() const override { return fKeys->GetSize(); }
0098            Long64_t    GetSeekDir() const override { return fSeekDir; }
0099            Long64_t    GetSeekParent() const override { return fSeekParent; }
0100            Long64_t    GetSeekKeys() const override { return fSeekKeys; }
0101            Bool_t      IsModified() const override { return fModified; }
0102            Bool_t      IsWritable() const override { return fWritable; }
0103            void        ls(Option_t *option="") const override;
0104            TDirectory *mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory = kFALSE) override;
0105            TFile      *OpenFile(const char *name, Option_t *option= "",
0106                             const char *ftitle = "", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
0107                             Int_t netopt = 0) override;
0108            void        Purge(Short_t nkeep=1) override;
0109            void        ReadAll(Option_t *option="") override;
0110            Int_t       ReadKeys(Bool_t forceRead=kTRUE) override;
0111            Int_t       ReadTObject(TObject *obj, const char *keyname) override;
0112    virtual void        ResetAfterMerge(TFileMergeInfo *);
0113            void        rmdir(const char *name) override;
0114            void        Save() override;
0115            void        SaveSelf(Bool_t force = kFALSE) override;
0116            Int_t       SaveObjectAs(const TObject *obj, const char *filename="", Option_t *option="") const override;
0117            void        SetBufferSize(Int_t bufsize) override;
0118            void        SetModified() override {fModified = kTRUE;}
0119            void        SetSeekDir(Long64_t v) override { fSeekDir = v; }
0120            void        SetTRefAction(TObject *ref, TObject *parent) override;
0121            void        SetWritable(Bool_t writable=kTRUE) override;
0122            Int_t       Sizeof() const override;
0123            Int_t       Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override;
0124            Int_t       Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) const override;
0125            Int_t       WriteTObject(const TObject *obj, const char *name=nullptr, Option_t *option="", Int_t bufsize=0) override;
0126            Int_t       WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option="", Int_t bufsize=0) override;
0127            Int_t       WriteObjectAny(const void *obj, const TClass *cl, const char *name, Option_t *option="", Int_t bufsize=0) override;
0128            void        WriteDirHeader() override;
0129            void        WriteKeys() override;
0130 
0131    ClassDefOverride(TDirectoryFile,5)  //Describe directory structure in a ROOT file
0132 };
0133 
0134 #endif