CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 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 24 of file QTestConfigurationParser.h.

Constructor & Destructor Documentation

QTestConfigurationParser::QTestConfigurationParser ( )

Creator.

Definition at line 19 of file QTestConfigurationParser.cc.

References alignCSCRings::e.

19  {
20 
22 
23  try {
24  if (s_numberOfInstances==0)
25  XMLPlatformUtils::Initialize();
26  }
27  catch (const XMLException& e) {
28  throw(std::runtime_error("Standard pool exception : Fatal Error on pool::TrivialFileCatalog"));
29  }
30 
32 }
QTestParameterNames * qtestParamNames
QTestConfigurationParser::~QTestConfigurationParser ( )

Destructor.

Definition at line 34 of file QTestConfigurationParser.cc.

34  {
35  delete qtestParamNames;
36  qtestParamNames = 0;
37 }
QTestParameterNames * qtestParamNames

Member Function Documentation

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

Definition at line 125 of file QTestConfigurationParser.cc.

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

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

102  {
103 
104  std::map<std::string, std::string> paramNamesValues;
105  paramNamesValues["type"]=qtestType;
106 
107  DOMNodeList *arguments = qtestElement->getElementsByTagName (qtxml::_toDOMS ("PARAM"));
108 
109  for (unsigned int i=0; i<arguments->getLength(); ++i){
110  DOMElement *argNode = dynamic_cast <DOMElement *> ( arguments ->item(i));
111  std::string regExp = qtxml::_toString (argNode->getAttribute (qtxml::_toDOMS ("name")));
112  DOMText *argText = dynamic_cast <DOMText *> (argNode->getFirstChild());
113  if (!argText){
114  break;
115  }
116 
117  std::string regExpValue = qtxml::_toString (argText->getData());
118  paramNamesValues[regExp]=regExpValue;
119  }
120 
121  return paramNamesValues;
122 
123 }
int i
Definition: DBlmapReader.cc:9
std::string _toString(const XMLCh *toTranscode)
XMLCh * _toDOMS(std::string temp)
int QTestConfigurationParser::instances ( )
inlineprivate

Definition at line 42 of file QTestConfigurationParser.h.

References 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().

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

Get ME name

Loop on linkTagsNum

Definition at line 148 of file QTestConfigurationParser.cc.

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

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

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

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

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

References testsRequested.

Referenced by QTestHandle::configureTests().

34 { 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 51 of file QTestConfigurationParser.h.

Referenced by meToTestsList().

QTestParameterNames* QTestConfigurationParser::qtestParamNames
private

Definition at line 54 of file QTestConfigurationParser.h.

int QTestConfigurationParser::s_numberOfInstances = 0
staticprivate

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.