5#include "GaudiKernel/CnvFactory.h"
6#include "GaudiKernel/IOpaqueAddress.h"
7#include "GaudiKernel/DataObject.h"
8#include "GaudiKernel/IAddressCreator.h"
9#include "GaudiKernel/IDataProviderSvc.h"
10#include "GaudiKernel/IConversionSvc.h"
11#include "GaudiKernel/MsgStream.h"
13#include "CalibSvc/ICalibXmlSvc.h"
14#include "CalibSvc/ICalibMetaCnvSvc.h"
15#include "CalibData/CalibTime.h"
16#include "CalibData/CalibBase.h"
20#include "CalibData/RangeBase.h"
21#include "xmlBase/Dom.h"
29#include "CalibData/DacCol.h"
31#include "facilities/Util.h"
33#include <xercesc/dom/DOMDocument.hpp>
37XERCES_CPP_NAMESPACE_USE
46 m_xmlSvc (0), m_metaSvc(0), m_vstart(0), m_vend(0)
51 StatusCode status = Converter::initialize();
57 serviceLocator()->getService (
"CalibDataSvc",
63 serviceLocator()->getService (
"CalibXmlCnvSvc",
72 serviceLocator()->getService(
"CalibMySQLCnvSvc",
79 return Converter::finalize();
85 DataObject*& refpObject) {
88 MsgStream log(
msgSvc(),
"XmlBaseCnv" );
91 return StatusCode::FAILURE;
97 const std::string* par = addr->par();
99 std::string par0 = par[0];
114 <<
"Unable to parse document " << par[0] <<
" aka "
116 return StatusCode::FAILURE;
120 <<
"successfully parsed document " << par[0] <<
" aka "
142 DataObject*& refpObject,
145 MsgStream log(
msgSvc(),
"XmlBaseCnv" );
150 CLID classId =
address->clID();
152 IConverter* conv = this->conversionSvc()->converter(classId);
156 <<
"No proper converter found for classID " << classId
157 <<
", the default converter"
158 <<
" will be used. " << endreq;
160 converter =
dynamic_cast <XmlBaseCnv*
> (conv);
161 if (0 == converter) {
163 <<
"The converter found for classID " << classId
164 <<
" was not a descendent of XmlBaseCnv as it should be "
165 <<
"( was of type " <<
typeid (*converter).name() <<
"). "
166 <<
"The default converter will be used" << endreq;
171 unsigned int serNo = *(
address->ipar());
184 StatusCode sc = converter->
i_createObj (docElt, refpObject);
185 if (sc.isFailure()) {
191 if (sc.isSuccess()) {
192 log << MSG::DEBUG <<
"Successfully created calib. object " << endreq;
200 return StatusCode::SUCCESS;
206 return StatusCode::FAILURE;
221 return StatusCode::SUCCESS;
225 return XML_StorageType;
254 std::string att = Dom::getAttribute(dacColElt,
"range");
262 std::vector<int> vals;
264 Dom::getIntsAttribute(dacColElt,
"values", vals);
290 std::string sigName) {
291 if (elt == 0 )
return 0;
298std::vector<CalibData::ValSig>*
300 std::string sigName) {
303 MsgStream log(
msgSvc(),
"XmlBaseCnv" );
305 if (elt == 0 )
return 0;
306 std::vector<float> vals;
307 std::vector<float> sigs;
311 if (vals.size() != sigs.size() ) {
312 log << MSG::ERROR <<
"#values <> #sigmas " << endreq;
315 unsigned n = vals.size();
316 std::vector<CalibData::ValSig>* pValSigs =
317 new std::vector<CalibData::ValSig>(
n);
318 for (
unsigned i = 0; i <
n; i++) {
319 (*pValSigs)[i].m_val = vals[i];
320 (*pValSigs)[i].m_sig = sigs[i];
virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * parse(const char *filename)=0
ICalibMetaCnvSvc * m_metaSvc
CalibData::ValSig * processValSig(DOMElement *elt, std::string valName, std::string sigName)
Read in what will become a CalibData::ValSig.
std::vector< CalibData::ValSig > * processValSigs(DOMElement *elt, std::string valName, std::string sigName)
Read in what will become a vector of CalibData::ValSig.
virtual StatusCode readHeader(const DOMElement *)
virtual StatusCode initialize()
void setBaseInfo(CalibData::CalibBase *pObj)
Another utility for derived classes to use.
static const unsigned char storageType()
CalibData::DacCol * processDacCol(DOMElement *dacColElt, unsigned *range)
virtual StatusCode i_processObj(DataObject *pObject, IOpaqueAddress *address)
In case there is additional work to do on the created object.
DOMElement * findNextDacCol(const DOMElement *rangeElt)
Still another one to navigate XML file and find next dac collection.
DOMElement * findFirstDacCol(const DOMElement *docElt)
Another one to find first dac collection element.
virtual StatusCode internalCreateObj(const DOMElement *element, DataObject *&refpObject, IOpaqueAddress *address)
virtual StatusCode finalize()
virtual StatusCode createObj(IOpaqueAddress *addr, DataObject *&refpObject)
XmlBaseCnv(ISvcLocator *svc, const CLID &clid)
virtual StatusCode i_createObj(const DOMElement *element, DataObject *&refpObject)
static int expandEnvVar(std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
static unsigned trimTrailing(std::string *toTrim)
static DOMElement * getSiblingElement(const DOMNode *child)
Return next element sibling, if any.
static unsigned getFloatsAttribute(const DOMNode *elt, std::string attName, std::vector< float > &values, bool clear=true)
static double getDoubleAttribute(const DOMNode *elt, std::string attName)
static DOMElement * findFirstChildByName(const DOMElement *parent, const char *const name)
static bool checkTagName(const DOMElement *element, const std::string &tagName)