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
17class TSQLFile;
18
19class TKeySQL final : public TKey {
20
21private:
22 TKeySQL(const TKeySQL &) = delete; // TKeySQL objects are not copiable.
23 TKeySQL &operator=(const TKeySQL &) = delete; // TKeySQL objects are not copiable.
24
25protected:
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
36public:
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
int Int_t
Definition: RtypesCore.h:43
long long Long64_t
Definition: RtypesCore.h:71
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassDefOverride(name, id)
Definition: Rtypes.h:326
char name[80]
Definition: TGX11.cxx:109
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
Describe directory structure in memory.
Definition: TDirectory.h:40
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:53
TKeySQL represents meta-information about object, which was written to SQL database.
Definition: TKeySQL.h:19
Int_t WriteFile(Int_t=1, TFile *=nullptr) final
Write the encoded object supported by this key.
Definition: TKeySQL.h:66
void * ReadObjectAny(const TClass *expectedClass) final
Read object of any type from SQL database.
Definition: TKeySQL.cxx:253
void FillBuffer(char *&) final
Encode key header into output buffer.
Definition: TKeySQL.h:52
void * ReadKeyObject(void *obj, const TClass *expectedClass)
Read object, associated with key, from database.
Definition: TKeySQL.cxx:273
TObject * ReadObj() final
Read object derived from TObject class If it is not TObject or in case of error, return 0.
Definition: TKeySQL.cxx:204
Long64_t fKeyId
! key identifier in KeysTables
Definition: TKeySQL.h:33
TKeySQL()
Definition: TKeySQL.h:26
void ReadBuffer(char *&) final
Decode input buffer.
Definition: TKeySQL.h:63
void Keep() final
Set the "KEEP" status.
Definition: TKeySQL.h:56
virtual ~TKeySQL()=default
Long64_t fObjId
! stored object identifier
Definition: TKeySQL.h:34
char * GetBuffer() const final
Definition: TKeySQL.h:53
void Delete(Option_t *option="") final
Removes key from current directory Note: TKeySQL object is not deleted.
Definition: TKeySQL.cxx:135
Long64_t GetSeekPdir() const final
Definition: TKeySQL.h:55
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:93
void DeleteBuffer() final
Delete key buffer(s).
Definition: TKeySQL.h:51
Bool_t ReadFile() final
Read the key structure from the file.
Definition: TKeySQL.h:64
Long64_t GetDBKeyId() const
Definition: TKeySQL.h:45
void SetBuffer() final
Definition: TKeySQL.h:65
Long64_t GetDBDirId() const
return sql id of parent directory
Definition: TKeySQL.cxx:148
TKeySQL & operator=(const TKeySQL &)=delete
Long64_t GetSeekKey() const final
Definition: TKeySQL.h:54
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:229
Long64_t GetDBObjId() const
Definition: TKeySQL.h:46
Int_t Read(TObject *obj) final
To read an object from the file.
Definition: TKeySQL.cxx:190
void StoreKeyObject(const void *obj, const TClass *cl)
Stores object, associated with key, into data tables.
Definition: TKeySQL.cxx:156
TKeySQL(const TKeySQL &)=delete
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:28
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKey.h:54
char * fBuffer
Object buffer.
Definition: TKey.h:49
Mother of all ROOT objects.
Definition: TObject.h:37
Access an SQL db via the TFile interface.
Definition: TSQLFile.h:30