BmnRoot
26.10.0-19-g6979a6c6
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
MpdXMLNode.h
Go to the documentation of this file.
1
/*
2
* FairXLMNode.h
3
*
4
* Created on: 13 wrz 2017
5
* Author: Daniel Wielanek
6
* E-mail: daniel.wielanek@gmail.com
7
* Warsaw University of Technology, Faculty of Physics
8
*/
9
#ifndef MPDXLMNODE_H
10
#define MPDXLMNODE_H
11
#include <
TList.h
>
12
#include <
TNamed.h
>
13
#include <
TXMLAttr.h
>
14
#include <
TXMLEngine.h
>
15
#include <
TXMLNode.h
>
16
#include <memory>
17
/**
18
* class for representing node attributes
19
*/
20
class
MpdXMLAttrib
:
public
TNamed
21
{
22
public
:
23
/**
24
* default constructor
25
*/
26
MpdXMLAttrib
()
27
:
TNamed
()
28
{}
29
/**
30
* default constructor
31
* @param name name of attribute
32
* @param value value of attribute
33
*/
34
MpdXMLAttrib
(
TString
name,
TString
value)
35
{
36
SetName
(name);
37
SetTitle
(value);
38
}
39
/**
40
*
41
* @return value of node
42
*/
43
TString
GetValue
()
const
{
return
GetTitle
(); };
44
/**
45
*
46
* @param val value of node to se
47
*/
48
void
SetValue
(
TString
val) {
SetTitle
(val); };
49
virtual
~MpdXMLAttrib
() {};
50
ClassDef
(
MpdXMLAttrib
, 1)
51
};
52
/**
53
* class for representing XML node
54
*/
55
class
MpdXMLNode
:
public
TNamed
56
{
57
TList
fChildren
;
58
TList
fAttrib
;
59
60
public
:
61
/**
62
* copy constructor
63
* @param other
64
*/
65
MpdXMLNode
(
const
MpdXMLNode
& other);
66
/**
67
* default constructor
68
* @param name name of node
69
* @param value value of node
70
*/
71
MpdXMLNode
(
TString
name =
""
,
TString
value =
""
);
72
/**
73
* assignement operator
74
* @param other
75
* @return
76
*/
77
MpdXMLNode
&
operator=
(
const
MpdXMLNode
& other);
78
/**
79
* copy data for node to this
80
* @param node
81
*/
82
void
Copy
(
TXMLNode
* node);
83
/**
84
*
85
* @param value new value
86
*/
87
void
SetValue
(
TString
value) {
SetTitle
(value); };
88
/**
89
* add child node to this node, node is now owned by
90
* parent node
91
* @param node node to add
92
*/
93
void
AddChild
(
MpdXMLNode
* node) {
fChildren
.AddLast(node); };
94
/**
95
* add attribute to this class
96
* @param attrib
97
*/
98
void
AddAttrib
(
MpdXMLAttrib
* attrib);
99
/**
100
*
101
* @return number of childen nodes
102
*/
103
Int_t
GetNChildren
()
const
{
return
fChildren
.GetEntries(); };
104
/**
105
*
106
* @return number of attributes
107
*/
108
Int_t
GetNAttributes
()
const
{
return
fAttrib
.GetEntries(); };
109
/**
110
* search for child with given name
111
* @param name name of node
112
* @return number of node with given name
113
*/
114
Int_t
GetNChildren
(
TString
name)
const
;
115
/**
116
*
117
* @return value of node
118
*/
119
TString
GetValue
()
const
{
return
GetTitle
(); };
120
/**
121
*
122
* @param name name of atribute
123
* @return
124
*/
125
MpdXMLAttrib
*
GetAttrib
(
TString
name)
const
;
126
/**
127
*
128
* @param index index of atrribute
129
* @return
130
*/
131
MpdXMLAttrib
*
GetAttrib
(
Int_t
index)
const
;
132
/**
133
* search for node with given name
134
* @param name name of node
135
* @param count number of node (if more than one with given name exist)
136
* @return node
137
*/
138
MpdXMLNode
*
GetChild
(
TString
name,
Int_t
count = 0)
const
;
139
/**
140
*
141
* @param index child number
142
* @return child at given position
143
*/
144
MpdXMLNode
*
GetChild
(
Int_t
index)
const
;
145
virtual
~MpdXMLNode
();
146
ClassDef
(
MpdXMLNode
, 1)
147
};
148
149
/**
150
* class for opening XML files
151
*/
152
class
MpdXMLFile
:
public
TObject
153
{
154
std::unique_ptr<MpdXMLNode>
fRootNode
;
155
TString
fName
;
156
Bool_t
fOverwrite
;
157
void
ExportNode
(
XMLNodePointer_t
& nodePointer,
TXMLEngine
& engine,
const
MpdXMLNode
& node)
const
;
158
159
public
:
160
/**
161
*
162
* @param name name of xml file
163
* @param mode if "READ" or "read" - only read file, otherwise create /overwrite file
164
*/
165
MpdXMLFile
(
TString
name =
""
,
TString
mode =
"read"
);
166
/**
167
* create new root node
168
* @param name name of new node
169
*/
170
void
CreateRootNode
(
TString
name);
171
/**
172
* set new root node, old node will be overwritten
173
* @param node root node
174
*/
175
void
SetRootNode
(
MpdXMLNode
* node);
176
/**
177
*
178
* @return root node
179
*/
180
MpdXMLNode
*
GetRootNode
()
const
{
return
fRootNode
.get(); };
181
/**
182
* close and write xml (if needed)
183
*/
184
void
Close
();
185
/**
186
* destroy object (and save xml file if needed and Close was not called)
187
*/
188
virtual
~MpdXMLFile
();
189
ClassDef
(
MpdXMLFile
, 1)
190
};
191
192
#endif
/* MPDXLMNODE_H */
Bool_t
bool Bool_t
Int_t
int Int_t
ClassDef
#define ClassDef(name, id)
TList.h
TNamed.h
TXMLAttr.h
TXMLEngine.h
XMLNodePointer_t
void * XMLNodePointer_t
TXMLNode.h
MpdXMLAttrib
class for representing node attributes
Definition
MpdXMLNode.h:21
MpdXMLAttrib::MpdXMLAttrib
MpdXMLAttrib()
default constructor
Definition
MpdXMLNode.h:26
MpdXMLAttrib::MpdXMLAttrib
MpdXMLAttrib(TString name, TString value)
default constructor
Definition
MpdXMLNode.h:34
MpdXMLAttrib::~MpdXMLAttrib
virtual ~MpdXMLAttrib()
Definition
MpdXMLNode.h:49
MpdXMLAttrib::GetValue
TString GetValue() const
Definition
MpdXMLNode.h:43
MpdXMLAttrib::SetValue
void SetValue(TString val)
Definition
MpdXMLNode.h:48
MpdXMLFile
class for opening XML files
Definition
MpdXMLNode.h:153
MpdXMLFile::CreateRootNode
void CreateRootNode(TString name)
create new root node
Definition
MpdXMLNode.cxx:154
MpdXMLFile::fOverwrite
Bool_t fOverwrite
Definition
MpdXMLNode.h:156
MpdXMLFile::fName
TString fName
Definition
MpdXMLNode.h:155
MpdXMLFile::fRootNode
std::unique_ptr< MpdXMLNode > fRootNode
Definition
MpdXMLNode.h:154
MpdXMLFile::MpdXMLFile
MpdXMLFile(TString name="", TString mode="read")
Definition
MpdXMLNode.cxx:138
MpdXMLFile::GetRootNode
MpdXMLNode * GetRootNode() const
Definition
MpdXMLNode.h:180
MpdXMLFile::SetRootNode
void SetRootNode(MpdXMLNode *node)
set new root node, old node will be overwritten
Definition
MpdXMLNode.cxx:159
MpdXMLFile::ExportNode
void ExportNode(XMLNodePointer_t &nodePointer, TXMLEngine &engine, const MpdXMLNode &node) const
Definition
MpdXMLNode.cxx:182
MpdXMLFile::~MpdXMLFile
virtual ~MpdXMLFile()
destroy object (and save xml file if needed and Close was not called)
Definition
MpdXMLNode.cxx:195
MpdXMLFile::Close
void Close()
close and write xml (if needed)
Definition
MpdXMLNode.cxx:164
MpdXMLNode
class for representing XML node
Definition
MpdXMLNode.h:56
MpdXMLNode::AddAttrib
void AddAttrib(MpdXMLAttrib *attrib)
add attribute to this class
Definition
MpdXMLNode.cxx:82
MpdXMLNode::GetValue
TString GetValue() const
Definition
MpdXMLNode.h:119
MpdXMLNode::Copy
void Copy(TXMLNode *node)
copy data for node to this
Definition
MpdXMLNode.cxx:52
MpdXMLNode::operator=
MpdXMLNode & operator=(const MpdXMLNode &other)
assignement operator
Definition
MpdXMLNode.cxx:35
MpdXMLNode::GetNAttributes
Int_t GetNAttributes() const
Definition
MpdXMLNode.h:108
MpdXMLNode::GetChild
MpdXMLNode * GetChild(TString name, Int_t count=0) const
search for node with given name
Definition
MpdXMLNode.cxx:104
MpdXMLNode::AddChild
void AddChild(MpdXMLNode *node)
add child node to this node, node is now owned by parent node
Definition
MpdXMLNode.h:93
MpdXMLNode::GetAttrib
MpdXMLAttrib * GetAttrib(TString name) const
Definition
MpdXMLNode.cxx:119
MpdXMLNode::GetNChildren
Int_t GetNChildren() const
Definition
MpdXMLNode.h:103
MpdXMLNode::fChildren
TList fChildren
Definition
MpdXMLNode.h:57
MpdXMLNode::~MpdXMLNode
virtual ~MpdXMLNode()
Definition
MpdXMLNode.cxx:134
MpdXMLNode::MpdXMLNode
MpdXMLNode(const MpdXMLNode &other)
copy constructor
Definition
MpdXMLNode.cxx:24
MpdXMLNode::SetValue
void SetValue(TString value)
Definition
MpdXMLNode.h:87
MpdXMLNode::fAttrib
TList fAttrib
Definition
MpdXMLNode.h:58
TList
TNamed::SetTitle
virtual void SetTitle(const char *title="")
TNamed::GetTitle
const char * GetTitle() const override
TNamed::TNamed
TNamed()
TNamed::SetName
virtual void SetName(const char *name)
TObject::TObject
TObject()
TString
TXMLEngine
TXMLNode
eventdisplay
MpdXMLNode.h
Generated on
for BmnRoot by
1.17.0