]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/CDB/AliCDBHandler.cxx
Merge branch 'master' into flatdev
[u/mrichter/AliRoot.git] / STEER / CDB / AliCDBHandler.cxx
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 ClassImp(AliCDBHandler)
37
38 //_____________________________________________________________________________
39 AliCDBHandler::AliCDBHandler()
40   :TObject(),
41   fRun(-1),
42   fStartRunRange(-1),
43   fEndRunRange(-1),
44   fOCDBFolder("")
45 {
46   //
47   // AliCDBHandler default constructor
48   //
49 }
50
51 //_____________________________________________________________________________
52 AliCDBHandler::AliCDBHandler(Int_t run)
53   :TObject(),
54   fRun(run),
55   fStartRunRange(-1),
56   fEndRunRange(-1),
57   fOCDBFolder("")
58 {
59   //
60   // AliCDBHandler constructor with requested run
61   //
62 }
63
64 //_____________________________________________________________________________
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)
71 {
72   //
73   // AliCDBHandler copy constructor
74   //
75 }
76
77 //_____________________________________________________________________________
78 AliCDBHandler &AliCDBHandler::operator=(const AliCDBHandler &sh)
79 {
80   //
81   // Assignment operator
82   //
83   if (&sh == this) return *this;
84
85   new (this) AliCDBHandler(sh);
86   return *this;
87 }
88
89 //_____________________________________________________________________________
90 AliCDBHandler::~AliCDBHandler()
91 {
92   //
93   // AliCDBHandler destructor
94   //    
95 }
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   AliInfo("Reading XML file for LHCPeriod <-> Run Range correspondence");
103 }
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 }
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   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;
145 }
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   TString strName(name);
151   AliDebug(2,Form("name = %s",strName.Data()));
152 }
153
154 //_____________________________________________________________________________
155 void AliCDBHandler::OnCharacters(const char *characters)
156 {
157   // copy the text content of an XML element
158   //fContent = characters;
159   TString strCharacters(characters);
160   AliDebug(2,Form("characters = %s",strCharacters.Data()));
161 }
162
163 //_____________________________________________________________________________
164 void AliCDBHandler::OnComment(const char* /*text*/)
165 {
166   // comments within the XML file are ignored
167 }
168
169 //_____________________________________________________________________________
170 void AliCDBHandler::OnWarning(const char *text)
171 {
172   // process warnings here
173   AliInfo(Form("Warning: %s",text));
174 }
175
176 //_____________________________________________________________________________
177 void AliCDBHandler::OnError(const char *text)
178 {
179   // process errors here
180   AliError(Form("Error: %s",text));
181 }
182
183 //_____________________________________________________________________________
184 void AliCDBHandler::OnFatalError(const char *text)
185 {
186   // process fatal errors here
187   AliFatal(Form("Fatal error: %s",text));
188 }
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 }
196