1 /*************************************************************************
\r
2 * * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
\r
4 * * Author: The ALICE Off-line Project. *
\r
5 * * Contributors are mentioned in the code where appropriate. *
\r
7 * * Permission to use, copy, modify and distribute this software and its *
\r
8 * * documentation strictly for non-commercial purposes is hereby granted *
\r
9 * * without fee, provided that the above copyright notice appears in all *
\r
10 * * copies and that both the copyright notice and this permission notice *
\r
11 * * appear in the supporting documentation. The authors make no claims *
\r
12 * * about the suitability of this software for any purpose. It is *
\r
13 * * provided "as is" without express or implied warranty. *
\r
14 * **************************************************************************/
\r
16 ////////////////////////////////////////////////////////////////////////////
\r
18 // The SAX XML file handler used in the CDBManager //
\r
21 // Chiara Zampolli (Chiara.Zampolli@cern.ch) //
\r
23 ////////////////////////////////////////////////////////////////////////////
\r
26 #include <Riostream.h>
\r
29 #include <TObject.h>
\r
30 #include <TXMLAttr.h>
\r
31 #include <TSAXParser.h>
\r
34 #include "AliCDBHandler.h"
\r
36 ClassImp(AliCDBHandler)
\r
39 //_____________________________________________________________________________
\r
40 AliCDBHandler::AliCDBHandler()
\r
48 // AliCDBHandler default constructor
\r
52 //_____________________________________________________________________________
\r
53 AliCDBHandler::AliCDBHandler(Int_t run)
\r
61 // AliCDBHandler constructor with requested run
\r
65 //_____________________________________________________________________________
\r
66 AliCDBHandler::AliCDBHandler(const AliCDBHandler &sh)
\r
69 fStartRunRange(sh.fStartRunRange),
\r
70 fEndRunRange(sh.fEndRunRange),
\r
71 fOCDBFolder(sh.fOCDBFolder)
\r
74 // AliCDBHandler copy constructor
\r
78 //_____________________________________________________________________________
\r
79 AliCDBHandler &AliCDBHandler::operator=(const AliCDBHandler &sh)
\r
82 // Assignment operator
\r
84 if (&sh == this) return *this;
\r
86 new (this) AliCDBHandler(sh);
\r
90 //_____________________________________________________________________________
\r
91 AliCDBHandler::~AliCDBHandler()
\r
94 // AliCDBHandler destructor
\r
98 //_____________________________________________________________________________
\r
99 void AliCDBHandler::OnStartDocument()
\r
101 // if something should happen right at the beginning of the
\r
102 // XML document, this must happen here
\r
103 AliInfo("Reading XML file for LHCPerdiod <-> Run Range correspondance");
\r
106 //_____________________________________________________________________________
\r
107 void AliCDBHandler::OnEndDocument()
\r
109 // if something should happen at the end of the XML document
\r
110 // this must be done here
\r
113 //_____________________________________________________________________________
\r
114 void AliCDBHandler::OnStartElement(const char *name, const TList *attributes)
\r
116 // when a new XML element is found, it is processed here
\r
118 // set the current system if necessary
\r
119 TString strName(name);
\r
120 AliDebug(2,Form("name = %s",strName.Data()));
\r
124 TIter next(attributes);
\r
125 while ((attr = (TXMLAttr*) next())) {
\r
126 TString attrName = attr->GetName();
\r
127 AliDebug(2,Form("Name = %s",attrName.Data()));
\r
128 if (attrName == "StartRunRange"){
\r
129 startRun = (Int_t)(((TString)(attr->GetValue())).Atoi());
\r
130 AliDebug(2,Form("startRun = %d",startRun));
\r
132 if (attrName == "EndRunRange"){
\r
133 endRun = (Int_t)(((TString)(attr->GetValue())).Atoi());
\r
134 AliDebug(2,Form("endRun = %d",endRun));
\r
136 if (attrName == "OCDBFolder"){
\r
137 if (fRun>=startRun && fRun<=endRun && startRun!=-1 && endRun!=-1){
\r
138 fOCDBFolder = (TString)(attr->GetValue());
\r
139 AliDebug(2,Form("OCDBFolder = %s",fOCDBFolder.Data()));
\r
140 fStartRunRange = startRun;
\r
141 fEndRunRange = endRun;
\r
147 //_____________________________________________________________________________
\r
148 void AliCDBHandler::OnEndElement(const char *name)
\r
150 // do everything that needs to be done when an end tag of an element is found
\r
151 TString strName(name);
\r
152 AliDebug(2,Form("name = %s",strName.Data()));
\r
155 //_____________________________________________________________________________
\r
156 void AliCDBHandler::OnCharacters(const char *characters)
\r
158 // copy the text content of an XML element
\r
159 //fContent = characters;
\r
160 TString strCharacters(characters);
\r
161 AliDebug(2,Form("characters = %s",strCharacters.Data()));
\r
164 //_____________________________________________________________________________
\r
165 void AliCDBHandler::OnComment(const char* /*text*/)
\r
167 // comments within the XML file are ignored
\r
170 //_____________________________________________________________________________
\r
171 void AliCDBHandler::OnWarning(const char *text)
\r
173 // process warnings here
\r
174 AliInfo(Form("Warning: %s",text));
\r
177 //_____________________________________________________________________________
\r
178 void AliCDBHandler::OnError(const char *text)
\r
180 // process errors here
\r
181 AliError(Form("Error: %s",text));
\r
184 //_____________________________________________________________________________
\r
185 void AliCDBHandler::OnFatalError(const char *text)
\r
187 // process fatal errors here
\r
188 AliFatal(Form("Fatal error: %s",text));
\r
191 //_____________________________________________________________________________
\r
192 void AliCDBHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
\r
194 // process character data blocks here
\r
195 // not implemented and should not be used here
\r