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 22 of file QTestConfigurationParser.h.

Constructor & Destructor Documentation

QTestConfigurationParser::QTestConfigurationParser ( )

Creator.

Definition at line 17 of file QTestConfigurationParser.cc.

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

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

Destructor.

Definition at line 32 of file QTestConfigurationParser.cc.

32  {
33  delete qtestParamNames;
34  qtestParamNames = nullptr;
35 }
QTestParameterNames * qtestParamNames

Member Function Documentation

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

Definition at line 123 of file QTestConfigurationParser.cc.

Referenced by instances().

123  {
124 
125  std::vector<std::string> paramNames=qtestParamNames->getTestParamNames(qtestType);
126  // commenting out as does not seem to be logical SDutta 22/3/2013
127  /*if(paramNames.size() == 0) {
128 
129  return true;
130  }*/
131 
132  paramNames.push_back("error");
133  paramNames.push_back("warning");
134 
135  std::map<std::string, std::string> namesMap=testsRequested[qtestName];
136 
137  for(std::vector<std::string>::iterator namesItr=paramNames.begin(); namesItr!=paramNames.end(); ++namesItr){
138  if(namesMap.find(*namesItr)==namesMap.end()){
139  return true;
140  }
141  }
142 
143  return false;
144 }
QTestParameterNames * qtestParamNames
std::vector< std::string > getTestParamNames(std::string theTestType)
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 100 of file QTestConfigurationParser.cc.

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

Referenced by meToTestsList().

100  {
101 
102  std::map<std::string, std::string> paramNamesValues;
103  paramNamesValues["type"]=qtestType;
104 
105  DOMNodeList *arguments = qtestElement->getElementsByTagName (qtxml::_toDOMS ("PARAM"));
106 
107  for (unsigned int i=0; i<arguments->getLength(); ++i){
108  DOMElement *argNode = dynamic_cast <DOMElement *> ( arguments ->item(i));
109  std::string regExp = qtxml::_toString (argNode->getAttribute (qtxml::_toDOMS ("name")));
110  DOMText *argText = dynamic_cast <DOMText *> (argNode->getFirstChild());
111  if (!argText){
112  break;
113  }
114 
115  std::string regExpValue = qtxml::_toString (argText->getData());
116  paramNamesValues[regExp]=regExpValue;
117  }
118 
119  return paramNamesValues;
120 
121 }
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 34 of file QTestConfigurationParser.h.

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

Referenced by QTestHandle::attachTests().

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

Get ME name

Loop on linkTagsNum

Definition at line 146 of file QTestConfigurationParser.cc.

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

Referenced by meToTestsList().

146  {
147 
148  std::string testON="true";
149  std::string testOFF="false";
150 
151  unsigned int linkTagsNum =
152  doc()->getElementsByTagName(qtxml::_toDOMS("LINK"))->getLength();
153 
154 
155  for (unsigned int i=0; i<linkTagsNum; ++i){
156 
157  DOMNode* linkNode =
158  doc()->getElementsByTagName(qtxml::_toDOMS("LINK"))->item(i);
160  if (! linkNode){
161  return true;
162  }
163  DOMElement* linkElement = static_cast<DOMElement *>(linkNode);
164  if (! linkElement){
165  return true;
166  }
167  std::string linkName = qtxml::_toString (linkElement->getAttribute (qtxml::_toDOMS ("name")));
168 
169  DOMNodeList *testList = linkElement->getElementsByTagName (qtxml::_toDOMS ("TestName"));
170  unsigned int numberOfTests=testList->getLength();
171 
172  std::vector<std::string> qualityTestList;
173  for(unsigned int tt=0; tt<numberOfTests; ++tt){
174  DOMElement * testElement = dynamic_cast <DOMElement *> ( testList ->item(tt));
175  if (!testElement ){
176  return true;
177  }
178 
179  std::string activate = qtxml::_toString (testElement ->getAttribute (qtxml::_toDOMS ("activate")));
180 
181  DOMText *argText = dynamic_cast <DOMText *> (testElement ->getFirstChild());
182 
183  if(!std::strcmp(activate.c_str(),testON.c_str())) {
184  if (!argText){
185  return true;
186  }else{
187  std::string regExpValue = qtxml::_toString (argText->getData());
188  qualityTestList.push_back(regExpValue);
189  }
190  }
191  if(!std::strcmp(activate.c_str(),testOFF.c_str())) {
192  if (argText) {
193  std::string regExpValue = qtxml::_toString (argText->getData());
194  // Create List of QTests to unattach from current ME
195  }
196  }
197 
198  }
199 
200 
201  if(!qualityTestList.empty()) mapMonitorElementTests[linkName]=qualityTestList;
202  }
203 
204 
205  return false;
206 
207 
208 
209 }
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:45
bool QTestConfigurationParser::parseQTestsConfiguration ( )

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

Definition at line 37 of file QTestConfigurationParser.cc.

Referenced by QTestHandle::configureTests().

37  {
38  testsToDisable.clear();
39  testsRequested.clear();
40  mapMonitorElementTests.clear();
41  bool qtErrors= this->qtestsConfig();
42  bool meErrors= this->monitorElementTestsMap();
43  return (qtErrors||meErrors);
44 
45 }
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 47 of file QTestConfigurationParser.cc.

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

Referenced by meToTestsList().

47  {
48 
49  std::string testActivationOFF="false";
50 
51  unsigned int qtestTagsNum =
52  doc()->getElementsByTagName(qtxml::_toDOMS("QTEST"))->getLength();
53 
54  for (unsigned int i=0; i<qtestTagsNum; ++i){
56  DOMNode* qtestNode =
57  doc()->getElementsByTagName(qtxml::_toDOMS("QTEST"))->item(i);
58 
59 
61  if (! qtestNode){
62  return true;
63  }
64  DOMElement* qtestElement = static_cast<DOMElement *>(qtestNode);
65  if (! qtestElement){
66  return true;
67  }
68  std::string qtestName = qtxml::_toString (qtestElement->getAttribute (qtxml::_toDOMS ("name")));
69  std::string activate = qtxml::_toString (qtestElement->getAttribute (qtxml::_toDOMS ("activate")));
70  if(!std::strcmp(activate.c_str(),testActivationOFF.c_str())) {
71  testsToDisable.push_back(qtestName);
72  }else{
73 
75  DOMNodeList *typeNodePrefix
76  = qtestElement->getElementsByTagName (qtxml::_toDOMS ("TYPE"));
77 
78  if (typeNodePrefix->getLength () != 1)return true;
79 
80 
81  DOMElement *prefixNode = dynamic_cast <DOMElement *> (typeNodePrefix->item (0));
82  if (!prefixNode)return true;
83 
84  DOMText *prefixText = dynamic_cast <DOMText *> (prefixNode->getFirstChild());
85  if (!prefixText)return true;
86 
87  std::string qtestType = qtxml::_toString (prefixText->getData ());
88 
89  testsRequested[qtestName]= this->getParams(qtestElement, qtestType);
90 
91  if( this->checkParameters(qtestName, qtestType)) return true;
92  }
93 
94  } //loop on qtestTagsNum
95 
96  return false;
97 
98 }
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:45
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 32 of file QTestConfigurationParser.h.

References testsRequested.

Referenced by QTestHandle::configureTests().

32 { 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 49 of file QTestConfigurationParser.h.

Referenced by meToTestsList().

QTestParameterNames* QTestConfigurationParser::qtestParamNames
private

Definition at line 52 of file QTestConfigurationParser.h.

int QTestConfigurationParser::s_numberOfInstances = 0
staticprivate

Definition at line 46 of file QTestConfigurationParser.h.

Referenced by instances().

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

Definition at line 48 of file QTestConfigurationParser.h.

Referenced by testsList().

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

Definition at line 50 of file QTestConfigurationParser.h.