CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
QTestConfigurationParser Class Reference

#include <QTestConfigurationParser.h>

Inheritance diagram for QTestConfigurationParser:
DQMParserBase

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. More...
 
bool parseQTestsConfiguration ()
 Methor that parses the xml file configFile, returns false if no errors are encountered. More...
 
 QTestConfigurationParser ()
 Creator. More...
 
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. More...
 
 ~QTestConfigurationParser () override
 Destructor. More...
 
- Public Member Functions inherited from DQMParserBase
int countNodes (std::string tagName)
 Returns the number of nodes with given name. More...
 
xercesc::DOMDocument * doc ()
 DOM Document. More...
 
 DQMParserBase ()
 Creator. More...
 
void getDocument (std::string configFile, bool UseDB=false)
 Methor that parses the xml file configFile. More...
 
void getNewDocument (std::string configFile, bool UseDB=false)
 Parses a new Document. More...
 
virtual ~DQMParserBase ()
 Destructor. More...
 

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
 
QTestParameterNamesqtestParamNames
 
std::map< std::string, std::map< std::string, std::string > > testsRequested
 
std::vector< std::string > testsToDisable
 

Static Private Attributes

static int s_numberOfInstances = 0
 

Additional Inherited Members

- Protected Attributes inherited from DQMParserBase
xercesc::XercesDOMParser * parser
 

Detailed Description

Definition at line 21 of file QTestConfigurationParser.h.

Constructor & Destructor Documentation

QTestConfigurationParser::QTestConfigurationParser ( )

Creator.

Definition at line 16 of file QTestConfigurationParser.cc.

References MillePedeFileConverter_cfg::e, and cms::concurrency::xercesInitialize().

16  {
18 
19  try {
20  if (s_numberOfInstances == 0)
22  } catch (const XMLException &e) {
23  throw(std::runtime_error("Standard pool exception : Fatal Error on pool::TrivialFileCatalog"));
24  }
25 
27 }
void xercesInitialize()
Definition: Xerces.cc:18
QTestParameterNames * qtestParamNames
QTestConfigurationParser::~QTestConfigurationParser ( )
override

Destructor.

Definition at line 29 of file QTestConfigurationParser.cc.

29  {
30  delete qtestParamNames;
31  qtestParamNames = nullptr;
32 }
QTestParameterNames * qtestParamNames

Member Function Documentation

bool QTestConfigurationParser::checkParameters ( std::string  qtestName,
std::string  qtestType 
)
private

Definition at line 114 of file QTestConfigurationParser.cc.

Referenced by instances().

114  {
115  std::vector<std::string> paramNames = qtestParamNames->getTestParamNames(qtestType);
116  // commenting out as does not seem to be logical SDutta 22/3/2013
117  /*if(paramNames.size() == 0) {
118 
119  return true;
120  }*/
121 
122  paramNames.push_back("error");
123  paramNames.push_back("warning");
124 
125  std::map<std::string, std::string> namesMap = testsRequested[qtestName];
126 
127  for (std::vector<std::string>::iterator namesItr = paramNames.begin(); namesItr != paramNames.end(); ++namesItr) {
128  if (namesMap.find(*namesItr) == namesMap.end()) {
129  return true;
130  }
131  }
132 
133  return false;
134 }
std::vector< std::string > getTestParamNames(std::string theTestType)
QTestParameterNames * qtestParamNames
std::map< std::string, std::map< std::string, std::string > > testsRequested
std::map< std::string, std::string > QTestConfigurationParser::getParams ( xercesc::DOMElement *  qtestElement,
std::string  test 
)
private

Definition at line 92 of file QTestConfigurationParser.cc.

References qtxml::_toDOMS(), qtxml::_toString(), mps_fire::i, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by meToTestsList().

93  {
94  std::map<std::string, std::string> paramNamesValues;
95  paramNamesValues["type"] = qtestType;
96 
97  DOMNodeList *arguments = qtestElement->getElementsByTagName(qtxml::_toDOMS("PARAM"));
98 
99  for (unsigned int i = 0; i < arguments->getLength(); ++i) {
100  DOMElement *argNode = dynamic_cast<DOMElement *>(arguments->item(i));
101  std::string regExp = qtxml::_toString(argNode->getAttribute(qtxml::_toDOMS("name")));
102  DOMText *argText = dynamic_cast<DOMText *>(argNode->getFirstChild());
103  if (!argText) {
104  break;
105  }
106 
107  std::string regExpValue = qtxml::_toString(argText->getData());
108  paramNamesValues[regExp] = regExpValue;
109  }
110 
111  return paramNamesValues;
112 }
std::string _toString(const XMLCh *toTranscode)
XMLCh * _toDOMS(std::string temp)
int QTestConfigurationParser::instances ( )
inlineprivate
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 32 of file QTestConfigurationParser.h.

References getParams(), mapMonitorElementTests, monitorElementTestsMap(), qtestsConfig(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by QTestHandle::attachTests().

32 { return mapMonitorElementTests; }
std::map< std::string, std::vector< std::string > > mapMonitorElementTests
bool QTestConfigurationParser::monitorElementTestsMap ( )
private

Get ME name

Loop on linkTagsNum

Definition at line 136 of file QTestConfigurationParser.cc.

References qtxml::_toDOMS(), qtxml::_toString(), common_cff::doc, mps_fire::i, AlCaHLTBitMon_QueryRunRegistry::string, runTheMatrix::testList, and groupFilesInBlocks::tt.

Referenced by meToTestsList().

136  {
137  std::string testON = "true";
138  std::string testOFF = "false";
139 
140  unsigned int linkTagsNum = doc()->getElementsByTagName(qtxml::_toDOMS("LINK"))->getLength();
141 
142  for (unsigned int i = 0; i < linkTagsNum; ++i) {
143  DOMNode *linkNode = doc()->getElementsByTagName(qtxml::_toDOMS("LINK"))->item(i);
145  if (!linkNode) {
146  return true;
147  }
148  DOMElement *linkElement = static_cast<DOMElement *>(linkNode);
149  if (!linkElement) {
150  return true;
151  }
152  std::string linkName = qtxml::_toString(linkElement->getAttribute(qtxml::_toDOMS("name")));
153 
154  DOMNodeList *testList = linkElement->getElementsByTagName(qtxml::_toDOMS("TestName"));
155  unsigned int numberOfTests = testList->getLength();
156 
157  std::vector<std::string> qualityTestList;
158  for (unsigned int tt = 0; tt < numberOfTests; ++tt) {
159  DOMElement *testElement = dynamic_cast<DOMElement *>(testList->item(tt));
160  if (!testElement) {
161  return true;
162  }
163 
164  std::string activate = qtxml::_toString(testElement->getAttribute(qtxml::_toDOMS("activate")));
165 
166  DOMText *argText = dynamic_cast<DOMText *>(testElement->getFirstChild());
167 
168  if (!std::strcmp(activate.c_str(), testON.c_str())) {
169  if (!argText) {
170  return true;
171  } else {
172  std::string regExpValue = qtxml::_toString(argText->getData());
173  qualityTestList.push_back(regExpValue);
174  }
175  }
176  if (!std::strcmp(activate.c_str(), testOFF.c_str())) {
177  if (argText) {
178  std::string regExpValue = qtxml::_toString(argText->getData());
179  // Create List of QTests to unattach from current ME
180  }
181  }
182  }
183 
184  if (!qualityTestList.empty())
185  mapMonitorElementTests[linkName] = qualityTestList;
186  }
187 
188  return false;
189 }
std::string _toString(const XMLCh *toTranscode)
XMLCh * _toDOMS(std::string temp)
std::map< std::string, std::vector< std::string > > mapMonitorElementTests
xercesc::DOMDocument * doc()
DOM Document.
Definition: DQMParserBase.h:39
bool QTestConfigurationParser::parseQTestsConfiguration ( )

Methor that parses the xml file configFile, returns false if no errors are encountered.

Definition at line 34 of file QTestConfigurationParser.cc.

Referenced by QTestHandle::configureTests().

34  {
35  testsToDisable.clear();
36  testsRequested.clear();
37  mapMonitorElementTests.clear();
38  bool qtErrors = this->qtestsConfig();
39  bool meErrors = this->monitorElementTestsMap();
40  return (qtErrors || meErrors);
41 }
std::vector< std::string > testsToDisable
std::map< std::string, std::vector< std::string > > mapMonitorElementTests
std::map< std::string, std::map< std::string, std::string > > testsRequested
bool QTestConfigurationParser::qtestsConfig ( )
private

Get Node

Get QTEST name

Get Qtest TYPE

Definition at line 43 of file QTestConfigurationParser.cc.

References qtxml::_toDOMS(), qtxml::_toString(), common_cff::doc, LHCInfoImpl::getParams(), mps_fire::i, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by meToTestsList().

43  {
44  std::string testActivationOFF = "false";
45 
46  unsigned int qtestTagsNum = doc()->getElementsByTagName(qtxml::_toDOMS("QTEST"))->getLength();
47 
48  for (unsigned int i = 0; i < qtestTagsNum; ++i) {
50  DOMNode *qtestNode = doc()->getElementsByTagName(qtxml::_toDOMS("QTEST"))->item(i);
51 
53  if (!qtestNode) {
54  return true;
55  }
56  DOMElement *qtestElement = static_cast<DOMElement *>(qtestNode);
57  if (!qtestElement) {
58  return true;
59  }
60  std::string qtestName = qtxml::_toString(qtestElement->getAttribute(qtxml::_toDOMS("name")));
61  std::string activate = qtxml::_toString(qtestElement->getAttribute(qtxml::_toDOMS("activate")));
62  if (!std::strcmp(activate.c_str(), testActivationOFF.c_str())) {
63  testsToDisable.push_back(qtestName);
64  } else {
66  DOMNodeList *typeNodePrefix = qtestElement->getElementsByTagName(qtxml::_toDOMS("TYPE"));
67 
68  if (typeNodePrefix->getLength() != 1)
69  return true;
70 
71  DOMElement *prefixNode = dynamic_cast<DOMElement *>(typeNodePrefix->item(0));
72  if (!prefixNode)
73  return true;
74 
75  DOMText *prefixText = dynamic_cast<DOMText *>(prefixNode->getFirstChild());
76  if (!prefixText)
77  return true;
78 
79  std::string qtestType = qtxml::_toString(prefixText->getData());
80 
81  testsRequested[qtestName] = this->getParams(qtestElement, qtestType);
82 
83  if (this->checkParameters(qtestName, qtestType))
84  return true;
85  }
86 
87  } //loop on qtestTagsNum
88 
89  return false;
90 }
std::map< std::string, std::string > getParams(xercesc::DOMElement *qtestElement, std::string test)
std::string _toString(const XMLCh *toTranscode)
bool checkParameters(std::string qtestName, std::string qtestType)
std::vector< std::string > testsToDisable
XMLCh * _toDOMS(std::string temp)
xercesc::DOMDocument * doc()
DOM Document.
Definition: DQMParserBase.h:39
std::map< std::string, std::map< std::string, std::string > > testsRequested
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 30 of file QTestConfigurationParser.h.

References testsRequested.

Referenced by QTestHandle::configureTests().

30 { return testsRequested; }
std::map< std::string, std::map< std::string, std::string > > testsRequested

Member Data Documentation

std::map<std::string, std::vector<std::string> > QTestConfigurationParser::mapMonitorElementTests
private

Definition at line 45 of file QTestConfigurationParser.h.

Referenced by meToTestsList().

QTestParameterNames* QTestConfigurationParser::qtestParamNames
private

Definition at line 48 of file QTestConfigurationParser.h.

int QTestConfigurationParser::s_numberOfInstances = 0
staticprivate

Definition at line 42 of file QTestConfigurationParser.h.

Referenced by instances().

std::map<std::string, std::map<std::string, std::string> > QTestConfigurationParser::testsRequested
private

Definition at line 44 of file QTestConfigurationParser.h.

Referenced by testsList().

std::vector<std::string> QTestConfigurationParser::testsToDisable
private

Definition at line 46 of file QTestConfigurationParser.h.