Logo ROOT   6.10/09
Reference Guide
TKeySQL.h
Go to the documentation of this file.
1 // @(#)root/sql:$Id$
2 // Author: Sergey Linev 20/11/2005
3 
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  *************************************************************************/
11 
12 
13 #ifndef ROOT_TKeySQL
14 #define ROOT_TKeySQL
15 
16 #include "TKey.h"
17 
18 class TSQLFile;
19 
20 class TKeySQL : public TKey {
21 
22 private:
23  TKeySQL(const TKeySQL&); // TKeySQL objects are not copiable.
24  TKeySQL& operator=(const TKeySQL&); // TKeySQL objects are not copiable.
25 
26 protected:
27  TKeySQL();
28 
29  virtual Int_t Read(const char *name) { return TKey::Read(name); }
30  void StoreKeyObject(const void* obj, const TClass* cl);
31  void* ReadKeyObject(void* obj, const TClass* expectedClass);
32 
33  Long64_t fKeyId; ///<! key identifier in KeysTables
34  Long64_t fObjId; ///<! stored object identifer
35 
36 public:
37  TKeySQL(TDirectory* mother, const TObject* obj, const char* name, const char* title = 0);
38  TKeySQL(TDirectory* mother, const void* obj, const TClass* cl, const char* name, const char* title = 0);
39  TKeySQL(TDirectory* mother, Long64_t keyid, Long64_t objid,
40  const char* name, const char* title,
41  const char* keydatetime, Int_t cycle, const char* classname);
42  virtual ~TKeySQL();
43 
44  Bool_t IsKeyModified(const char* keyname, const char* keytitle, const char* keydatime, Int_t cycle, const char* classname);
45 
46  Long64_t GetDBKeyId() const { return fKeyId; }
47  Long64_t GetDBObjId() const { return fObjId; }
48  Long64_t GetDBDirId() const;
49 
50  // redefined TKey Methods
51  virtual void Delete(Option_t *option="");
52  virtual void DeleteBuffer() {}
53  virtual void FillBuffer(char *&) {}
54  virtual char *GetBuffer() const { return 0; }
55  virtual Long64_t GetSeekKey() const { return GetDBObjId() > 0 ? GetDBObjId() : 0; }
56  virtual Long64_t GetSeekPdir() const { return GetDBDirId() > 0 ? GetDBDirId() : 0; }
57  virtual void Keep() {}
58 
59  virtual Int_t Read(TObject* obj);
60  virtual TObject *ReadObj();
61  virtual TObject *ReadObjWithBuffer(char *bufferRead);
62  virtual void *ReadObjectAny(const TClass *expectedClass);
63 
64  virtual void ReadBuffer(char *&) {}
65  virtual Bool_t ReadFile() { return kTRUE; }
66  virtual void SetBuffer() { fBuffer = 0; }
67  virtual Int_t WriteFile(Int_t =1, TFile* = 0) { return 0; }
68 
69  ClassDef(TKeySQL,1) // a special TKey for SQL data base
70 };
71 
72 #endif
virtual void DeleteBuffer()
Delete key buffer(s).
Definition: TKeySQL.h:52
Long64_t fKeyId
! key identifier in KeysTables
Definition: TKeySQL.h:33
long long Long64_t
Definition: RtypesCore.h:69
virtual char * GetBuffer() const
Definition: TKeySQL.h:54
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:56
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
Long64_t fObjId
! stored object identifer
Definition: TKeySQL.h:34
Long64_t GetDBKeyId() const
Definition: TKeySQL.h:46
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
char * fBuffer
Object buffer.
Definition: TKey.h:44
TKeySQL()
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:297
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:24
virtual void FillBuffer(char *&)
Encode key header into output buffer.
Definition: TKeySQL.h:53
virtual Int_t WriteFile(Int_t=1, TFile *=0)
Write the encoded object supported by this key.
Definition: TKeySQL.h:67
virtual ~TKeySQL()
TKeySQL destructor.
Definition: TKeySQL.cxx:101
Access an SQL db via the TFile interface.
Definition: TSQLFile.h:30
TKeySQL & operator=(const TKeySQL &)
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
virtual void Keep()
Set the "KEEP" status.
Definition: TKeySQL.h:57
virtual void ReadBuffer(char *&)
Decode input buffer.
Definition: TKeySQL.h:64
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKeySQL.h:29
virtual void SetBuffer()
Definition: TKeySQL.h:66
Describe directory structure in memory.
Definition: TDirectory.h:34
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:65
TKeySQL represents metainforamtion about object, which was written to SQL database.
Definition: TKeySQL.h:20
virtual Long64_t GetSeekKey() const
Definition: TKeySQL.h:55
Long64_t GetDBObjId() const
Definition: TKeySQL.h:47
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKey.h:49
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual void Delete(Option_t *option="")
Removes key from current directory Note: TKeySQL object is not deleted.
Definition: TKeySQL.cxx:142