Logo ROOT   6.08/07
Reference Guide
Go to the documentation of this file.
1 // @(#)root/sql:$Id$
2 // Author: Sergey Linev 20/11/2005
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
13 #ifndef ROOT_TKeySQL
14 #define ROOT_TKeySQL
16 #ifndef ROOT_TKey
17 #include "TKey.h"
18 #endif
20 class TSQLFile;
22 class TKeySQL : public TKey {
24 private:
25  TKeySQL(const TKeySQL&); // TKeySQL objects are not copiable.
26  TKeySQL& operator=(const TKeySQL&); // TKeySQL objects are not copiable.
28 protected:
29  TKeySQL();
31  virtual Int_t Read(const char *name) { return TKey::Read(name); }
32  void StoreKeyObject(const void* obj, const TClass* cl);
33  void* ReadKeyObject(void* obj, const TClass* expectedClass);
35  Long64_t fKeyId; ///<! key identifier in KeysTables
36  Long64_t fObjId; ///<! stored object identifer
38 public:
39  TKeySQL(TDirectory* mother, const TObject* obj, const char* name, const char* title = 0);
40  TKeySQL(TDirectory* mother, const void* obj, const TClass* cl, const char* name, const char* title = 0);
41  TKeySQL(TDirectory* mother, Long64_t keyid, Long64_t objid,
42  const char* name, const char* title,
43  const char* keydatetime, Int_t cycle, const char* classname);
44  virtual ~TKeySQL();
46  Bool_t IsKeyModified(const char* keyname, const char* keytitle, const char* keydatime, Int_t cycle, const char* classname);
48  Long64_t GetDBKeyId() const { return fKeyId; }
49  Long64_t GetDBObjId() const { return fObjId; }
50  Long64_t GetDBDirId() const;
52  // redefined TKey Methods
53  virtual void Delete(Option_t *option="");
54  virtual void DeleteBuffer() {}
55  virtual void FillBuffer(char *&) {}
56  virtual char *GetBuffer() const { return 0; }
57  virtual Long64_t GetSeekKey() const { return GetDBObjId() > 0 ? GetDBObjId() : 0; }
58  virtual Long64_t GetSeekPdir() const { return GetDBDirId() > 0 ? GetDBDirId() : 0; }
59  virtual void Keep() {}
61  virtual Int_t Read(TObject* obj);
62  virtual TObject *ReadObj();
63  virtual TObject *ReadObjWithBuffer(char *bufferRead);
64  virtual void *ReadObjectAny(const TClass *expectedClass);
66  virtual void ReadBuffer(char *&) {}
67  virtual Bool_t ReadFile() { return kTRUE; }
68  virtual void SetBuffer() { fBuffer = 0; }
69  virtual Int_t WriteFile(Int_t =1, TFile* = 0) { return 0; }
71  ClassDef(TKeySQL,1) // a special TKey for SQL data base
72 };
74 #endif
virtual void DeleteBuffer()
Delete key buffer(s).
Definition: TKeySQL.h:54
Long64_t fKeyId
! key identifier in KeysTables
Definition: TKeySQL.h:35
long long Long64_t
Definition: RtypesCore.h:69
virtual char * GetBuffer() const
Definition: TKeySQL.h:56
void * ReadKeyObject(void *obj, const TClass *expectedClass)
Read object, associated with key, from database.
Definition: TKeySQL.cxx:266
Long64_t GetDBDirId() const
return sql id of parent directory
Definition: TKeySQL.cxx:155
const char Option_t
Definition: RtypesCore.h:62
virtual Long64_t GetSeekPdir() const
Definition: TKeySQL.h:58
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
Long64_t fObjId
! stored object identifer
Definition: TKeySQL.h:36
Long64_t GetDBKeyId() const
Definition: TKeySQL.h:48
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
char * fBuffer
Object buffer.
Definition: TKey.h:50
default constructor
Definition: TKeySQL.cxx:40
Bool_t IsKeyModified(const char *keyname, const char *keytitle, const char *keydatime, Int_t cycle, const char *classname)
Compares keydata with provided and return kTRUE if key was modified Used in TFile::StreamKeysForDirec...
Definition: TKeySQL.cxx:110
#define ClassDef(name, id)
Definition: Rtypes.h:254
void StoreKeyObject(const void *obj, const TClass *cl)
Stores object, associated with key, into data tables.
Definition: TKeySQL.cxx:163
virtual TObject * ReadObjWithBuffer(char *bufferRead)
Read object derived from TObject class If it is not TObject or in case of error, return 0...
Definition: TKeySQL.cxx:235
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:30
virtual void FillBuffer(char *&)
Encode key header into output buffer.
Definition: TKeySQL.h:55
virtual Int_t WriteFile(Int_t=1, TFile *=0)
Write the encoded object supported by this key.
Definition: TKeySQL.h:69
virtual ~TKeySQL()
TKeySQL destructor.
Definition: TKeySQL.cxx:101
Access an SQL db via the TFile interface.
Definition: TSQLFile.h:32
TKeySQL & operator=(const TKeySQL &)
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
virtual void Keep()
Set the "KEEP" status.
Definition: TKeySQL.h:59
virtual void ReadBuffer(char *&)
Decode input buffer.
Definition: TKeySQL.h:66
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKeySQL.h:31
virtual void SetBuffer()
Definition: TKeySQL.h:68
Describe directory structure in memory.
Definition: TDirectory.h:44
virtual void * ReadObjectAny(const TClass *expectedClass)
Read object of any type from SQL database.
Definition: TKeySQL.cxx:258
virtual TObject * ReadObj()
Read object derived from TObject class If it is not TObject or in case of error, return 0...
Definition: TKeySQL.cxx:211
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Bool_t ReadFile()
Read the key structure from the file.
Definition: TKeySQL.h:67
TKeySQL represents metainforamtion about object, which was written to SQL database.
Definition: TKeySQL.h:22
virtual Long64_t GetSeekKey() const
Definition: TKeySQL.h:57
Long64_t GetDBObjId() const
Definition: TKeySQL.h:49
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKey.h:55
const Bool_t kTRUE
Definition: Rtypes.h:91
char name[80]
Definition: TGX11.cxx:109
virtual void Delete(Option_t *option="")
Removes key from current directory Note: TKeySQL object is not deleted.
Definition: TKeySQL.cxx:142