Logo ROOT   6.16/01
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#ifndef ROOT_TKeySQL
13#define ROOT_TKeySQL
14
15#include "TKey.h"
16
17class TSQLFile;
18
19class TKeySQL : public TKey {
20
21private:
22 TKeySQL(const TKeySQL &); // TKeySQL objects are not copiable.
23 TKeySQL &operator=(const TKeySQL &); // TKeySQL objects are not copiable.
24
25protected:
26 TKeySQL();
27
28 virtual Int_t Read(const char *name) { return TKey::Read(name); }
29 void StoreKeyObject(const void *obj, const TClass *cl);
30 void *ReadKeyObject(void *obj, const TClass *expectedClass);
31
32 Long64_t fKeyId; ///<! key identifier in KeysTables
33 Long64_t fObjId; ///<! stored object identifer
34
35public:
36 TKeySQL(TDirectory *mother, const TObject *obj, const char *name, const char *title = 0);
37 TKeySQL(TDirectory *mother, const void *obj, const TClass *cl, const char *name, const char *title = 0);
38 TKeySQL(TDirectory *mother, Long64_t keyid, Long64_t objid, const char *name, const char *title,
39 const char *keydatetime, Int_t cycle, const char *classname);
40 virtual ~TKeySQL();
41
42 Bool_t
43 IsKeyModified(const char *keyname, const char *keytitle, const char *keydatime, Int_t cycle, const char *classname);
44
45 Long64_t GetDBKeyId() const { return fKeyId; }
46 Long64_t GetDBObjId() const { return fObjId; }
47 Long64_t GetDBDirId() const;
48
49 // redefined TKey Methods
50 virtual void Delete(Option_t *option = "");
51 virtual void DeleteBuffer() {}
52 virtual void FillBuffer(char *&) {}
53 virtual char *GetBuffer() const { return 0; }
54 virtual Long64_t GetSeekKey() const { return GetDBObjId() > 0 ? GetDBObjId() : 0; }
55 virtual Long64_t GetSeekPdir() const { return GetDBDirId() > 0 ? GetDBDirId() : 0; }
56 virtual void Keep() {}
57
58 virtual Int_t Read(TObject *obj);
59 virtual TObject *ReadObj();
60 virtual TObject *ReadObjWithBuffer(char *bufferRead);
61 virtual void *ReadObjectAny(const TClass *expectedClass);
62
63 virtual void ReadBuffer(char *&) {}
64 virtual Bool_t ReadFile() { return kTRUE; }
65 virtual void SetBuffer() { fBuffer = 0; }
66 virtual Int_t WriteFile(Int_t = 1, TFile * = 0) { return 0; }
67
68 ClassDef(TKeySQL, 1) // a special TKey for SQL data base
69};
70
71#endif
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
Describe directory structure in memory.
Definition: TDirectory.h:34
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
TKeySQL represents meta-inforamtion about object, which was written to SQL database.
Definition: TKeySQL.h:19
virtual void SetBuffer()
Definition: TKeySQL.h:65
virtual char * GetBuffer() const
Definition: TKeySQL.h:53
void * ReadKeyObject(void *obj, const TClass *expectedClass)
Read object, associated with key, from database.
Definition: TKeySQL.cxx:288
Long64_t fKeyId
! key identifier in KeysTables
Definition: TKeySQL.h:32
TKeySQL()
default constructor
Definition: TKeySQL.cxx:39
virtual void DeleteBuffer()
Delete key buffer(s).
Definition: TKeySQL.h:51
virtual void ReadBuffer(char *&)
Decode input buffer.
Definition: TKeySQL.h:63
virtual void FillBuffer(char *&)
Encode key header into output buffer.
Definition: TKeySQL.h:52
virtual ~TKeySQL()
TKeySQL destructor.
Definition: TKeySQL.cxx:99
Long64_t fObjId
! stored object identifer
Definition: TKeySQL.h:33
TKeySQL & operator=(const TKeySQL &)
virtual void Keep()
Set the "KEEP" status.
Definition: TKeySQL.h:56
TKeySQL(const TKeySQL &)
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:108
virtual void Delete(Option_t *option="")
Removes key from current directory Note: TKeySQL object is not deleted.
Definition: TKeySQL.cxx:150
virtual Bool_t ReadFile()
Read the key structure from the file.
Definition: TKeySQL.h:64
Long64_t GetDBKeyId() const
Definition: TKeySQL.h:45
virtual TObject * ReadObj()
Read object derived from TObject class If it is not TObject or in case of error, return 0.
Definition: TKeySQL.cxx:219
virtual Long64_t GetSeekPdir() const
Definition: TKeySQL.h:55
virtual void * ReadObjectAny(const TClass *expectedClass)
Read object of any type from SQL database.
Definition: TKeySQL.cxx:268
Long64_t GetDBDirId() const
return sql id of parent directory
Definition: TKeySQL.cxx:163
virtual Long64_t GetSeekKey() const
Definition: TKeySQL.h:54
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:244
virtual Int_t WriteFile(Int_t=1, TFile *=0)
Write the encoded object supported by this key.
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:28
Long64_t GetDBObjId() const
Definition: TKeySQL.h:46
void StoreKeyObject(const void *obj, const TClass *cl)
Stores object, associated with key, into data tables.
Definition: TKeySQL.cxx:171
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKey.h:49
char * fBuffer
Object buffer.
Definition: TKey.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
Access an SQL db via the TFile interface.
Definition: TSQLFile.h:30