ROOT logo
// @(#)root/io:$Id$
// Author: Rene Brun   28/12/94

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TKey
#define ROOT_TKey


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TKey                                                                 //
//                                                                      //
// Header description of a logical record on file.                      //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
#ifndef ROOT_TDatime
#include "TDatime.h"
#endif
#ifndef ROOT_TBuffer
#include "TBuffer.h"
#endif

class TClass;
class TBrowser;
class TDirectory;
class TFile;

class TKey : public TNamed {

private:
   enum EStatusBits {
      kIsDirectoryFile = BIT(14)
   };
   TKey(const TKey&);            // TKey objects are not copiable.
   TKey& operator=(const TKey&); // TKey objects are not copiable.

protected:
   Int_t       fVersion;     //Key version identifier
   Int_t       fNbytes;      //Number of bytes for the object on file
   Int_t       fObjlen;      //Length of uncompressed object in bytes
   TDatime     fDatime;      //Date/Time of insertion in file
   Short_t     fKeylen;      //Number of bytes for the key itself
   Short_t     fCycle;       //Cycle number
   Long64_t    fSeekKey;     //Location of object on file
   Long64_t    fSeekPdir;    //Location of parent directory on file
   TString     fClassName;   //Object Class name
   Int_t       fLeft;        //Number of bytes left in current segment
   char       *fBuffer;      //Object buffer
   TBuffer    *fBufferRef;   //Pointer to the TBuffer object
   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
   TDirectory *fMotherDir;   //! pointer to mother directory

   virtual Int_t    Read(const char *name) { return TObject::Read(name); }
   virtual void     Create(Int_t nbytes, TFile* f = 0);
           void     Build(TDirectory* motherDir, const char* classname, Long64_t filepos);
   virtual void     Reset(); // Currently only for the use of TBasket.
   virtual Int_t    WriteFileKeepBuffer(TFile *f = 0);


 public:
   TKey();
   TKey(TDirectory* motherDir);
   TKey(TDirectory* motherDir, const TKey &orig, UShort_t pidOffset);
   TKey(const char *name, const char *title, const TClass *cl, Int_t nbytes, TDirectory* motherDir = 0);
   TKey(const TString &name, const TString &title, const TClass *cl, Int_t nbytes, TDirectory* motherDir = 0);
   TKey(const TObject *obj, const char *name, Int_t bufsize, TDirectory* motherDir = 0);
   TKey(const void *obj, const TClass *cl, const char *name, Int_t bufsize, TDirectory* motherDir = 0);
   TKey(Long64_t pointer, Int_t nbytes, TDirectory* motherDir = 0);
   virtual ~TKey();

   virtual void        Browse(TBrowser *b);
   virtual void        Delete(Option_t *option="");
   virtual void        DeleteBuffer();
   virtual void        FillBuffer(char *&buffer);
   virtual const char *GetClassName() const {return fClassName.Data();}
   virtual const char *GetIconName() const;
   virtual const char *GetTitle() const;
   virtual char       *GetBuffer() const {return fBuffer+fKeylen;}
           TBuffer    *GetBufferRef() const {return fBufferRef;}
           Short_t     GetCycle() const;
   const   TDatime    &GetDatime() const   {return fDatime;}
           TFile      *GetFile() const;
           Short_t     GetKeep() const;
           Int_t       GetKeylen() const   {return fKeylen;}
           TDirectory* GetMotherDir() const { return fMotherDir; }
           Int_t       GetNbytes() const   {return fNbytes;}
           Int_t       GetObjlen() const   {return fObjlen;}
           Int_t       GetVersion() const  {return fVersion;}
   virtual Long64_t    GetSeekKey() const  {return fSeekKey;}
   virtual Long64_t    GetSeekPdir() const {return fSeekPdir;}
   virtual ULong_t     Hash() const;
   virtual void        IncrementPidOffset(UShort_t offset);
           Bool_t      IsFolder() const;
   virtual void        Keep();
   virtual void        ls(Option_t *option="") const;
   virtual void        Print(Option_t *option="") const;
   virtual Int_t       Read(TObject *obj);
   virtual TObject    *ReadObj();
   virtual TObject    *ReadObjWithBuffer(char *bufferRead);
   virtual void       *ReadObjectAny(const TClass *expectedClass);
   virtual void        ReadBuffer(char *&buffer);
           void        ReadKeyBuffer(char *&buffer);
   virtual Bool_t      ReadFile();
   virtual void        SetBuffer() { fBuffer = new char[fNbytes];}
   virtual void        SetParent(const TObject *parent);
           void        SetMotherDir(TDirectory* dir) { fMotherDir = dir; }
   virtual Int_t       Sizeof() const;
   virtual Int_t       WriteFile(Int_t cycle=1, TFile* f = 0);

   ClassDef(TKey,4); //Header description of a logical record on file.
};

#endif
 TKey.h:1
 TKey.h:2
 TKey.h:3
 TKey.h:4
 TKey.h:5
 TKey.h:6
 TKey.h:7
 TKey.h:8
 TKey.h:9
 TKey.h:10
 TKey.h:11
 TKey.h:12
 TKey.h:13
 TKey.h:14
 TKey.h:15
 TKey.h:16
 TKey.h:17
 TKey.h:18
 TKey.h:19
 TKey.h:20
 TKey.h:21
 TKey.h:22
 TKey.h:23
 TKey.h:24
 TKey.h:25
 TKey.h:26
 TKey.h:27
 TKey.h:28
 TKey.h:29
 TKey.h:30
 TKey.h:31
 TKey.h:32
 TKey.h:33
 TKey.h:34
 TKey.h:35
 TKey.h:36
 TKey.h:37
 TKey.h:38
 TKey.h:39
 TKey.h:40
 TKey.h:41
 TKey.h:42
 TKey.h:43
 TKey.h:44
 TKey.h:45
 TKey.h:46
 TKey.h:47
 TKey.h:48
 TKey.h:49
 TKey.h:50
 TKey.h:51
 TKey.h:52
 TKey.h:53
 TKey.h:54
 TKey.h:55
 TKey.h:56
 TKey.h:57
 TKey.h:58
 TKey.h:59
 TKey.h:60
 TKey.h:61
 TKey.h:62
 TKey.h:63
 TKey.h:64
 TKey.h:65
 TKey.h:66
 TKey.h:67
 TKey.h:68
 TKey.h:69
 TKey.h:70
 TKey.h:71
 TKey.h:72
 TKey.h:73
 TKey.h:74
 TKey.h:75
 TKey.h:76
 TKey.h:77
 TKey.h:78
 TKey.h:79
 TKey.h:80
 TKey.h:81
 TKey.h:82
 TKey.h:83
 TKey.h:84
 TKey.h:85
 TKey.h:86
 TKey.h:87
 TKey.h:88
 TKey.h:89
 TKey.h:90
 TKey.h:91
 TKey.h:92
 TKey.h:93
 TKey.h:94
 TKey.h:95
 TKey.h:96
 TKey.h:97
 TKey.h:98
 TKey.h:99
 TKey.h:100
 TKey.h:101
 TKey.h:102
 TKey.h:103
 TKey.h:104
 TKey.h:105
 TKey.h:106
 TKey.h:107
 TKey.h:108
 TKey.h:109
 TKey.h:110
 TKey.h:111
 TKey.h:112
 TKey.h:113
 TKey.h:114
 TKey.h:115
 TKey.h:116
 TKey.h:117
 TKey.h:118
 TKey.h:119
 TKey.h:120
 TKey.h:121
 TKey.h:122
 TKey.h:123
 TKey.h:124