Line data Source code
1 : /*************************************************************************
2 : * * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3 : * * *
4 : * * Author: The ALICE Off-line Project. *
5 : * * Contributors are mentioned in the code where appropriate. *
6 : * * *
7 : * * Permission to use, copy, modify and distribute this software and its *
8 : * * documentation strictly for non-commercial purposes is hereby granted *
9 : * * without fee, provided that the above copyright notice appears in all *
10 : * * copies and that both the copyright notice and this permission notice *
11 : * * appear in the supporting documentation. The authors make no claims *
12 : * * about the suitability of this software for any purpose. It is *
13 : * * provided "as is" without express or implied warranty. *
14 : * **************************************************************************/
15 :
16 : ////////////////////////////////////////////////////////////////////////////
17 : // //
18 : // The SAX XML file handler used in the CDBManager //
19 : // //
20 : // Author: //
21 : // Chiara Zampolli (Chiara.Zampolli@cern.ch) //
22 : // //
23 : ////////////////////////////////////////////////////////////////////////////
24 :
25 : #include <cstdlib>
26 : #include <Riostream.h>
27 :
28 : #include <TList.h>
29 : #include <TObject.h>
30 : #include <TXMLAttr.h>
31 : #include <TSAXParser.h>
32 :
33 : #include "AliLog.h"
34 : #include "AliCDBHandler.h"
35 :
36 128 : ClassImp(AliCDBHandler)
37 :
38 : //_____________________________________________________________________________
39 : AliCDBHandler::AliCDBHandler()
40 0 : :TObject(),
41 0 : fRun(-1),
42 0 : fStartRunRange(-1),
43 0 : fEndRunRange(-1),
44 0 : fOCDBFolder("")
45 0 : {
46 : //
47 : // AliCDBHandler default constructor
48 : //
49 0 : }
50 :
51 : //_____________________________________________________________________________
52 : AliCDBHandler::AliCDBHandler(Int_t run)
53 0 : :TObject(),
54 0 : fRun(run),
55 0 : fStartRunRange(-1),
56 0 : fEndRunRange(-1),
57 0 : fOCDBFolder("")
58 0 : {
59 : //
60 : // AliCDBHandler constructor with requested run
61 : //
62 0 : }
63 :
64 : //_____________________________________________________________________________
65 : AliCDBHandler::AliCDBHandler(const AliCDBHandler &sh)
66 0 : :TObject(sh),
67 0 : fRun(sh.fRun),
68 0 : fStartRunRange(sh.fStartRunRange),
69 0 : fEndRunRange(sh.fEndRunRange),
70 0 : fOCDBFolder(sh.fOCDBFolder)
71 0 : {
72 : //
73 : // AliCDBHandler copy constructor
74 : //
75 0 : }
76 :
77 : //_____________________________________________________________________________
78 : AliCDBHandler &AliCDBHandler::operator=(const AliCDBHandler &sh)
79 : {
80 : //
81 : // Assignment operator
82 : //
83 0 : if (&sh == this) return *this;
84 :
85 0 : new (this) AliCDBHandler(sh);
86 0 : return *this;
87 0 : }
88 :
89 : //_____________________________________________________________________________
90 : AliCDBHandler::~AliCDBHandler()
91 0 : {
92 : //
93 : // AliCDBHandler destructor
94 : //
95 0 : }
96 :
97 : //_____________________________________________________________________________
98 : void AliCDBHandler::OnStartDocument()
99 : {
100 : // if something should happen right at the beginning of the
101 : // XML document, this must happen here
102 0 : AliInfo("Reading XML file for LHCPeriod <-> Run Range correspondence");
103 0 : }
104 :
105 : //_____________________________________________________________________________
106 : void AliCDBHandler::OnEndDocument()
107 : {
108 : // if something should happen at the end of the XML document
109 : // this must be done here
110 0 : }
111 :
112 : //_____________________________________________________________________________
113 : void AliCDBHandler::OnStartElement(const char *name, const TList *attributes)
114 : {
115 : // when a new XML element is found, it is processed here
116 :
117 : // set the current system if necessary
118 0 : TString strName(name);
119 0 : AliDebug(2,Form("name = %s",strName.Data()));
120 : Int_t startRun=-1;
121 : Int_t endRun=-1;
122 : TXMLAttr* attr;
123 0 : TIter next(attributes);
124 0 : while ((attr = (TXMLAttr*) next())) {
125 0 : TString attrName = attr->GetName();
126 0 : AliDebug(2,Form("Name = %s",attrName.Data()));
127 0 : if (attrName == "StartRunRange"){
128 0 : startRun = (Int_t)(((TString)(attr->GetValue())).Atoi());
129 0 : AliDebug(2,Form("startRun = %d",startRun));
130 : }
131 0 : if (attrName == "EndRunRange"){
132 0 : endRun = (Int_t)(((TString)(attr->GetValue())).Atoi());
133 0 : AliDebug(2,Form("endRun = %d",endRun));
134 : }
135 0 : if (attrName == "OCDBFolder"){
136 0 : if (fRun>=startRun && fRun<=endRun && startRun!=-1 && endRun!=-1){
137 0 : fOCDBFolder = (TString)(attr->GetValue());
138 0 : AliDebug(2,Form("OCDBFolder = %s",fOCDBFolder.Data()));
139 0 : fStartRunRange = startRun;
140 0 : fEndRunRange = endRun;
141 0 : }
142 : }
143 0 : }
144 : return;
145 0 : }
146 : //_____________________________________________________________________________
147 : void AliCDBHandler::OnEndElement(const char *name)
148 : {
149 : // do everything that needs to be done when an end tag of an element is found
150 0 : TString strName(name);
151 0 : AliDebug(2,Form("name = %s",strName.Data()));
152 0 : }
153 :
154 : //_____________________________________________________________________________
155 : void AliCDBHandler::OnCharacters(const char *characters)
156 : {
157 : // copy the text content of an XML element
158 : //fContent = characters;
159 0 : TString strCharacters(characters);
160 0 : AliDebug(2,Form("characters = %s",strCharacters.Data()));
161 0 : }
162 :
163 : //_____________________________________________________________________________
164 : void AliCDBHandler::OnComment(const char* /*text*/)
165 : {
166 : // comments within the XML file are ignored
167 0 : }
168 :
169 : //_____________________________________________________________________________
170 : void AliCDBHandler::OnWarning(const char *text)
171 : {
172 : // process warnings here
173 0 : AliInfo(Form("Warning: %s",text));
174 0 : }
175 :
176 : //_____________________________________________________________________________
177 : void AliCDBHandler::OnError(const char *text)
178 : {
179 : // process errors here
180 0 : AliError(Form("Error: %s",text));
181 0 : }
182 :
183 : //_____________________________________________________________________________
184 : void AliCDBHandler::OnFatalError(const char *text)
185 : {
186 : // process fatal errors here
187 0 : AliFatal(Form("Fatal error: %s",text));
188 0 : }
189 :
190 : //_____________________________________________________________________________
191 : void AliCDBHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
192 : {
193 : // process character data blocks here
194 : // not implemented and should not be used here
195 0 : }
196 :
|