forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXmlHandler.cxx
More file actions
140 lines (121 loc) · 3.77 KB
/
Copy pathXmlHandler.cxx
File metadata and controls
140 lines (121 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
// The SAX XML file handler used in the CDBManager //
#include "CCDB/XmlHandler.h"
#include <fairlogger/Logger.h> // for LOG
#include <TList.h> // for TList
#include <TXMLAttr.h> // for TXMLAttr
using namespace o2::ccdb;
ClassImp(XmlHandler)
XmlHandler::XmlHandler() : TObject(), mRun(-1), mStartIdRunRange(-1), mEndIdRunRange(-1), mOCDBFolder("")
{
//
// XmlHandler default constructor
//
}
XmlHandler::XmlHandler(Int_t run) : TObject(), mRun(run), mStartIdRunRange(-1), mEndIdRunRange(-1), mOCDBFolder("")
{
//
// XmlHandler constructor with requested run
//
}
XmlHandler::XmlHandler(const XmlHandler &) = default;
XmlHandler &XmlHandler::operator=(const XmlHandler &sh)
{
//
// Assignment operator
//
if (&sh == this) {
return *this;
}
new(this) XmlHandler(sh);
return *this;
}
XmlHandler::~XmlHandler() = default;
void XmlHandler::OnStartDocument()
{
// if something should happen right at the beginning of the
// XML document, this must happen here
LOG(INFO) << "Reading XML file for LHCPeriod <-> Run Range correspondence";
}
void XmlHandler::OnEndDocument()
{
// if something should happen at the end of the XML document
// this must be done here
}
void XmlHandler::OnStartElement(const char *name, const TList *attributes)
{
// when a new XML element is found, it is processed here
// set the current system if necessary
TString strName(name);
LOG(DEBUG) << "name = " << strName.Data();
Int_t startRun = -1;
Int_t endRun = -1;
TXMLAttr *attr;
TIter next(attributes);
while ((attr = (TXMLAttr *) next())) {
TString attrName = attr->GetName();
LOG(DEBUG) << "Name = " << attrName.Data();
if (attrName == "StartIdRunRange") {
startRun = (Int_t) (((TString) (attr->GetValue())).Atoi());
LOG(DEBUG) << "startRun = " << startRun;
}
if (attrName == "EndIdRunRange") {
endRun = (Int_t) (((TString) (attr->GetValue())).Atoi());
LOG(DEBUG) << "endRun = " << endRun;
}
if (attrName == "OCDBFolder") {
if (mRun >= startRun && mRun <= endRun && startRun != -1 && endRun != -1) {
mOCDBFolder = (TString) (attr->GetValue());
LOG(DEBUG) << "OCDBFolder = " << mOCDBFolder.Data();
mStartIdRunRange = startRun;
mEndIdRunRange = endRun;
}
}
}
return;
}
void XmlHandler::OnEndElement(const char *name)
{
// do everything that needs to be done when an end tag of an element is found
TString strName(name);
LOG(DEBUG) << "name = " << strName.Data();
}
void XmlHandler::OnCharacters(const char *characters)
{
// copy the text content of an XML element
// mContent = characters;
TString strCharacters(characters);
LOG(DEBUG) << "characters = " << strCharacters.Data();
}
void XmlHandler::OnComment(const char * /*text*/)
{
// comments within the XML file are ignored
}
void XmlHandler::OnWarning(const char *text)
{
// process warnings here
LOG(INFO) << "Warning: " << text;
}
void XmlHandler::OnError(const char *text)
{
// process errors here
LOG(ERROR) << "Error: " << text;
}
void XmlHandler::OnFatalError(const char *text)
{
// process fatal errors here
LOG(FATAL) << "Fatal error: " << text;
}
void XmlHandler::OnCdataBlock(const char * /*text*/, Int_t /*len*/)
{
// process character data blocks here
// not implemented and should not be used here
}