Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TKeyXML.h
Go to the documentation of this file.
1 // @(#)root/xml:$Id$
2 // Author: Sergey Linev 10.05.2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, 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_TKeyXML
13 #define ROOT_TKeyXML
14 
15 #include "TXMLEngine.h"
16 #include "TKey.h"
17 
18 class TXMLFile;
19 
20 class TKeyXML final : public TKey {
21 
22 private:
23  TKeyXML(const TKeyXML &) = delete; // TKeyXML objects are not copiable.
24  TKeyXML &operator=(const TKeyXML &) = delete; // TKeyXML objects are not copiable.
25 
26 protected:
27  TKeyXML() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
28 
29 public:
30  TKeyXML(TDirectory *mother, Long64_t keyid, const TObject *obj, const char *name = nullptr,
31  const char *title = nullptr);
32  TKeyXML(TDirectory *mother, Long64_t keyid, const void *obj, const TClass *cl, const char *name,
33  const char *title = nullptr);
34  TKeyXML(TDirectory *mother, Long64_t keyid, XMLNodePointer_t keynode);
35  virtual ~TKeyXML();
36 
37  // redefined TKey Methods
38  void Delete(Option_t *option = "") final;
39  void DeleteBuffer() final {}
40  void FillBuffer(char *&) final {}
41  char *GetBuffer() const final { return nullptr; }
42  Long64_t GetSeekKey() const final { return fKeyNode ? 1024 : 0; }
43  Long64_t GetSeekPdir() const final { return fKeyNode ? 1024 : 0; }
44  // virtual ULong_t Hash() const { return 0; }
45  void Keep() final {}
46  // virtual void ls(Option_t* ="") const;
47  // virtual void Print(Option_t* ="") const {}
48 
49  Int_t Read(TObject *tobj) final;
50  TObject *ReadObj() final;
51  TObject *ReadObjWithBuffer(char *bufferRead) final;
52  void *ReadObjectAny(const TClass *expectedClass) final;
53 
54  void ReadBuffer(char *&) final {}
55  Bool_t ReadFile() final { return kTRUE; }
56  void SetBuffer() final { fBuffer = nullptr; }
57  Int_t WriteFile(Int_t = 1, TFile * = nullptr) final { return 0; }
58 
59  // TKeyXML specific methods
60 
61  XMLNodePointer_t KeyNode() const { return fKeyNode; }
62  Long64_t GetKeyId() const { return fKeyId; }
63  Bool_t IsSubdir() const { return fSubdir; }
64  void SetSubir() { fSubdir = kTRUE; }
65  void UpdateObject(TObject *obj);
66  void UpdateAttributes();
67 
68 protected:
69  Int_t Read(const char *name) final { return TKey::Read(name); }
70  void StoreObject(const void *obj, const TClass *cl, Bool_t check_tobj = kFALSE);
71  void StoreKeyAttributes();
72  TXMLEngine *XMLEngine();
73 
74  void *XmlReadAny(void *obj, const TClass *expectedClass);
75 
76  XMLNodePointer_t fKeyNode{nullptr}; //! node with stored object
77  Long64_t fKeyId{0}; //! unique identifier of key for search methods
78  Bool_t fSubdir{kFALSE}; //! indicates that key contains subdirectory
79 
80  ClassDefOverride(TKeyXML, 1) // a special TKey for XML files
81 };
82 
83 #endif