]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/CDB/AliCDBHandler.cxx
AliOCDBtoolkit.sh - make a diff between 2 OCDB
[u/mrichter/AliRoot.git] / STEER / CDB / AliCDBHandler.cxx
CommitLineData
a65a7e70 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
36ClassImp(AliCDBHandler)
37
a65a7e70 38//_____________________________________________________________________________
39AliCDBHandler::AliCDBHandler()
5078a13f 40 :TObject(),
41 fRun(-1),
42 fStartRunRange(-1),
43 fEndRunRange(-1),
44 fOCDBFolder("")
a65a7e70 45{
5078a13f 46 //
47 // AliCDBHandler default constructor
48 //
a65a7e70 49}
50
51//_____________________________________________________________________________
52AliCDBHandler::AliCDBHandler(Int_t run)
5078a13f 53 :TObject(),
54 fRun(run),
55 fStartRunRange(-1),
56 fEndRunRange(-1),
57 fOCDBFolder("")
a65a7e70 58{
5078a13f 59 //
60 // AliCDBHandler constructor with requested run
61 //
a65a7e70 62}
63
64//_____________________________________________________________________________
5078a13f 65 AliCDBHandler::AliCDBHandler(const AliCDBHandler &sh)
66:TObject(sh),
67 fRun(sh.fRun),
68 fStartRunRange(sh.fStartRunRange),
69 fEndRunRange(sh.fEndRunRange),
70 fOCDBFolder(sh.fOCDBFolder)
a65a7e70 71{
5078a13f 72 //
73 // AliCDBHandler copy constructor
74 //
a65a7e70 75}
76
77//_____________________________________________________________________________
78AliCDBHandler &AliCDBHandler::operator=(const AliCDBHandler &sh)
79{
5078a13f 80 //
81 // Assignment operator
82 //
83 if (&sh == this) return *this;
84
85 new (this) AliCDBHandler(sh);
86 return *this;
a65a7e70 87}
88
89//_____________________________________________________________________________
90AliCDBHandler::~AliCDBHandler()
91{
5078a13f 92 //
93 // AliCDBHandler destructor
94 //
a65a7e70 95}
96
97//_____________________________________________________________________________
98void AliCDBHandler::OnStartDocument()
99{
5078a13f 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");
a65a7e70 103}
104
105//_____________________________________________________________________________
106void AliCDBHandler::OnEndDocument()
107{
5078a13f 108 // if something should happen at the end of the XML document
109 // this must be done here
a65a7e70 110}
111
112//_____________________________________________________________________________
113void AliCDBHandler::OnStartElement(const char *name, const TList *attributes)
114{
5078a13f 115 // when a new XML element is found, it is processed here
116
117 // set the current system if necessary
118 TString strName(name);
119 AliDebug(2,Form("name = %s",strName.Data()));
120 Int_t startRun=-1;
121 Int_t endRun=-1;
122 TXMLAttr* attr;
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));
130 }
131 if (attrName == "EndRunRange"){
132 endRun = (Int_t)(((TString)(attr->GetValue())).Atoi());
133 AliDebug(2,Form("endRun = %d",endRun));
134 }
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;
141 }
142 }
143 }
144 return;
a65a7e70 145}
146//_____________________________________________________________________________
147void AliCDBHandler::OnEndElement(const char *name)
148{
5078a13f 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()));
a65a7e70 152}
153
154//_____________________________________________________________________________
155void AliCDBHandler::OnCharacters(const char *characters)
156{
5078a13f 157 // copy the text content of an XML element
158 //fContent = characters;
159 TString strCharacters(characters);
160 AliDebug(2,Form("characters = %s",strCharacters.Data()));
a65a7e70 161}
162
163//_____________________________________________________________________________
164void AliCDBHandler::OnComment(const char* /*text*/)
165{
5078a13f 166 // comments within the XML file are ignored
a65a7e70 167}
168
169//_____________________________________________________________________________
170void AliCDBHandler::OnWarning(const char *text)
171{
5078a13f 172 // process warnings here
173 AliInfo(Form("Warning: %s",text));
a65a7e70 174}
175
176//_____________________________________________________________________________
177void AliCDBHandler::OnError(const char *text)
178{
5078a13f 179 // process errors here
180 AliError(Form("Error: %s",text));
a65a7e70 181}
182
183//_____________________________________________________________________________
184void AliCDBHandler::OnFatalError(const char *text)
185{
5078a13f 186 // process fatal errors here
187 AliFatal(Form("Fatal error: %s",text));
a65a7e70 188}
189
190//_____________________________________________________________________________
191void AliCDBHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
192{
5078a13f 193 // process character data blocks here
194 // not implemented and should not be used here
a65a7e70 195}
196