7#include "GaudiKernel/CnvFactory.h"
8#include "GaudiKernel/DataObject.h"
9#include "GaudiKernel/IAddressCreator.h"
10#include "GaudiKernel/IConversionSvc.h"
11#include "GaudiKernel/IDataProviderSvc.h"
12#include "GaudiKernel/IOpaqueAddress.h"
13#include "GaudiKernel/MsgStream.h"
15#include "CalibData/CalibBase.h"
16#include "CalibData/CalibTime.h"
17#include "CalibSvc/ICalibMetaCnvSvc.h"
18#include "CalibSvc/ICalibXmlSvc.h"
22#include "CalibData/RangeBase.h"
23#include "xmlBase/Dom.h"
31#include "CalibData/DacCol.h"
33#include "facilities/Util.h"
35#include <xercesc/dom/DOMDocument.hpp>
39XERCES_CPP_NAMESPACE_USE
56 StatusCode status = Converter::initialize();
62 serviceLocator()->getService(
"CalibDataSvc", IID_IDataProviderSvc, (IInterface*&)dp );
63 setDataProvider( dp );
66 serviceLocator()->getService(
"CalibXmlCnvSvc", IID_ICalibXmlSvc, (IInterface*&)
m_xmlSvc );
73 serviceLocator()->getService(
"CalibMySQLCnvSvc", IID_ICalibMetaCnvSvc,
85 MsgStream log(
msgSvc(),
"XmlBaseCnv" );
87 if ( 0 == addr ) {
return StatusCode::FAILURE; }
92 const std::string* par = addr->par();
94 std::string par0 = par[0];
104 DOMDocument* doc =
m_xmlSvc->parse( par0.c_str() );
108 log << MSG::FATAL <<
"Unable to parse document " << par[0] <<
" aka " << par0 << endmsg;
109 return StatusCode::FAILURE;
113 log << MSG::INFO <<
"successfully parsed document " << par[0] <<
" aka " << par0 << endmsg;
135 MsgStream log(
msgSvc(),
"XmlBaseCnv" );
140 CLID classId =
address->clID();
142 IConverter* conv = this->conversionSvc()->converter( classId );
146 log << MSG::WARNING <<
"No proper converter found for classID " << classId
147 <<
", the default converter"
148 <<
" will be used. " << endmsg;
152 converter =
dynamic_cast<XmlBaseCnv*
>( conv );
153 if ( 0 == converter )
155 log << MSG::ERROR <<
"The converter found for classID " << classId
156 <<
" was not a descendent of XmlBaseCnv as it should be "
157 <<
"( was of type " <<
typeid( *converter ).name() <<
"). "
158 <<
"The default converter will be used" << endmsg;
163 unsigned int serNo = *(
address->ipar() );
176 StatusCode sc = converter->
i_createObj( docElt, refpObject );
177 if ( sc.isFailure() ) {
return sc; }
181 if ( sc.isSuccess() )
182 { log << MSG::DEBUG <<
"Successfully created calib. object " << endmsg; }
189 return StatusCode::SUCCESS;
194 return StatusCode::FAILURE;
236 std::string att = Dom::getAttribute( dacColElt,
"range" );
244 std::vector<int> vals;
246 Dom::getIntsAttribute( dacColElt,
"values", vals );
270 std::string sigName ) {
271 if ( elt == 0 )
return 0;
278std::vector<CalibData::ValSig>*
282 MsgStream log(
msgSvc(),
"XmlBaseCnv" );
284 if ( elt == 0 )
return 0;
285 std::vector<float> vals;
286 std::vector<float> sigs;
290 if ( vals.size() != sigs.size() )
292 log << MSG::ERROR <<
"#values <> #sigmas " << endmsg;
295 unsigned n = vals.size();
296 std::vector<CalibData::ValSig>* pValSigs =
new std::vector<CalibData::ValSig>(
n );
297 for (
unsigned i = 0; i <
n; i++ )
299 ( *pValSigs )[i].m_val = vals[i];
300 ( *pValSigs )[i].m_sig = sigs[i];
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)