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