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