#include <MyFrame.h>
Public Member Functions | |
const double | DOMToDouble (const XMLCh *thisDOMString) const |
const double | DOMToDouble (const XMLCh *thisDOMString) const |
void | final () |
void | final () |
const std::vector< std::pair< Signature *, Sequence * > > & | getTablesVector () const |
const std::vector< std::pair< Signature *, Sequence * > > & | getTablesVector () const |
void | init (const std::string, const std::string) |
void | init (const std::string, const std::string) |
void | makeTableVector () |
void | makeTableVector () |
Static Public Member Functions | |
void | destruct () |
void | destruct () |
MyFrame * | instance () |
MyFrame * | instance () |
Protected Member Functions | |
MyFrame () | |
MyFrame () | |
~MyFrame () | |
~MyFrame () | |
Private Member Functions | |
void | buildSequenceList (const DOMNode *, bool) |
void | buildSequenceList (const DOMNode *, bool) |
void | buildSignatureList (const DOMNode *, bool) |
void | buildSignatureList (const DOMNode *, bool) |
Private Attributes | |
bool | m_first |
int | m_FrameAbsolutMaxStep |
int | m_FrameNumSequenceTables |
int | m_FrameNumTables |
char * | m_FrameSequenceListFile |
char * | m_FrameSequenceListFile |
char * | m_FrameSignatureListFile |
char * | m_FrameSignatureListFile |
int | m_idCriteria |
int | m_idItem |
int | m_idSequence |
int | m_idSignature |
MessageSvcProvider * | m_msgSvcProvider |
MessageSvcProvider * | m_msgSvcProvider |
DOMNode * | m_Sequence_DocNode |
DOMNode * | m_Sequence_DocNode |
std::vector< Sequence * > | m_SequenceVec |
std::vector< Sequence * > | m_SequenceVec |
DOMNode * | m_Signature_DocNode |
DOMNode * | m_Signature_DocNode |
std::vector< Signature * > | m_SignatureVec |
std::vector< Signature * > | m_SignatureVec |
std::vector< std::pair< Signature *, Sequence * > > | m_TableVector |
std::vector< std::pair< Signature *, Sequence * > > | m_TableVector |
std::string | m_thisName |
Static Private Attributes | |
MyFrame * | s_FrameInstance |
MyFrame * | s_FrameInstance = 0 |
|
00033 : 00034 m_FrameNumSequenceTables(0),m_FrameNumTables(0), 00035 m_FrameAbsolutMaxStep(0), 00036 m_Signature_DocNode(NULL), m_Sequence_DocNode(NULL), 00037 m_SignatureVec(0),m_SequenceVec(0),m_TableVector(0), 00038 m_idSequence(0),m_idSignature(0),m_idCriteria(0),m_idItem(0), 00039 m_first(true) 00040 { 00041 if(s_FrameInstance){ 00042 std::cout << " MyFrame constructed twice!"<< std::endl; 00043 } 00044 s_FrameInstance=this; 00045 m_thisName = "HltConfig"; 00046 m_msgSvcProvider = MessageSvcProvider::instance(); 00047 }
|
|
00051 { 00052 for (unsigned int i = 0; i < m_SignatureVec.size(); i++) delete m_SignatureVec[i]; 00053 for (unsigned int j = 0; j < m_SequenceVec.size(); j++) delete m_SequenceVec[j]; 00054 //destruct(); 00055 }
|
|
|
|
|
|
|
|
00198 { 00199 //MsgStream log(m_msgSvcProvider->msgSvc(), m_thisName); 00200 if ( first ) { 00201 first=false; 00202 //log << MSG::INFO << endreq; 00203 //log << MSG::INFO << "--------------------------------------" << endreq; 00204 //log << MSG::INFO << " Building global sequence list! " << endreq; 00205 //log << MSG::INFO << "--------------------------------------" << endreq; 00206 } 00207 std::string outString, inputString, seq_idString, algoString; 00208 00209 #define XMLCF XMLString::compareString 00210 #define XMLTF XMLString::transcode 00211 DOMNode *helpNode = thisNode->getFirstChild(); 00212 // loop through the tree 00213 while (helpNode != 0) { 00214 00215 if(XMLCF(XMLTF(helpNode->getNodeName()),"SEQUENCE")==0) { 00216 DOMNamedNodeMap *attributes = helpNode->getAttributes(); 00217 int attributesCount = attributes->getLength(); 00218 for(int i = 0; i < attributesCount; i++) { 00219 if(XMLCF(XMLTF(attributes->item(i)->getNodeName()),"sequence_id")==0) 00220 seq_idString = XMLTF(attributes->item(i)->getNodeValue()); 00221 if(XMLCF(XMLTF(attributes->item(i)->getNodeName()),"input")==0) 00222 inputString = XMLTF(attributes->item(i)->getNodeValue()); 00223 if(XMLCF(XMLTF(attributes->item(i)->getNodeName()),"output")==0) 00224 outString = XMLTF(attributes->item(i)->getNodeValue()); 00225 } 00226 std::cout <<"+-Found SEQUENCE: " << seq_idString << std::endl; 00227 //log << MSG::INFO <<"+-Found SEQUENCE: " << seq_idString << endreq; 00228 Sequence* m_helpSequence = new Sequence(); 00229 m_helpSequence->setSeqID(seq_idString); 00230 m_helpSequence->setInputID(inputString); 00231 m_helpSequence->setOutputID(outString); 00232 m_SequenceVec.push_back(m_helpSequence); 00233 } 00234 00235 if (XMLCF(XMLTF(helpNode->getNodeName()),"ESALGORITHM") == 0) { 00236 DOMNamedNodeMap *attributes = helpNode->getAttributes(); 00237 int attributesCount = attributes->getLength(); 00238 for (int i = 0; i < attributesCount; i++) { 00239 if(XMLCF(XMLTF(attributes->item(i)->getNodeName()),"algorithm")==0) 00240 algoString = XMLTF(attributes->item(i)->getNodeValue()); 00241 } 00242 std::cout << "| +-Found ESALGORITHM: " << algoString << std::endl; 00243 //log << MSG::INFO << "| +-Found ESALGORITHM: " << algoString << endreq; 00244 m_SequenceVec.back()->makeVectors(algoString); 00245 } 00246 00247 // and crowl on ... 00248 MyFrame::buildSequenceList(helpNode, first); 00249 helpNode = helpNode->getNextSibling(); 00250 } 00251 #undef XMLCF 00252 #undef XMLTF 00253 }
|
|
|
|
00257 { 00258 //MsgStream log(m_msgSvcProvider->msgSvc(), m_thisName); 00259 00260 if ( first ) { 00261 first = false; 00262 //log << MSG::INFO << endreq; 00263 //log << MSG::INFO << "--------------------------------------" << endreq; 00264 //log << MSG::INFO << " Building global signature list! " << endreq; 00265 //log << MSG::INFO << "--------------------------------------" << endreq; 00266 } 00267 std::string helpString, helpPrescale, behaviour, itemName, itemType; 00268 int prescale=1; 00269 float forcedAccept=1, itemValue=0; 00270 00271 #define XMLCF XMLString::compareString 00272 #define XMLTF XMLString::transcode 00273 DOMNode *helpNode = thisNode->getFirstChild(); 00274 // loop through the tree 00275 while (helpNode != 0) { 00276 static std::string current_sigID = ""; 00277 if(XMLCF(XMLTF(helpNode->getNodeName()),"SIGNATURE")==0) { 00278 DOMNamedNodeMap *attributes = helpNode->getAttributes(); 00279 unsigned int attributesCount = attributes->getLength(); 00280 for(unsigned int i = 0; i < attributesCount; i++) { 00281 if(XMLCF(XMLTF(attributes->item(i)->getNodeName()),"signature_id")==0) 00282 helpString = XMLTF(attributes->item(i)->getNodeValue()); 00283 current_sigID = helpString; 00284 if(XMLCF(XMLTF(attributes->item(i)->getNodeName()),"prescale")==0) { 00285 helpPrescale = XMLTF(attributes->item(i)->getNodeValue()); 00286 prescale = atoi(helpPrescale.c_str()); 00287 } 00288 if(XMLCF(XMLTF(attributes->item(i)->getNodeName()),"forced_accept")==0) 00289 forcedAccept = (float)DOMToDouble(attributes->item(i)->getNodeValue()); 00290 } 00291 std::cout<< "+-Found SIGNATURE: " << helpString << std::endl; 00292 //log << MSG::INFO << "+-Found SIGNATURE: " << helpString << endreq; 00293 Signature* m_helpSignature = new Signature(); 00294 m_helpSignature->setSigLabel(helpString); 00295 m_helpSignature->setPrescale(prescale); 00296 m_helpSignature->setForcedAccept(forcedAccept); 00297 m_SignatureVec.push_back(m_helpSignature); 00298 } 00299 //std::cout<<"***************************2"<<std::endl; 00300 static HltCriteria* current_HltCriteria = NULL; 00301 if(XMLCF(XMLTF(helpNode->getNodeName()),"CRITERIA")==0) { 00302 HltCriteria *m_HltCriteria = new HltCriteria(m_idCriteria); 00303 DOMNamedNodeMap *attributes = helpNode->getAttributes(); 00304 unsigned int attributesCount = attributes->getLength(); 00305 //std::cout <<"---------------------------1"<<current_sigID<<std::endl; 00306 for(unsigned int i = 0; i < attributesCount; i++) { 00307 if(XMLCF(XMLTF(attributes->item(i)->getNodeName()),"behaviour")==0) { 00308 behaviour = XMLTF(attributes->item(i)->getNodeValue()); 00309 if (behaviour == "reject") behaviour += "_reject"; 00310 } 00311 if(XMLCF(XMLTF(attributes->item(i)->getNodeName()),"next")==0) { 00312 if (behaviour != "jump") { 00313 std::cout << "Unconsistent of behaviour and next" << std::endl; 00314 //log << MSG::ERROR << "Unconsistent of behaviour and next" << endreq; 00315 exit(1); 00316 } 00317 std::string nextID = XMLTF(attributes->item(i)->getNodeValue()); 00318 //std::cout <<"---------------------------2"<<nextID<<std::endl; 00319 for (unsigned int i = 0; i < m_SequenceVec.size(); i++) { 00320 //std::cout << "======="<<m_SequenceVec[i]->getSeqID()<<std::endl; 00321 if (m_SequenceVec[i]->getSeqID() == current_sigID) { 00322 while (++i < m_SequenceVec.size()) { 00323 //std::cout << "======="<<m_SequenceVec[i]->getSeqID()<<std::endl; 00324 if (m_SequenceVec[i]->getSeqID() == nextID) break; 00325 } 00326 if (i == m_SequenceVec.size()) { 00327 std::cout << "Undefined jump target: " << nextID << std::endl; 00328 //log << MSG::ERROR << "Undefined jump target: " << nextID << endreq; 00329 exit(1); 00330 } 00331 break; 00332 } 00333 } 00334 behaviour = behaviour +'_'+ nextID; 00335 } 00336 if(XMLCF(XMLTF(attributes->item(i)->getNodeName()),"mark")==0) { 00337 if ((behaviour!= "accept")&&(behaviour!= "continue")) { 00338 std::cout << "Unconsistent of behaviour and mark" << std::endl; 00339 //log << MSG::ERROR << "Unconsistent of behaviour and mark" << endreq; 00340 exit(1); 00341 } 00342 behaviour = behaviour +'_'+ XMLTF(attributes->item(i)->getNodeValue()); 00343 } 00344 } 00345 if (behaviour.find('_') == string::npos) { 00346 std::cout << "Unvalid behaviour ==> " << behaviour << std::endl; 00347 //log << MSG::ERROR << "Unvalid behaviour ==> " << behaviour << endreq; 00348 exit(1); 00349 } 00350 //std::cout << "-----------------" << behaviour << std::endl; 00351 m_HltCriteria->setBehaviour(behaviour); 00352 std::cout << "| +-Found CRITERIA: behaviour as " << m_HltCriteria->getBehaviour() << std::endl; 00353 //log << MSG::INFO << "| +-Found CRITERIA: behaviour as " << behaviour << endreq; 00354 m_SignatureVec.back()->makeVectors(m_HltCriteria); 00355 m_idCriteria++; 00356 current_HltCriteria = m_HltCriteria; 00357 } 00358 //std::cout<<"***************************3"<<std::endl; 00359 if(XMLCF(XMLTF(helpNode->getNodeName()),"ITEM") == 0) { 00360 DOMNamedNodeMap *itemAttr = helpNode->getAttributes(); 00361 if (itemAttr->getLength() != 3) { 00362 //log << MSG::ERROR << "Unvalid CriteriaItem" << endreq; 00363 exit(1); 00364 } 00365 for (int i = 0; i < 3; i++) { 00366 if(XMLCF(XMLTF(itemAttr->item(i)->getNodeName()), "name") == 0) 00367 itemName = XMLTF(itemAttr->item(i)->getNodeValue()); 00368 if(XMLCF(XMLTF(itemAttr->item(i)->getNodeName()), "value") == 0) 00369 itemValue = (float)DOMToDouble(itemAttr->item(i)->getNodeValue()); 00370 if(XMLCF(XMLTF(itemAttr->item(i)->getNodeName()), "type") == 0) 00371 itemType = XMLTF(itemAttr->item(i)->getNodeValue()); 00372 } 00373 //log << MSG::INFO << "| | +-Found CRITERIA_ITEM (" << itemName 00374 //<< ", " << itemValue << ", " << itemType << ")" << endreq; 00375 current_HltCriteria->addItem(itemName, itemValue, itemType,m_idItem); 00376 m_idItem++; 00377 } 00378 //std::cout<<"***************************4"<<std::endl; 00379 // and crowl on ... 00380 MyFrame::buildSignatureList(helpNode, first); 00381 helpNode = helpNode->getNextSibling(); 00382 } 00383 //if(helpNode==0)std::cout<<"MyFrame::buildSignatureList() finished"<<std::endl; 00384 #undef XMLCF 00385 #undef XMLTF 00386 }
|
|
|
|
00028 { 00029 if (s_FrameInstance) delete s_FrameInstance; 00030 }
|
|
|
|
00395 { 00396 double returnValue(0); 00397 std::string helpString(XMLString::transcode(thisDOMString)); 00398 std::istringstream is(helpString); 00399 is >> returnValue; 00400 return returnValue; 00401 }
|
|
|
|
00186 { 00187 /*zoujh:MsgStream log(m_msgSvcProvider->msgSvc(), m_thisName); 00188 log << MSG::INFO << endreq; 00189 log << MSG::INFO << "***" << endreq; 00190 log << MSG::INFO << "Finalizing XML." << endreq; 00191 log << MSG::INFO << "***" << endreq;*/ 00192 //m_msgSvcProvider=0; 00193 // Call the XML termination method 00194 XMLPlatformUtils::Terminate(); 00195 }
|
|
|
|
00390 {
00391 return m_TableVector;
00392 }
|
|
|
|
00059 { 00060 //if(m_msgSvcProvider==0)m_msgSvcProvider = MessageSvcProvider::instance(); 00061 //MsgStream log(m_msgSvcProvider->msgSvc(), m_thisName); 00062 //MsgStream log(messageService(),name()); 00063 //std::cout<<"@@@@@@@@@@@@@@@@@@@1"<<std::endl; 00064 try { 00065 XMLPlatformUtils::Initialize(); 00066 //log << MSG::INFO << "MyFrame : Initialized XML!" << endreq; 00067 } 00068 00069 catch (const XMLException& toCatch) { 00070 //log << MSG::ERROR << "MyFrame : Init failed!" << endreq; 00071 exit(1); 00072 } 00073 //std::cout<<"@@@@@@@@@@@@@@@@@@@2"<<std::endl; 00074 // Instantiate DOM parser for signature XML file. 00075 XercesDOMParser* signatureParser = new XercesDOMParser; 00076 signatureParser->setValidationScheme(XercesDOMParser::Val_Always); // optional. 00077 signatureParser->setDoNamespaces(true); // optional 00078 00079 // Instantiate DOM parser for sequence XML file. 00080 XercesDOMParser* sequenceParser = new XercesDOMParser; 00081 sequenceParser->setValidationScheme(XercesDOMParser::Val_Always); // optional. 00082 sequenceParser->setDoNamespaces(true); // optional 00083 00084 // Now try to parse. 00085 try { 00086 signatureParser->parse(signatureFile.c_str()); 00087 //zoujh:log << MSG::INFO << "Parsing " << signatureFile.c_str() << endreq; 00088 00089 sequenceParser->parse(sequenceFile.c_str()); 00090 //zoujh:log << MSG::INFO << "Parsing " << sequenceFile.c_str() << endreq; 00091 } 00092 00093 catch (const XMLException& toCatch) { 00094 //log << MSG::ERROR << "Error 1" << endreq; 00095 exit(1); 00096 } 00097 catch (const DOMException& toCatch) { 00098 //log << MSG::ERROR << "Error 4" << endreq; 00099 XMLPlatformUtils::Terminate(); 00100 exit(1); 00101 } 00102 catch (...) { 00103 //log << MSG::ERROR << "Error 5" << endreq; 00104 XMLPlatformUtils::Terminate(); 00105 exit(1); 00106 } 00107 //std::cout<<"@@@@@@@@@@@@@@@@@@@3"<<std::endl; 00108 // Get document handle. 00109 m_Sequence_DocNode = sequenceParser->getDocument(); 00110 m_Signature_DocNode = signatureParser->getDocument(); 00111 //std::cout<<"1@@@@@@@@@@@@@@@@@@@"<<m_SequenceVec.size()<<std::endl; 00112 //std::cout<<"2@@@@@@@@@@@@@@@@@@@"<<m_SignatureVec.size()<<std::endl; 00113 //std::cout<<"3@@@@@@@@@@@@@@@@@@@"<<m_TableVector.size()<<std::endl; 00114 if(m_first){ 00115 m_first=false; 00116 } 00117 else{ 00118 for (unsigned int i = 0; i < m_SignatureVec.size(); i++) delete m_SignatureVec[i]; 00119 for (unsigned int j = 0; j < m_SequenceVec.size(); j++) delete m_SequenceVec[j]; 00120 m_SignatureVec.clear(); 00121 m_SequenceVec.clear(); 00122 m_TableVector.clear(); 00123 m_idCriteria=0; 00124 m_idSignature=0; 00125 m_idSequence=0; 00126 } 00127 //std::cout<<"1@@@@@@@@@@@@@@@@@@@"<<m_SequenceVec.size()<<std::endl; 00128 //std::cout<<"2@@@@@@@@@@@@@@@@@@@"<<m_SignatureVec.size()<<std::endl; 00129 //std::cout<<"3@@@@@@@@@@@@@@@@@@@"<<m_TableVector.size()<<std::endl; 00130 //std::vector<Sequence*> tmp1(0); 00131 //m_SequenceVec=tmp1; 00132 //std::cout<<"1@@@@@@@@@@@@@@@@@@@"<<m_SequenceVec.size()<<std::endl; 00133 //std::vector<Signature*> tmp2(0); 00134 //m_SignatureVec=tmp2; 00135 //std::cout<<"2@@@@@@@@@@@@@@@@@@@"<<m_SignatureVec.size()<<std::endl; 00136 //std::vector<std::pair<Signature*,Sequence*> > tmp3(0); 00137 //m_TableVector=tmp3; 00138 //std::cout<<"3@@@@@@@@@@@@@@@@@@@"<<m_TableVector.size()<<std::endl; 00139 // Build global sequence list (and print it). 00140 buildSequenceList(m_Sequence_DocNode, true); 00141 //std::cout<<"1@@@@@@@@@@@@@@@@@@@"<<m_SequenceVec.size()<<std::endl; 00142 //std::vector<Sequence*>::iterator iter=m_SequenceVec.begin(); 00143 //for(;iter!=m_SequenceVec.end();iter++){ 00144 // std::cout<< "@@@@@@@@"<<((*iter)->getSeqID())<<std::endl; 00145 //} 00146 //for (unsigned int i = 0; i < m_SequenceVec.size(); i++) { 00147 // std::string seqId = m_SequenceVec[i]->getSeqID(); 00148 // std::cout<< "@@@@@@@@"<<seqId<<std::endl; 00149 //} 00150 // Build global signature list (and print it). 00151 buildSignatureList(m_Signature_DocNode, true); 00152 //std::cout<<"2@@@@@@@@@@@@@@@@@@@"<<m_SignatureVec.size()<<std::endl; 00153 //m_Signature_DocNode->release(); 00154 //m_Sequence_DocNode->release(); 00155 delete sequenceParser; 00156 delete signatureParser; 00157 //std::cout<<"@@@@@@@@@@@@@@@@@@@6"<<std::endl; 00158 makeTableVector(); 00159 //std::cout<<"3@@@@@@@@@@@@@@@@@@@"<<m_TableVector.size()<<std::endl; 00160 m_first=false; 00161 std::cout << "MyFrame init() succuss" << "criteria num=" << m_idCriteria << std::endl; 00162 }
|
|
|
|
00022 { 00023 if(s_FrameInstance == 0) { 00024 s_FrameInstance = new MyFrame; 00025 } 00026 return s_FrameInstance; 00027 }
|
|
|
|
00165 { 00166 //MsgStream log(m_msgSvcProvider->msgSvc(), m_thisName); 00167 00168 for (unsigned int i = 0; i < m_SequenceVec.size(); i++) { 00169 std::string seqId = m_SequenceVec[i]->getSeqID(); 00170 bool matched = false; 00171 for (unsigned int j = 0; j < m_SignatureVec.size(); j++) { 00172 if (m_SignatureVec[j]->label() == m_SequenceVec[i]->getSeqID()) { 00173 m_TableVector.push_back(std::make_pair(m_SignatureVec[j], m_SequenceVec[i])); 00174 matched = true; 00175 break; 00176 } 00177 } 00178 if (!matched) { 00179 //log << MSG::ERROR << "No matched Signature to Sequence(" << seqId << ")" << endreq; 00180 exit(1); 00181 } 00182 } 00183 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|