TKey.h

Go to the documentation of this file.
00001 // @(#)root/io:$Id: TKey.h 35225 2010-09-10 12:44:37Z pcanal $
00002 // Author: Rene Brun   28/12/94
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TKey
00013 #define ROOT_TKey
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TKey                                                                 //
00019 //                                                                      //
00020 // Header description of a logical record on file.                      //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_TNamed
00025 #include "TNamed.h"
00026 #endif
00027 #ifndef ROOT_TDatime
00028 #include "TDatime.h"
00029 #endif
00030 #ifndef ROOT_TBuffer
00031 #include "TBuffer.h"
00032 #endif
00033 
00034 class TClass;
00035 class TBrowser;
00036 class TDirectory;
00037 class TFile;
00038 
00039 class TKey : public TNamed {
00040 
00041 private:
00042    TKey(const TKey&);            // TKey objects are not copiable.
00043    TKey& operator=(const TKey&); // TKey objects are not copiable.
00044 
00045 protected:
00046    Int_t       fVersion;     //Key version identifier
00047    Int_t       fNbytes;      //Number of bytes for the object on file
00048    Int_t       fObjlen;      //Length of uncompressed object in bytes
00049    TDatime     fDatime;      //Date/Time of insertion in file
00050    Short_t     fKeylen;      //Number of bytes for the key itself
00051    Short_t     fCycle;       //Cycle number
00052    Long64_t    fSeekKey;     //Location of object on file
00053    Long64_t    fSeekPdir;    //Location of parent directory on file
00054    TString     fClassName;   //Object Class name
00055    Int_t       fLeft;        //Number of bytes left in current segment
00056    char       *fBuffer;      //Object buffer
00057    TBuffer    *fBufferRef;   //Pointer to the TBuffer object
00058    UShort_t    fPidOffset;   //! Offset to be added to the pid index in this key/buffer.  This is actually saved in the high bits of fSeekPdir
00059    TDirectory *fMotherDir;   //! pointer to mother directory
00060 
00061    virtual Int_t    Read(const char *name) { return TObject::Read(name); }
00062    virtual void     Create(Int_t nbytes, TFile* f = 0);
00063            void     Build(TDirectory* motherDir, const char* classname, Long64_t filepos);
00064    virtual void     Reset(); // Currently only for the use of TBasket.
00065    virtual Int_t    WriteFileKeepBuffer(TFile *f = 0);
00066 
00067 
00068  public:
00069    TKey();
00070    TKey(TDirectory* motherDir);
00071    TKey(const char *name, const char *title, const TClass *cl, Int_t nbytes, TDirectory* motherDir = 0);
00072    TKey(const TString &name, const TString &title, const TClass *cl, Int_t nbytes, TDirectory* motherDir = 0);
00073    TKey(const TObject *obj, const char *name, Int_t bufsize, TDirectory* motherDir = 0);
00074    TKey(const void *obj, const TClass *cl, const char *name, Int_t bufsize, TDirectory* motherDir = 0);
00075    TKey(Long64_t pointer, Int_t nbytes, TDirectory* motherDir = 0);
00076    virtual ~TKey();
00077 
00078    virtual void        Browse(TBrowser *b);
00079    virtual void        Delete(Option_t *option="");
00080    virtual void        DeleteBuffer();
00081    virtual void        FillBuffer(char *&buffer);
00082    virtual const char *GetClassName() const {return fClassName.Data();}
00083    virtual const char *GetIconName() const;
00084    virtual const char *GetTitle() const;
00085    virtual char       *GetBuffer() const {return fBuffer+fKeylen;}
00086            TBuffer    *GetBufferRef() const {return fBufferRef;}
00087            Short_t     GetCycle() const;
00088    const   TDatime    &GetDatime() const   {return fDatime;}
00089            TFile      *GetFile() const;
00090            Short_t     GetKeep() const;
00091            Int_t       GetKeylen() const   {return fKeylen;}
00092            TDirectory* GetMotherDir() const { return fMotherDir; }
00093            Int_t       GetNbytes() const   {return fNbytes;}
00094            Int_t       GetObjlen() const   {return fObjlen;}
00095            Int_t       GetVersion() const  {return fVersion;}
00096    virtual Long64_t    GetSeekKey() const  {return fSeekKey;}
00097    virtual Long64_t    GetSeekPdir() const {return fSeekPdir;}
00098    virtual ULong_t     Hash() const;
00099    virtual void        IncrementPidOffset(UShort_t offset);
00100            Bool_t      IsFolder() const;
00101    virtual void        Keep();
00102    virtual void        ls(Option_t *option="") const;
00103    virtual void        Print(Option_t *option="") const;
00104    virtual Int_t       Read(TObject *obj);
00105    virtual TObject    *ReadObj();
00106    virtual TObject    *ReadObjWithBuffer(char *bufferRead);
00107    virtual void       *ReadObjectAny(const TClass *expectedClass);
00108    virtual void        ReadBuffer(char *&buffer);
00109            void        ReadKeyBuffer(char *&buffer);
00110    virtual void        ReadFile();
00111    virtual void        SetBuffer() { fBuffer = new char[fNbytes];}
00112    virtual void        SetParent(const TObject *parent);
00113            void        SetMotherDir(TDirectory* dir) { fMotherDir = dir; }
00114    virtual Int_t       Sizeof() const;
00115    virtual Int_t       WriteFile(Int_t cycle=1, TFile* f = 0);
00116 
00117    ClassDef(TKey,4); //Header description of a logical record on file.
00118 };
00119 
00120 #endif

Generated on Tue Jul 5 14:26:58 2011 for ROOT_528-00b_version by  doxygen 1.5.1