Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/sql:$Id$
2// Author: Sergey Linev 20/11/2005
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 *************************************************************************/
12#ifndef ROOT_TKeySQL
13#define ROOT_TKeySQL
15#include "TKey.h"
17class TSQLFile;
19class TKeySQL final : public TKey {
22 TKeySQL(const TKeySQL &) = delete;
23 TKeySQL &operator=(const TKeySQL &) = delete;
26 TKeySQL() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
28 using TKey::Read;
30 void StoreKeyObject(const void *obj, const TClass *cl);
31 void *ReadKeyObject(void *obj, const TClass *expectedClass);
33 Long64_t fKeyId{-1}; ///<! key identifier in KeysTables
34 Long64_t fObjId{-1}; ///<! stored object identifier
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;
43 Bool_t IsKeyModified(const char *keyname, const char *keytitle, const char *keydatime, Int_t cycle, const char *classname);
45 Long64_t GetDBKeyId() const { return fKeyId; }
46 Long64_t GetDBObjId() const { return fObjId; }
47 Long64_t GetDBDirId() const;
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 {}
58 Int_t Read(TObject *obj) final;
59 TObject *ReadObj() final;
60 TObject *ReadObjWithBuffer(char *bufferRead) final;
61 void *ReadObjectAny(const TClass *expectedClass) final;
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; }
68 ClassDefOverride(TKeySQL, 1) // a special TKey for SQL data base
int Int_t
Definition: RtypesCore.h:45
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
Option_t Option_t option
char name[80]
Definition: TGX11.cxx:110
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
Describe directory structure in memory.
Definition: TDirectory.h:45
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
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:252
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:272
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
Long64_t fKeyId
! key identifier in KeysTables
Definition: TKeySQL.h:33
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:134
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:92
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:147
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:228
Long64_t GetDBObjId() const
Definition: TKeySQL.h:46
Int_t Read(TObject *obj) final
To read an object from the file.
Definition: TKeySQL.cxx:189
void StoreKeyObject(const void *obj, const TClass *cl)
Stores object, associated with key, into data tables.
Definition: TKeySQL.cxx:155
TKeySQL(const TKeySQL &)=delete
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:28
Int_t Read(const char *name) override
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