Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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