#include <QTestConfigurationParser.h>
Public Member Functions | |
std::map< std::string, std::vector< std::string > > | meToTestsList () const |
Returns the map between the MonitoElemnt and the list of tests requested for it. | |
bool | parseQTestsConfiguration () |
Methor that parses the xml file configFile, returns false if no errors are encountered. | |
QTestConfigurationParser () | |
Creator. | |
std::map< std::string, std::map< std::string, std::string > > | testsList () const |
Returns the Quality Tests list with their parameters obtained from the xml file. | |
~QTestConfigurationParser () | |
Destructor. | |
Private Member Functions | |
bool | checkParameters (std::string qtestName, std::string qtestType) |
std::map< std::string, std::string > | getParams (xercesc::DOMElement *qtestElement, std::string test) |
int | instances () |
bool | monitorElementTestsMap () |
bool | qtestsConfig () |
Private Attributes | |
std::map< std::string, std::vector< std::string > > | mapMonitorElementTests |
QTestParameterNames * | qtestParamNames |
std::map< std::string, std::map< std::string, std::string > > | testsRequested |
std::vector< std::string > | testsToDisable |
Static Private Attributes | |
static int | s_numberOfInstances = 0 |
* Parses the xml file with the configuration of quality tests and the map between quality tests and MonitorElement
Definition at line 24 of file QTestConfigurationParser.h.
QTestConfigurationParser::QTestConfigurationParser | ( | ) |
Creator.
Definition at line 19 of file QTestConfigurationParser.cc.
References ExpressReco_HICollisions_FallBack::e.
{ qtestParamNames=new QTestParameterNames(); try { if (s_numberOfInstances==0) XMLPlatformUtils::Initialize(); } catch (const XMLException& e) { throw(std::runtime_error("Standard pool exception : Fatal Error on pool::TrivialFileCatalog")); } ++s_numberOfInstances; }
QTestConfigurationParser::~QTestConfigurationParser | ( | ) |
Destructor.
Definition at line 34 of file QTestConfigurationParser.cc.
{ delete qtestParamNames; qtestParamNames = 0; }
bool QTestConfigurationParser::checkParameters | ( | std::string | qtestName, |
std::string | qtestType | ||
) | [private] |
Definition at line 125 of file QTestConfigurationParser.cc.
{ std::vector<std::string> paramNames=qtestParamNames->getTestParamNames(qtestType); if(paramNames.size() == 0) { return true; } paramNames.push_back("error"); paramNames.push_back("warning"); std::map<std::string, std::string> namesMap=testsRequested[qtestName]; for(std::vector<std::string>::iterator namesItr=paramNames.begin(); namesItr!=paramNames.end(); ++namesItr){ if(namesMap.find(*namesItr)==namesMap.end()){ return true; } } return false; }
std::map< std::string, std::string > QTestConfigurationParser::getParams | ( | xercesc::DOMElement * | qtestElement, |
std::string | test | ||
) | [private] |
Definition at line 102 of file QTestConfigurationParser.cc.
References qtxml::_toDOMS(), _toString(), and i.
{ std::map<std::string, std::string> paramNamesValues; paramNamesValues["type"]=qtestType; DOMNodeList *arguments = qtestElement->getElementsByTagName (qtxml::_toDOMS ("PARAM")); for (unsigned int i=0; i<arguments->getLength(); ++i){ DOMElement *argNode = dynamic_cast <DOMElement *> ( arguments ->item(i)); std::string regExp = qtxml::_toString (argNode->getAttribute (qtxml::_toDOMS ("name"))); DOMText *argText = dynamic_cast <DOMText *> (argNode->getFirstChild()); if (!argText){ break; } std::string regExpValue = qtxml::_toString (argText->getData()); paramNamesValues[regExp]=regExpValue; } return paramNamesValues; }
int QTestConfigurationParser::instances | ( | ) | [inline, private] |
Definition at line 42 of file QTestConfigurationParser.h.
References s_numberOfInstances.
{return s_numberOfInstances;}
std::map<std::string, std::vector<std::string> > QTestConfigurationParser::meToTestsList | ( | ) | const [inline] |
Returns the map between the MonitoElemnt and the list of tests requested for it.
Definition at line 36 of file QTestConfigurationParser.h.
References mapMonitorElementTests.
Referenced by QTestHandle::attachTests().
{ return mapMonitorElementTests;}
bool QTestConfigurationParser::monitorElementTestsMap | ( | ) | [private] |
Get ME name
Loop on linkTagsNum
Definition at line 146 of file QTestConfigurationParser.cc.
References qtxml::_toDOMS(), _toString(), asciidump::doc, and i.
{ std::string testON="true"; std::string testOFF="false"; unsigned int linkTagsNum = doc->getElementsByTagName(qtxml::_toDOMS("LINK"))->getLength(); for (unsigned int i=0; i<linkTagsNum; ++i){ DOMNode* linkNode = doc->getElementsByTagName(qtxml::_toDOMS("LINK"))->item(i); if (! linkNode){ return true; } DOMElement* linkElement = static_cast<DOMElement *>(linkNode); if (! linkElement){ return true; } std::string linkName = qtxml::_toString (linkElement->getAttribute (qtxml::_toDOMS ("name"))); DOMNodeList *testList = linkElement->getElementsByTagName (qtxml::_toDOMS ("TestName")); unsigned int numberOfTests=testList->getLength(); std::vector<std::string> qualityTestList; for(unsigned int tt=0; tt<numberOfTests; ++tt){ DOMElement * testElement = dynamic_cast <DOMElement *> ( testList ->item(tt)); if (!testElement ){ return true; } std::string activate = qtxml::_toString (testElement ->getAttribute (qtxml::_toDOMS ("activate"))); DOMText *argText = dynamic_cast <DOMText *> (testElement ->getFirstChild()); if(!std::strcmp(activate.c_str(),testON.c_str())) { if (!argText){ return true; }else{ std::string regExpValue = qtxml::_toString (argText->getData()); qualityTestList.push_back(regExpValue); } } if(!std::strcmp(activate.c_str(),testOFF.c_str())) { if (argText) { std::string regExpValue = qtxml::_toString (argText->getData()); // Create List of QTests to unattach from current ME } } } if(qualityTestList.size()) mapMonitorElementTests[linkName]=qualityTestList; } return false; }
bool QTestConfigurationParser::parseQTestsConfiguration | ( | ) |
Methor that parses the xml file configFile, returns false if no errors are encountered.
Definition at line 39 of file QTestConfigurationParser.cc.
Referenced by QTestHandle::configureTests().
{ testsToDisable.clear(); testsRequested.clear(); mapMonitorElementTests.clear(); bool qtErrors= this->qtestsConfig(); bool meErrors= this->monitorElementTestsMap(); return (qtErrors||meErrors); }
bool QTestConfigurationParser::qtestsConfig | ( | ) | [private] |
Get Node
Get QTEST name
Get Qtest TYPE
Definition at line 49 of file QTestConfigurationParser.cc.
References qtxml::_toDOMS(), _toString(), asciidump::doc, and i.
{ std::string testActivationOFF="false"; unsigned int qtestTagsNum = doc->getElementsByTagName(qtxml::_toDOMS("QTEST"))->getLength(); for (unsigned int i=0; i<qtestTagsNum; ++i){ DOMNode* qtestNode = doc->getElementsByTagName(qtxml::_toDOMS("QTEST"))->item(i); if (! qtestNode){ return true; } DOMElement* qtestElement = static_cast<DOMElement *>(qtestNode); if (! qtestElement){ return true; } std::string qtestName = qtxml::_toString (qtestElement->getAttribute (qtxml::_toDOMS ("name"))); std::string activate = qtxml::_toString (qtestElement->getAttribute (qtxml::_toDOMS ("activate"))); if(!std::strcmp(activate.c_str(),testActivationOFF.c_str())) { testsToDisable.push_back(qtestName); }else{ DOMNodeList *typeNodePrefix = qtestElement->getElementsByTagName (qtxml::_toDOMS ("TYPE")); if (typeNodePrefix->getLength () != 1)return true; DOMElement *prefixNode = dynamic_cast <DOMElement *> (typeNodePrefix->item (0)); if (!prefixNode)return true; DOMText *prefixText = dynamic_cast <DOMText *> (prefixNode->getFirstChild()); if (!prefixText)return true; std::string qtestType = qtxml::_toString (prefixText->getData ()); testsRequested[qtestName]= this->getParams(qtestElement, qtestType); if( this->checkParameters(qtestName, qtestType)) return true; } } //loop on qtestTagsNum return false; }
std::map<std::string, std::map<std::string, std::string> > QTestConfigurationParser::testsList | ( | ) | const [inline] |
Returns the Quality Tests list with their parameters obtained from the xml file.
Definition at line 34 of file QTestConfigurationParser.h.
References testsRequested.
Referenced by QTestHandle::configureTests().
{ return testsRequested;}
std::map<std::string, std::vector<std::string> > QTestConfigurationParser::mapMonitorElementTests [private] |
Definition at line 51 of file QTestConfigurationParser.h.
Referenced by meToTestsList().
Definition at line 54 of file QTestConfigurationParser.h.
int QTestConfigurationParser::s_numberOfInstances = 0 [static, private] |
Definition at line 48 of file QTestConfigurationParser.h.
Referenced by instances().
std::map<std::string, std::map<std::string, std::string> > QTestConfigurationParser::testsRequested [private] |
Definition at line 50 of file QTestConfigurationParser.h.
Referenced by testsList().
std::vector<std::string> QTestConfigurationParser::testsToDisable [private] |
Definition at line 52 of file QTestConfigurationParser.h.