XML Parser class for the hvEdit administration file. * * \param hva pointer to the main class. */ PHvAdminXMLParser::PHvAdminXMLParser(PHvAdmin *hva) { fHva = hva; fKey = empty; fOdbRootCounter = 0; } //********************************************************************** // startDocument //********************************************************************** /*! *
Routine called at the beginning of the XML parsing process. */ bool PHvAdminXMLParser::startDocument() { return TRUE; } //********************************************************************** // startElement //********************************************************************** /*! *
Routine called when a new XML tag is found. Here it is used * to set a tag for filtering afterwards the content. * * \param qName name of the XML tag. */ bool PHvAdminXMLParser::startElement( const QString&, const QString&, const QString& qName, const QXmlAttributes& ) { if (qName == "default_settings_dir") { fKey = defaultSettingDir; } else if (qName == "default_doc_dir") { fKey = defaultDocDir; } else if (qName == "termination_timeout") { fKey = terminationTimeout; } else if (qName == "demand_in_V") { fKey = demandInV; } else if (qName == "hv_root") { if (fOdbRootCounter == 0) fHva->fMidasOdbHvRoot->remove(); fOdbRootCounter++; fKey = hvRoot; } else if (qName == "hv_names") { fKey = hvNames; } else if (qName == "hv_demand") { fKey = hvDemand; } else if (qName == "hv_measured") { fKey = hvMeasured; } else if (qName == "hv_current") { fKey = hvCurrent; } else if (qName == "hv_current_limit") { fKey = hvCurrentLimit; } return TRUE; } //********************************************************************** // endElement //********************************************************************** /*! *
Routine called when the end XML tag is found. It is used to * put the filtering tag to 'empty'. */ bool PHvAdminXMLParser::endElement( const QString&, const QString&, const QString& ) { fKey = empty; return TRUE; } //********************************************************************** // characters //********************************************************************** /*! *
This routine delivers the content of an XML tag. It fills the * content into the load data structure. */ bool PHvAdminXMLParser::characters(const QString& str) { QString root; switch (fKey) { case defaultSettingDir: fHva->fDefaultDirHvSettings = QString(str.ascii()).stripWhiteSpace(); fHva->fb_DefaultDirHvSettings = true; break; case defaultDocDir: fHva->fDefaultDirDocu = QString(str.ascii()).stripWhiteSpace(); fHva->fb_DefaultDirDocu = true; break; case terminationTimeout: fHva->fTerminationTimeout = str.toInt(); fHva->fb_TerminationTimeout = true; break; case demandInV: if (str == "true") fHva->fDemandInV = true; else fHva->fDemandInV = false; fHva->fb_DemandInVPresent = true; break; case hvRoot: root = QString(str.ascii()).stripWhiteSpace(); fHva->fMidasOdbHvRoot->append(new QString(root)); fHva->fb_MidasOdbHvRoot = true; break; case hvNames: fHva->fMidasOdbHvNames = QString(str.ascii()).stripWhiteSpace(); fHva->fb_MidasOdbHvNames = true; break; case hvDemand: fHva->fMidasOdbHvDemand = QString(str.ascii()).stripWhiteSpace(); fHva->fb_MidasOdbHvDemand = true; break; case hvMeasured: fHva->fMidasOdbHvMeasured = QString(str.ascii()).stripWhiteSpace(); fHva->fb_MidasOdbHvMeasured = true; break; case hvCurrent: fHva->fMidasOdbHvCurrent = QString(str.ascii()).stripWhiteSpace(); fHva->fb_MidasOdbHvCurrent = true; break; case hvCurrentLimit: fHva->fMidasOdbHvCurrentLimit = QString(str.ascii()).stripWhiteSpace(); fHva->fb_MidasOdbHvCurrentLimit = true; break; default: break; } return TRUE; } //********************************************************************** // endDocument //********************************************************************** /*! *
Called at the end of the XML parse process. */ bool PHvAdminXMLParser::endDocument() { fHva->fNoOdbRoots = fOdbRootCounter; return TRUE; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // implementation of PHvAdmin //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //********************************************************************** // PHvAdmin constructor //********************************************************************** /*! *
Constructs the administration class object. This class holds all ODB and
* path related variables.
*
* \param host name of the host
* \param exp name of the experiment
*/
PHvAdmin::PHvAdmin(char *host, char *exp)
{
fHost = QString(host).stripWhiteSpace();
fExp = QString(exp).stripWhiteSpace();
// initialize flags for ODB pathes
fb_DefaultDirHvSettings = false;
fb_DefaultDirDocu = false;
fb_TerminationTimeout = false;
fb_DemandInVPresent = false;
fb_MidasOdbHvRoot = false;
fb_MidasOdbHvNames = false;
fb_MidasOdbHvDemand = false;
fb_MidasOdbHvMeasured = false;
fb_MidasOdbHvCurrent = false;
fb_MidasOdbHvCurrentLimit = false;
// init counters
fNoOdbRoots = 0;
// init termination timeout to a 15 (min) default
fTerminationTimeout = 15;
// init demand in V default
fDemandInV = true;
// init ODB path strings to some sensible defaults
QString str("/Equipment/HV");
fMidasOdbHvRoot = new QPtrList Destructor
*/
PHvAdmin::~PHvAdmin()
{
if (fMidasOdbHvRoot) {
delete fMidasOdbHvRoot;
fMidasOdbHvRoot = 0;
}
}
//**********************************************************************
// GetHvOdbRoot
//**********************************************************************
/*!
* returns the ODB path of the HV root with number i
*
* \param i number of a given ODB HV root
*/
QString* PHvAdmin::GetHvOdbRoot(uint i)
{
if (fMidasOdbHvRoot->count() < i)
return 0;
else
return fMidasOdbHvRoot->at(i);
}