Logo ROOT  
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 
17 class TSQLFile;
18 
19 class TKeySQL final : public TKey {
20 
21 private:
22  TKeySQL(const TKeySQL &) = delete; // TKeySQL objects are not copiable.
23  TKeySQL &operator=(const TKeySQL &) = delete; // TKeySQL objects are not copiable.
24 
25 protected:
26  TKeySQL() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
27 
28  using TKey::Read;
29 
30  void StoreKeyObject(const void *obj, const TClass *cl);
31  void *ReadKeyObject(void *obj, const TClass *expectedClass);
32 
33  Long64_t fKeyId{-1}; ///<! key identifier in KeysTables
34  Long64_t fObjId{-1}; ///<! stored object identifier
35 
36 public:
37  TKeySQL(TDirectory *mother, const TObject *obj, const char *name, const char *title = nullptr);
38  TKeySQL(TDirectory *mother, const void *obj, const TClass *cl, const char *name, const char *title = nullptr);
39  TKeySQL(TDirectory *mother, Long64_t keyid, Long64_t objid, const char *name, const char *title,
40  const char *keydatetime, Int_t cycle, const char *classname);
41  virtual ~TKeySQL() = default;
42 
43  Bool_t 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  void Delete(Option_t *option = "") final;
51  void DeleteBuffer() final {}
52  void FillBuffer(char *&) final {}
53  char *GetBuffer() const final { return nullptr; }
54  Long64_t GetSeekKey() const final { return GetDBObjId() > 0 ? GetDBObjId() : 0; }
55  Long64_t GetSeekPdir() const final { return GetDBDirId() > 0 ? GetDBDirId() : 0; }
56  void Keep() final {}
57 
58  Int_t Read(TObject *obj) final;
59  TObject *ReadObj() final;
60  TObject *ReadObjWithBuffer(char *bufferRead) final;
61  void *ReadObjectAny(const TClass *expectedClass) final;
62 
63  void ReadBuffer(char *&) final {}
64  Bool_t ReadFile() final { return kTRUE; }
65  void SetBuffer() final { fBuffer = nullptr; }
66  Int_t WriteFile(Int_t = 1, TFile * = nullptr) final { return 0; }
67 
68  ClassDefOverride(TKeySQL, 1) // a special TKey for SQL data base
69 };
70 
71 #endif
TKeySQL
Definition: TKeySQL.h:19
TKeySQL::Delete
void Delete(Option_t *option="") final
Removes key from current directory Note: TKeySQL object is not deleted.
Definition: TKeySQL.cxx:134
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TKeySQL::fKeyId
Long64_t fKeyId
! key identifier in KeysTables
Definition: TKeySQL.h:33
TKeySQL::ReadBuffer
void ReadBuffer(char *&) final
Decode input buffer.
Definition: TKeySQL.h:63
TKeySQL::fObjId
Long64_t fObjId
! stored object identifier
Definition: TKeySQL.h:34
TKeySQL::Read
Int_t Read(TObject *obj) final
To read an object from the file.
Definition: TKeySQL.cxx:189
TKeySQL::GetDBKeyId
Long64_t GetDBKeyId() const
Definition: TKeySQL.h:45
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TKeySQL::operator=
TKeySQL & operator=(const TKeySQL &)=delete
Int_t
int Int_t
Definition: RtypesCore.h:45
TKeySQL::TKeySQL
TKeySQL()
Definition: TKeySQL.h:26
TKey::fBuffer
char * fBuffer
Object buffer.
Definition: TKey.h:49
TKeySQL::GetDBDirId
Long64_t GetDBDirId() const
return sql id of parent directory
Definition: TKeySQL.cxx:147
ClassDefOverride
#define ClassDefOverride(name, id)
Definition: Rtypes.h:329
TKeySQL::~TKeySQL
virtual ~TKeySQL()=default
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TKeySQL::ReadObj
TObject * ReadObj() final
Read object derived from TObject class If it is not TObject or in case of error, return 0.
Definition: TKeySQL.cxx:203
TKeySQL::WriteFile
Int_t WriteFile(Int_t=1, TFile *=nullptr) final
Write the encoded object supported by this key.
Definition: TKeySQL.h:66
bool
TKeySQL::GetDBObjId
Long64_t GetDBObjId() const
Definition: TKeySQL.h:46
TKeySQL::StoreKeyObject
void StoreKeyObject(const void *obj, const TClass *cl)
Stores object, associated with key, into data tables.
Definition: TKeySQL.cxx:155
TKeySQL::GetBuffer
char * GetBuffer() const final
Definition: TKeySQL.h:53
TKeySQL::FillBuffer
void FillBuffer(char *&) final
Encode key header into output buffer.
Definition: TKeySQL.h:52
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TKeySQL::IsKeyModified
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:92
TKeySQL::GetSeekKey
Long64_t GetSeekKey() const final
Definition: TKeySQL.h:54
TKeySQL::ReadObjectAny
void * ReadObjectAny(const TClass *expectedClass) final
Read object of any type from SQL database.
Definition: TKeySQL.cxx:252
TKeySQL::ReadObjWithBuffer
TObject * ReadObjWithBuffer(char *bufferRead) final
Read object derived from TObject class If it is not TObject or in case of error, return 0.
Definition: TKeySQL.cxx:228
TKeySQL::GetSeekPdir
Long64_t GetSeekPdir() const final
Definition: TKeySQL.h:55
TFile
Definition: TFile.h:54
TKey
Definition: TKey.h:28
TKeySQL::ReadFile
Bool_t ReadFile() final
Read the key structure from the file.
Definition: TKeySQL.h:64
TKeySQL::SetBuffer
void SetBuffer() final
Definition: TKeySQL.h:65
TClass
Definition: TClass.h:80
TKeySQL::ReadKeyObject
void * ReadKeyObject(void *obj, const TClass *expectedClass)
Read object, associated with key, from database.
Definition: TKeySQL.cxx:272
TObject
Definition: TObject.h:37
TKeySQL::Keep
void Keep() final
Set the "KEEP" status.
Definition: TKeySQL.h:56
name
char name[80]
Definition: TGX11.cxx:110
TDirectory
Definition: TDirectory.h:40
TKey::Read
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKey.h:54
TKey.h
TKeySQL::DeleteBuffer
void DeleteBuffer() final
Delete key buffer(s).
Definition: TKeySQL.h:51
TSQLFile
Definition: TSQLFile.h:30
int