#include <XmlBaseCnv.h>
Inheritance diagram for XmlBaseCnv:
Public Types | |
typedef Ty2 | destination |
typedef Ty2 | destination |
typedef Ty1 | source |
typedef Ty1 | source |
Public Member Functions | |
virtual StatusCode | createObj (IOpaqueAddress *addr, DataObject *&refpObject) |
virtual StatusCode | finalize () |
ICalibXmlSvc * | getCalibXmlSvc () |
virtual StatusCode | initialize () |
destination * | operator (const source &) const |
destination * | operator (const source &) const |
XmlBaseCnv (ISvcLocator *svc, const CLID &clid) | |
virtual | ~XmlBaseCnv () |
Static Public Member Functions | |
const unsigned char | storageType () |
Protected Member Functions | |
virtual destination * | convert (const source &) const =0 |
virtual destination * | convert (const source &) const =0 |
DOMElement * | findFirstDacCol (const DOMElement *docElt) |
Another one to find first dac collection element. | |
DOMElement * | findFirstRange (const DOMElement *docElt) |
DOMElement * | findNextDacCol (const DOMElement *rangeElt) |
Still another one to navigate XML file and find next dac collection. | |
DOMElement * | findNextRange (const DOMElement *rangeElt) |
Still another one to navigate XML file and find next set of range data. | |
virtual StatusCode | i_createObj (const DOMElement *element, DataObject *&refpObject) |
virtual StatusCode | i_processObj (DataObject *pObject, IOpaqueAddress *address) |
In case there is additional work to do on the created object. | |
virtual StatusCode | internalCreateObj (const DOMElement *element, DataObject *&refpObject, IOpaqueAddress *address) |
CalibData::DacCol * | processDacCol (DOMElement *dacColElt, unsigned *range) |
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 *) |
void | setBaseInfo (CalibData::CalibBase *pObj) |
Another utility for derived classes to use. | |
Protected Attributes | |
ICalibMetaCnvSvc * | m_metaSvc |
int | m_serNo |
ITime * | m_vend |
ITime * | m_vstart |
ICalibXmlSvc * | m_xmlSvc |
|
|
|
|
|
|
|
|
|
00040 {}
|
|
Constructor for this converter
00044 : 00045 Converter (XML_StorageType, clid, svc), 00046 m_xmlSvc (0), m_metaSvc(0), m_vstart(0), m_vend(0) /*, 00047 m_nRow(10000), m_nCol(10000), m_nLayer(10000), m_nXtal(10000), 00048 m_nFace(10000), m_nRange(10000) */ {}
|
|
|
|
|
|
Create the transient representation of an object, given an opaque address. This and the following update method comprise the core functionality of calibration converters. 00085 { 00086 00087 // creates a msg stream for debug purposes 00088 MsgStream log( msgSvc(), "XmlBaseCnv" ); 00089 00090 if (0 == addr) { 00091 return StatusCode::FAILURE; 00092 } 00093 00094 // first do the things we always need: 00095 // First string parameter of opaque address is file ident 00096 // Parse file into DOM representation 00097 const std::string* par = addr->par(); 00098 00099 std::string par0 = par[0]; 00100 00101 // Ignore trailing white space. 00102 facilities::Util::trimTrailing(&par0); 00103 00104 // Just in case there are environment variables in the file specification 00105 // int nSub = 00106 facilities::Util::expandEnvVar(&par0); 00107 00108 // XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* doc = 00109 DOMDocument* doc = 00110 m_xmlSvc->parse(par0.c_str()); 00111 00112 if (doc == 0 ) { 00113 log << MSG::FATAL 00114 << "Unable to parse document " << par[0] << " aka " 00115 << par0 << endreq; 00116 return StatusCode::FAILURE; 00117 } 00118 else { 00119 log << MSG::INFO 00120 << "successfully parsed document " << par[0] << " aka " 00121 << par0 << endreq; 00122 } 00123 00124 // Could conceivably write some code here to handle generic 00125 // parts of document. Or, alternatively, add services to 00126 // CalibXmlCnvSvc for converters to invoke to do this. 00127 00128 // Then do some fancy footwork in internalCreateObj to get the 00129 // appropriate specific converter invoked to interpret the DOM 00130 // correctly and make a new object of the correct kind. 00131 00132 return internalCreateObj(doc->getDocumentElement(), refpObject, addr); 00133 }
|
|
00078 {
00079 return Converter::finalize();
00080 }
|
|
Another one to find first dac collection element.
00238 { 00239 return xmlBase::Dom::findFirstChildByName(docElt, "dac"); 00240 }
|
|
Find first range element. Derived classes which need it must define their own implementation. 00112 {
00113 return 0;}
|
|
Still another one to navigate XML file and find next dac collection.
00242 { 00243 DOMElement* next = xmlBase::Dom::getSiblingElement(dacElt); 00244 if (xmlBase::Dom::checkTagName(next, "dac")) return next; 00245 else return 0; 00246 }
|
|
Still another one to navigate XML file and find next set of range data.
00117 {
00118 return 0;}
|
|
00054 {
00055 return m_xmlSvc;
00056 }
|
|
This creates the transient representation of an object from the DOM_Element representing it. This actually does the "new" operation and deals with the attributes of the node. This base class implementation does nothing; it should not normally be called because it doesn't correspond to any TCDS class. Instead, i_createObj of some derived class will be called.
Reimplemented in XmlTest1Cnv. 00205 {
00206 return StatusCode::FAILURE;
00207 }
|
|
In case there is additional work to do on the created object.
00199 {
00200 return StatusCode::SUCCESS;
00201 }
|
|
00050 { 00051 StatusCode status = Converter::initialize(); 00052 00053 IDataProviderSvc* dp; 00054 00055 // I guess the service names are assigned in jobOptions? 00056 00057 serviceLocator()->getService ("CalibDataSvc", 00058 IID_IDataProviderSvc, 00059 (IInterface*&)dp); 00060 setDataProvider(dp); 00061 00062 // Locate the Xml Conversion Service 00063 serviceLocator()->getService ("CalibXmlCnvSvc", 00064 IID_ICalibXmlSvc, 00065 (IInterface*&)m_xmlSvc); 00066 00067 // Locate meta conversion service 00068 // Will anything need to be changed here to accommodate possibility 00069 // of two concrete implementations of ICalibMetaCnvSvc? Would 00070 // have different storage types. Could specify type desired 00071 // as job option. Ditto for name of class? 00072 serviceLocator()->getService("CalibMySQLCnvSvc", 00073 IID_ICalibMetaCnvSvc, 00074 (IInterface*&)m_metaSvc); 00075 return status; 00076 }
|
|
This creates the transient representation of an object from the DOMElement representing it, then fills it and process it. This implementation actually only calls the i_* methods of the "right" converter to do the job; so the very first thing it does is get a pointer to the appropriate derived converter. Converters typically don't need to override this method but only to override/implement some of the i_* methods.
00143 { 00144 // creates a msg stream for debug purposes 00145 MsgStream log( msgSvc(), "XmlBaseCnv" ); 00146 00147 // We're the default if we can't find anything better 00148 XmlBaseCnv* converter = this; 00149 00150 CLID classId = address->clID(); 00151 00152 IConverter* conv = this->conversionSvc()->converter(classId); 00153 00154 if (0 == conv) { 00155 log << MSG::WARNING 00156 << "No proper converter found for classID " << classId 00157 << ", the default converter" 00158 << " will be used. " << endreq; 00159 } else { 00160 converter = dynamic_cast <XmlBaseCnv*> (conv); 00161 if (0 == converter) { 00162 log << MSG::ERROR 00163 << "The converter found for classID " << classId 00164 << " was not a descendent of XmlBaseCnv as it should be " 00165 << "( was of type " << typeid (*converter).name() << "). " 00166 << "The default converter will be used" << endreq; 00167 converter = this; 00168 } 00169 } 00170 00171 unsigned int serNo = *(address->ipar()); 00172 m_serNo = serNo; 00173 /* maqm comment for remove getValidInterval() 00174 StatusCode sc = m_metaSvc->getValidInterval(serNo, 00175 &m_vstart, 00176 &m_vend ); 00177 00178 00179 // creates an object for the node found 00180 00181 00182 if (sc.isSuccess()) sc = converter->i_createObj (docElt, refpObject); 00183 */ 00184 StatusCode sc = converter->i_createObj (docElt, refpObject); 00185 if (sc.isFailure()) { 00186 return sc; 00187 } 00188 00189 // ends up the object construction 00190 sc = converter->i_processObj(refpObject, address); 00191 if (sc.isSuccess()) { 00192 log << MSG::DEBUG << "Successfully created calib. object " << endreq; 00193 } 00194 return sc; 00195 }
|
|
|
|
|
|
00249 { 00250 00251 using xmlBase::Dom; 00252 //maqm comment using idents::CalXtalId; 00253 00254 std::string att = Dom::getAttribute(dacColElt, "range"); 00255 /* maqm comment 00256 if (att.compare(std::string("LEX8")) == 0) *range = CalXtalId::LEX8; 00257 if (att.compare(std::string("LEX1")) == 0) *range = CalXtalId::LEX1; 00258 if (att.compare(std::string("HEX8")) == 0) *range = CalXtalId::HEX8; 00259 if (att.compare(std::string("HEX1")) == 0) *range = CalXtalId::HEX1; 00260 */ 00261 // *range = Dom::getIntAttribute(dacColElt, "range"); 00262 std::vector<int> vals; 00263 00264 Dom::getIntsAttribute(dacColElt, "values", vals); 00265 00266 CalibData::DacCol* pDacCol = new CalibData::DacCol(&vals); 00267 return pDacCol; 00268 00269 }
|
|
Read in what will become a CalibData::ValSig.
00290 { 00291 if (elt == 0 ) return 0; 00292 CalibData::ValSig *pValSig = new CalibData::ValSig; 00293 pValSig->m_val = xmlBase::Dom::getDoubleAttribute(elt, valName); 00294 pValSig->m_sig = xmlBase::Dom::getDoubleAttribute(elt, sigName); 00295 return pValSig; 00296 }
|
|
Read in what will become a vector of CalibData::ValSig.
00300 { 00301 00302 // creates a msg stream for debug purposes 00303 MsgStream log( msgSvc(), "XmlBaseCnv" ); 00304 00305 if (elt == 0 ) return 0; 00306 std::vector<float> vals; 00307 std::vector<float> sigs; 00308 00309 xmlBase::Dom::getFloatsAttribute(elt, valName, vals); 00310 xmlBase::Dom::getFloatsAttribute(elt, sigName, sigs); 00311 if (vals.size() != sigs.size() ) { 00312 log << MSG::ERROR << "#values <> #sigmas " << endreq; 00313 return 0; 00314 } 00315 unsigned n = vals.size(); 00316 std::vector<CalibData::ValSig>* pValSigs = 00317 new std::vector<CalibData::ValSig>(n); 00318 for (unsigned i = 0; i < n; i++) { 00319 (*pValSigs)[i].m_val = vals[i]; 00320 (*pValSigs)[i].m_sig = sigs[i]; 00321 } 00322 return pValSigs; 00323 }
|
|
00220 {
00221 return StatusCode::SUCCESS;
00222 }
|
|
Another utility for derived classes to use. Another convenience for derived classes: sets information belonging to the calibration base class, namely validity interval and serial number. 00232 { 00233 pObj->setValidity(*m_vstart, *m_vend); 00234 pObj->setSerNo(m_serNo); 00235 }
|
|
00224 {
00225 return XML_StorageType;
00226 }
|
|
|
|
|
|
|
|
|
|
|