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)
38 //_____________________________________________________________________________
39 AliCDBHandler::AliCDBHandler()
47 // AliCDBHandler default constructor
51 //_____________________________________________________________________________
52 AliCDBHandler::AliCDBHandler(Int_t run)
60 // AliCDBHandler constructor with requested run
64 //_____________________________________________________________________________
65 AliCDBHandler::AliCDBHandler(const AliCDBHandler &sh)
68 fStartRunRange(sh.fStartRunRange),
69 fEndRunRange(sh.fEndRunRange),
70 fOCDBFolder(sh.fOCDBFolder)
73 // AliCDBHandler copy constructor
77 //_____________________________________________________________________________
78 AliCDBHandler &AliCDBHandler::operator=(const AliCDBHandler &sh)
81 // Assignment operator
83 if (&sh == this) return *this;
85 new (this) AliCDBHandler(sh);
89 //_____________________________________________________________________________
90 AliCDBHandler::~AliCDBHandler()
93 // AliCDBHandler destructor
97 //_____________________________________________________________________________
98 void AliCDBHandler::OnStartDocument()
100 // if something should happen right at the beginning of the
101 // XML document, this must happen here
102 AliInfo("Reading XML file for LHCPeriod <-> Run Range correspondence");
105 //_____________________________________________________________________________
106 void AliCDBHandler::OnEndDocument()
108 // if something should happen at the end of the XML document
109 // this must be done here
112 //_____________________________________________________________________________
113 void AliCDBHandler::OnStartElement(const char *name, const TList *attributes)
115 // when a new XML element is found, it is processed here
117 // set the current system if necessary
118 TString strName(name);
119 AliDebug(2,Form("name = %s",strName.Data()));
123 TIter next(attributes);
124 while ((attr = (TXMLAttr*) next())) {
125 TString attrName = attr->GetName();
126 AliDebug(2,Form("Name = %s",attrName.Data()));
127 if (attrName == "StartRunRange"){
128 startRun = (Int_t)(((TString)(attr->GetValue())).Atoi());
129 AliDebug(2,Form("startRun = %d",startRun));
131 if (attrName == "EndRunRange"){
132 endRun = (Int_t)(((TString)(attr->GetValue())).Atoi());
133 AliDebug(2,Form("endRun = %d",endRun));
135 if (attrName == "OCDBFolder"){
136 if (fRun>=startRun && fRun<=endRun && startRun!=-1 && endRun!=-1){
137 fOCDBFolder = (TString)(attr->GetValue());
138 AliDebug(2,Form("OCDBFolder = %s",fOCDBFolder.Data()));
139 fStartRunRange = startRun;
140 fEndRunRange = endRun;
146 //_____________________________________________________________________________
147 void AliCDBHandler::OnEndElement(const char *name)
149 // do everything that needs to be done when an end tag of an element is found
150 TString strName(name);
151 AliDebug(2,Form("name = %s",strName.Data()));
154 //_____________________________________________________________________________
155 void AliCDBHandler::OnCharacters(const char *characters)
157 // copy the text content of an XML element
158 //fContent = characters;
159 TString strCharacters(characters);
160 AliDebug(2,Form("characters = %s",strCharacters.Data()));
163 //_____________________________________________________________________________
164 void AliCDBHandler::OnComment(const char* /*text*/)
166 // comments within the XML file are ignored
169 //_____________________________________________________________________________
170 void AliCDBHandler::OnWarning(const char *text)
172 // process warnings here
173 AliInfo(Form("Warning: %s",text));
176 //_____________________________________________________________________________
177 void AliCDBHandler::OnError(const char *text)
179 // process errors here
180 AliError(Form("Error: %s",text));
183 //_____________________________________________________________________________
184 void AliCDBHandler::OnFatalError(const char *text)
186 // process fatal errors here
187 AliFatal(Form("Fatal error: %s",text));
190 //_____________________________________________________________________________
191 void AliCDBHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
193 // process character data blocks here
194 // not implemented and should not be used here