XmlTest1Cnv Class Reference

#include <XmlTest1Cnv.h>

Inheritance diagram for XmlTest1Cnv:

XmlBaseCnv Converter< Ty1, Ty2 > List of all members.

Public Types

typedef Ty1 source
typedef Ty2 destination

Public Member Functions

const CLID & objType () const
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&refpObject)
ICalibXmlSvcgetCalibXmlSvc ()
destinationoperator (const source &) const

Static Public Member Functions

static const CLID & classID ()
static const unsigned char storageType ()

Protected Member Functions

 XmlTest1Cnv (ISvcLocator *svcs)
virtual ~XmlTest1Cnv ()
virtual StatusCode i_createObj (const DOMElement *element, DataObject *&refpObject)
virtual StatusCode internalCreateObj (const DOMElement *element, DataObject *&refpObject, IOpaqueAddress *address)
virtual StatusCode i_processObj (DataObject *pObject, IOpaqueAddress *address)
 In case there is additional work to do on the created object.
virtual StatusCode readHeader (const DOMElement *)
DOMElement * findFirstRange (const DOMElement *docElt)
DOMElement * findNextRange (const DOMElement *rangeElt)
 Still another one to navigate XML file and find next set of range data.
DOMElement * findFirstDacCol (const DOMElement *docElt)
 Another one to find first dac collection element.
DOMElement * findNextDacCol (const DOMElement *rangeElt)
 Still another one to navigate XML file and find next dac collection.
CalibData::DacColprocessDacCol (DOMElement *dacColElt, unsigned *range)
CalibData::ValSigprocessValSig (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.
void setBaseInfo (CalibData::CalibBase *pObj)
 Another utility for derived classes to use.
virtual destinationconvert (const source &) const =0

Protected Attributes

ICalibXmlSvcm_xmlSvc
ICalibMetaCnvSvcm_metaSvc
int m_serNo
ITime * m_vstart
ITime * m_vend

Friends

class CnvFactory< XmlTest1Cnv >
 Friend needed for instantiation.

Detailed Description

Definition at line 16 of file XmlTest1Cnv.h.


Member Typedef Documentation

template<class Ty1, class Ty2>
typedef Ty2 Converter< Ty1, Ty2 >::destination [inherited]

Definition at line 19 of file Converter.h.

template<class Ty1, class Ty2>
typedef Ty1 Converter< Ty1, Ty2 >::source [inherited]

Definition at line 18 of file Converter.h.


Constructor & Destructor Documentation

XmlTest1Cnv::XmlTest1Cnv ( ISvcLocator *  svcs  )  [protected]

Definition at line 29 of file XmlTest1Cnv.cxx.

00029                                           :
00030   XmlBaseCnv(svc, CLID_Calib_CalibTest1) { 
00031 }

virtual XmlTest1Cnv::~XmlTest1Cnv (  )  [inline, protected, virtual]

Definition at line 27 of file XmlTest1Cnv.h.

00027 {}       // most likely nothing to do 


Member Function Documentation

const CLID & XmlTest1Cnv::classID (  )  [static]

Definition at line 38 of file XmlTest1Cnv.cxx.

References CLID_Calib_CalibTest1.

00038                                  {
00039   return CLID_Calib_CalibTest1;
00040 }

template<class Ty1, class Ty2>
virtual destination* Converter< Ty1, Ty2 >::convert ( const source  )  const [protected, pure virtual, inherited]

StatusCode XmlBaseCnv::createObj ( IOpaqueAddress *  addr,
DataObject *&  refpObject 
) [virtual, inherited]

Create the transient representation of an object, given an opaque address. This and the following update method comprise the core functionality of calibration converters.

Definition at line 84 of file XmlBaseCnv.cxx.

References Bes_Common::FATAL, Bes_Common::INFO, XmlBaseCnv::internalCreateObj(), XmlBaseCnv::m_xmlSvc, msgSvc(), ICalibXmlSvc::parse(), and deljobs::string.

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 }

StatusCode XmlBaseCnv::finalize (  )  [virtual, inherited]

Definition at line 78 of file XmlBaseCnv.cxx.

00078                                 {
00079   return Converter::finalize();
00080 }

DOMElement * XmlBaseCnv::findFirstDacCol ( const DOMElement *  docElt  )  [protected, inherited]

Another one to find first dac collection element.

Definition at line 238 of file XmlBaseCnv.cxx.

References xmlBase::Dom::findFirstChildByName().

00238                                                                 {
00239   return  xmlBase::Dom::findFirstChildByName(docElt, "dac");
00240 }

DOMElement* XmlBaseCnv::findFirstRange ( const DOMElement *  docElt  )  [inline, protected, inherited]

Find first range element. Derived classes which need it must define their own implementation.

Definition at line 112 of file XmlBaseCnv.h.

00112                                                        {
00113     return 0;}

DOMElement * XmlBaseCnv::findNextDacCol ( const DOMElement *  rangeElt  )  [protected, inherited]

Still another one to navigate XML file and find next dac collection.

Definition at line 242 of file XmlBaseCnv.cxx.

References xmlBase::Dom::checkTagName(), xmlBase::Dom::getSiblingElement(), and next.

00242                                                                {
00243   DOMElement* next = xmlBase::Dom::getSiblingElement(dacElt);
00244   if (xmlBase::Dom::checkTagName(next, "dac")) return next;
00245   else return 0;
00246 }

DOMElement* XmlBaseCnv::findNextRange ( const DOMElement *  rangeElt  )  [inline, protected, inherited]

Still another one to navigate XML file and find next set of range data.

Definition at line 117 of file XmlBaseCnv.h.

00117                                                         {
00118     return 0;}

ICalibXmlSvc* XmlBaseCnv::getCalibXmlSvc (  )  [inline, inherited]

Definition at line 54 of file XmlBaseCnv.h.

References XmlBaseCnv::m_xmlSvc.

00054                                  {
00055     return m_xmlSvc;
00056   }

StatusCode XmlTest1Cnv::i_createObj ( const DOMElement *  element,
DataObject *&  refpObject 
) [protected, virtual]

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.

Parameters:
element the DOM_Element (typically root element of document) to be used to builds the object
refpObject the object to be built
Returns:
status depending on the completion of the call

Reimplemented from XmlBaseCnv.

Definition at line 52 of file XmlTest1Cnv.cxx.

References xmlBase::DomException::getMsg(), XmlBaseCnv::m_serNo, XmlBaseCnv::m_vend, XmlBaseCnv::m_vstart, and deljobs::string.

00054 {
00055   using xmlBase::Dom;
00056 
00057   // Fetch quantities we need: name, value
00058   DOMElement* child = Dom::findFirstChildByName(element, "data");
00059   if (child == 0) return StatusCode::FAILURE;
00060   child = Dom::findFirstChildByName(child, "leaf");
00061   if (child == 0) return StatusCode::FAILURE;
00062 
00063   std::string name = Dom::getAttribute(child, "name");
00064 
00065   //  std::string valueString = Dom::getAttribute(child, "value");
00066 
00067   //  int value = atoi(valueString.c_str());
00068   int value;
00069   try {
00070     value = Dom::getIntAttribute(child, "value");
00071   }
00072   catch (xmlBase::DomException ex) {
00073     std::cerr << "From CalibSvc::XmlTest1Cnv::i_crateObj " << std::endl;
00074     std::cerr << ex.getMsg() << std::endl;
00075   }
00076 
00077   refpObject = new  
00078     CalibData::CalibTest1(name, value, *m_vstart, *m_vend, m_serNo);
00079 
00080   return StatusCode::SUCCESS;
00081 }

StatusCode XmlBaseCnv::i_processObj ( DataObject *  pObject,
IOpaqueAddress *  address 
) [protected, virtual, inherited]

In case there is additional work to do on the created object.

Definition at line 198 of file XmlBaseCnv.cxx.

Referenced by XmlBaseCnv::internalCreateObj().

00199                                                                      {
00200   return StatusCode::SUCCESS;
00201 }

StatusCode XmlBaseCnv::initialize (  )  [virtual, inherited]

Definition at line 50 of file XmlBaseCnv.cxx.

References IID_ICalibMetaCnvSvc(), IID_ICalibXmlSvc(), XmlBaseCnv::m_metaSvc, and XmlBaseCnv::m_xmlSvc.

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 }

StatusCode XmlBaseCnv::internalCreateObj ( const DOMElement *  element,
DataObject *&  refpObject,
IOpaqueAddress *  address 
) [protected, virtual, inherited]

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.

Parameters:
element the DOMElement (typically the root element of the document) to be used to build the object
refpObject the object to be built
address the opaque address for this object
Returns:
status depending on the completion of the call

Definition at line 141 of file XmlBaseCnv.cxx.

References Bes_Common::DEBUG, calibUtil::ERROR, XmlBaseCnv::i_createObj(), XmlBaseCnv::i_processObj(), XmlBaseCnv::m_serNo, msgSvc(), and Bes_Common::WARNING.

Referenced by XmlBaseCnv::createObj().

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 } 

const CLID & XmlTest1Cnv::objType (  )  const

Definition at line 34 of file XmlTest1Cnv.cxx.

References CLID_Calib_CalibTest1.

00034                                        {
00035   return CLID_Calib_CalibTest1;
00036 }

template<class Ty1, class Ty2>
destination* Converter< Ty1, Ty2 >::operator ( const source  )  const [inline, inherited]

CalibData::DacCol * XmlBaseCnv::processDacCol ( DOMElement *  dacColElt,
unsigned *  range 
) [protected, inherited]

Definition at line 248 of file XmlBaseCnv.cxx.

References deljobs::string.

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 }

CalibData::ValSig * XmlBaseCnv::processValSig ( DOMElement *  elt,
std::string  valName,
std::string  sigName 
) [protected, inherited]

Read in what will become a CalibData::ValSig.

Definition at line 288 of file XmlBaseCnv.cxx.

References xmlBase::Dom::getDoubleAttribute(), CalibData::ValSig::m_sig, and CalibData::ValSig::m_val.

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 }

std::vector< CalibData::ValSig > * XmlBaseCnv::processValSigs ( DOMElement *  elt,
std::string  valName,
std::string  sigName 
) [protected, inherited]

Read in what will become a vector of CalibData::ValSig.

Definition at line 299 of file XmlBaseCnv.cxx.

References calibUtil::ERROR, xmlBase::Dom::getFloatsAttribute(), genRecEmupikp::i, and msgSvc().

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 }

StatusCode XmlBaseCnv::readHeader ( const DOMElement *   )  [protected, virtual, inherited]

Definition at line 220 of file XmlBaseCnv.cxx.

00220                                                    {
00221   return StatusCode::SUCCESS;
00222 }

void XmlBaseCnv::setBaseInfo ( CalibData::CalibBase pObj  )  [protected, inherited]

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.

Definition at line 232 of file XmlBaseCnv.cxx.

References XmlBaseCnv::m_serNo, XmlBaseCnv::m_vend, XmlBaseCnv::m_vstart, and CalibData::CalibBase::setSerNo().

00232                                                      {
00233   pObj->setValidity(*m_vstart, *m_vend);
00234   pObj->setSerNo(m_serNo);
00235 }

const unsigned char XmlBaseCnv::storageType (  )  [static, inherited]

Definition at line 224 of file XmlBaseCnv.cxx.

00224                                             {
00225   return XML_StorageType;
00226 }


Friends And Related Function Documentation

friend class CnvFactory< XmlTest1Cnv > [friend]

Friend needed for instantiation.

Definition at line 19 of file XmlTest1Cnv.h.


Member Data Documentation

ICalibMetaCnvSvc* XmlBaseCnv::m_metaSvc [protected, inherited]

Definition at line 148 of file XmlBaseCnv.h.

Referenced by XmlBaseCnv::initialize().

int XmlBaseCnv::m_serNo [protected, inherited]

Definition at line 150 of file XmlBaseCnv.h.

Referenced by i_createObj(), XmlBaseCnv::internalCreateObj(), and XmlBaseCnv::setBaseInfo().

ITime* XmlBaseCnv::m_vend [protected, inherited]

Definition at line 152 of file XmlBaseCnv.h.

Referenced by i_createObj(), and XmlBaseCnv::setBaseInfo().

ITime* XmlBaseCnv::m_vstart [protected, inherited]

Definition at line 151 of file XmlBaseCnv.h.

Referenced by i_createObj(), and XmlBaseCnv::setBaseInfo().

ICalibXmlSvc* XmlBaseCnv::m_xmlSvc [protected, inherited]

Definition at line 147 of file XmlBaseCnv.h.

Referenced by XmlBaseCnv::createObj(), XmlBaseCnv::getCalibXmlSvc(), and XmlBaseCnv::initialize().


Generated on Tue Nov 29 23:36:22 2016 for BOSS_7.0.2 by  doxygen 1.4.7