Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
18class TXMLFile;
19
20class TKeyXML final : public TKey {
21
22private:
23 TKeyXML(const TKeyXML &) = delete; // TKeyXML objects are not copiable.
24 TKeyXML &operator=(const TKeyXML &) = delete; // TKeyXML objects are not copiable.
25
26protected:
27 TKeyXML() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
28
29public:
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 ~TKeyXML() override;
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
68protected:
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();
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
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
char name[80]
Definition TGX11.cxx:110
void * XMLNodePointer_t
Definition TXMLEngine.h:17
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
Describe directory structure in memory.
Definition TDirectory.h:45
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
Int_t WriteFile(Int_t=1, TFile *=nullptr) final
Write the encoded object supported by this key.
Definition TKeyXML.h:57
void UpdateObject(TObject *obj)
updates object, stored in the node Used for TDirectory data update
Definition TKeyXML.cxx:218
~TKeyXML() override
TKeyXML destructor.
Definition TKeyXML.cxx:111
void DeleteBuffer() final
Delete key buffer(s).
Definition TKeyXML.h:39
void Delete(Option_t *option="") final
Delete key from current directory Note: TKeyXML object is not deleted.
Definition TKeyXML.cxx:128
Long64_t GetKeyId() const
Definition TKeyXML.h:62
XMLNodePointer_t KeyNode() const
Definition TKeyXML.h:61
XMLNodePointer_t fKeyNode
Definition TKeyXML.h:76
Bool_t IsSubdir() const
Definition TKeyXML.h:63
Int_t Read(TObject *tobj) final
To read an object from the file.
Definition TKeyXML.cxx:245
void Keep() final
Set the "KEEP" status.
Definition TKeyXML.h:45
TXMLEngine * XMLEngine()
return pointer on TXMLEngine object, used for xml conversion
Definition TKeyXML.cxx:389
TObject * ReadObjWithBuffer(char *bufferRead) final
read object derived from TObject class, from key if it is not TObject or in case of error,...
Definition TKeyXML.cxx:286
char * GetBuffer() const final
Definition TKeyXML.h:41
void * XmlReadAny(void *obj, const TClass *expectedClass)
read object from key and cast to expected class
Definition TKeyXML.cxx:334
void * ReadObjectAny(const TClass *expectedClass) final
read object of any type
Definition TKeyXML.cxx:312
TKeyXML(const TKeyXML &)=delete
void FillBuffer(char *&) final
Encode key header into output buffer.
Definition TKeyXML.h:40
void StoreObject(const void *obj, const TClass *cl, Bool_t check_tobj=kFALSE)
convert object to xml structure and keep this structure in key
Definition TKeyXML.cxx:166
void UpdateAttributes()
update key attributes in key node
Definition TKeyXML.cxx:203
TKeyXML()
Definition TKeyXML.h:27
void StoreKeyAttributes()
Stores keys attributes in key node.
Definition TKeyXML.cxx:142
void ReadBuffer(char *&) final
Decode input buffer.
Definition TKeyXML.h:54
Long64_t fKeyId
node with stored object
Definition TKeyXML.h:77
void SetSubir()
Definition TKeyXML.h:64
void SetBuffer() final
Definition TKeyXML.h:56
Bool_t ReadFile() final
Read the key structure from the file.
Definition TKeyXML.h:55
TKeyXML & operator=(const TKeyXML &)=delete
Long64_t GetSeekPdir() const final
Definition TKeyXML.h:43
TObject * ReadObj() final
read object derived from TObject class, from key if it is not TObject or in case of error,...
Definition TKeyXML.cxx:259
Int_t Read(const char *name) final
Read contents of object with specified name from the current directory.
Definition TKeyXML.h:69
Long64_t GetSeekKey() const final
Definition TKeyXML.h:42
Bool_t fSubdir
unique identifier of key for search methods
Definition TKeyXML.h:78
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:41