#include <EventFilter/StorageManager/interface/InitMsgCollection.h>
Public Member Functions | |
bool | addIfUnique (InitMsgView const &initMsgView) |
Adds the specified INIT message to the collection if it has a unique HLT output module label. | |
void | clear () |
Removes all entries from the collection. | |
InitMsgSharedPtr | getElementAt (unsigned int index) |
Returns a shared pointer to the requested element in the collection or an empty pointer if the requested index if out of bounds. | |
InitMsgSharedPtr | getElementForOutputModule (std::string requestedOMLabel) |
Fetches the single INIT message that matches the requested HLT output module label. | |
InitMsgSharedPtr | getFullCollection () |
InitMsgSharedPtr | getLastElement () |
Returns a shared pointer to the last element in the collection or an empty pointer if the collection has no elements. | |
std::string | getOutputModuleName (uint32 outputModuleId) |
Returns the name of the output module with the specified module ID, or an empty string of the specified module ID is not known. | |
std::string | getSelectionHelpString () |
Returns a string with information on which selections are available. | |
InitMsgCollection () | |
InitMsgCollection constructor. | |
int | size () |
Returns the number of INIT messages in the collection. | |
~InitMsgCollection () | |
InitMsgCollection destructor. | |
Static Public Member Functions | |
static std::string | stringsToText (Strings const &list, unsigned int maxCount=0) |
Creates a single text string from the elements in the specified list of strings. | |
Private Member Functions | |
void | add (InitMsgView const &initMsgView) |
Adds the specified INIT message to the collection (unconditionally). | |
Private Attributes | |
std::vector< InitMsgSharedPtr > | initMsgList_ |
boost::mutex | listLock_ |
std::map< uint32, std::string > | outModNameTable_ |
InitMsgSharedPtr | serializedFullSet_ |
Definition at line 23 of file InitMsgCollection.h.
InitMsgCollection::InitMsgCollection | ( | ) |
InitMsgCollection constructor.
Definition at line 28 of file InitMsgCollection.cc.
References lat::endl(), FDEBUG, Header::INIT_SET, initMsgList_, outModNameTable_, and serializedFullSet_.
00029 { 00030 FDEBUG(5) << "Executing constructor for InitMsgCollection" << std::endl; 00031 initMsgList_.clear(); 00032 outModNameTable_.clear(); 00033 00034 serializedFullSet_.reset(new InitMsgBuffer(2 * sizeof(Header))); 00035 OtherMessageBuilder fullSetMsg(&(*serializedFullSet_)[0], Header::INIT_SET); 00036 }
InitMsgCollection::~InitMsgCollection | ( | ) |
InitMsgCollection destructor.
Definition at line 41 of file InitMsgCollection.cc.
References lat::endl(), and FDEBUG.
void InitMsgCollection::add | ( | InitMsgView const & | initMsgView | ) | [private] |
Adds the specified INIT message to the collection (unconditionally).
initMsgView | The INIT message to add to the collection. |
Definition at line 574 of file InitMsgCollection.cc.
00577 { 00578 // add the message to the internal list 00579 InitMsgSharedPtr serializedProds(new InitMsgBuffer(initMsgView.size())); 00580 initMsgList_.push_back(serializedProds); 00581 std::copy(initMsgView.startAddress(), 00582 initMsgView.startAddress()+initMsgView.size(), 00583 &(*serializedProds)[0]); 00584 00585 // add the module ID name to the name map 00586 outModNameTable_[initMsgView.outputModuleId()] = 00587 initMsgView.outputModuleLabel(); 00588 00589 // calculate various sizes needed for adding the message to 00590 // the serialized version of the full set 00591 OtherMessageView fullSetView(&(*serializedFullSet_)[0]); 00592 unsigned int oldBodySize = fullSetView.bodySize(); 00593 unsigned int oldBufferSize = serializedFullSet_->size(); 00594 unsigned int newBodySize = oldBodySize + initMsgView.size(); 00595 unsigned int newBufferSize = oldBufferSize + initMsgView.size(); 00596 00597 // add the message to the serialized full set of messages 00598 serializedFullSet_->resize(newBufferSize); 00599 OtherMessageBuilder fullSetMsg(&(*serializedFullSet_)[0], 00600 Header::INIT_SET, 00601 newBodySize); 00602 uint8 *copyPtr = fullSetMsg.msgBody() + oldBodySize; 00603 std::copy(initMsgView.startAddress(), 00604 initMsgView.startAddress()+initMsgView.size(),
bool InitMsgCollection::addIfUnique | ( | InitMsgView const & | initMsgView | ) |
Adds the specified INIT message to the collection if it has a unique HLT output module label.
If we already have an INIT message with the same output module label as the input INIT message, the duplicate message is *not* added to the collection, and this method returns false.
If the output module label inside the INIT message is empty, an exception is thrown.
initMsgView | The INIT message to be added to the collection. |
cms::Exception | if one of the consistency checks fails. |
Definition at line 307 of file InitMsgCollection.cc.
00310 { 00311 boost::mutex::scoped_lock sl(listLock_); 00312 00313 // test the output module label for validity 00314 std::string inputOMLabel = initMsgView.outputModuleLabel(); 00315 std::string trimmedOMLabel = boost::algorithm::trim_copy(inputOMLabel); 00316 if (trimmedOMLabel.empty()) { 00317 throw cms::Exception("InitMsgCollection", "addIfUnique:") 00318 << "Invalid INIT message: the HLT output module label is empty!" 00319 << std::endl; 00320 } 00321 00322 // initially, assume that we will want to include the new message 00323 bool addToList = true; 00324 00325 // if this is the first INIT message that we've seen, we just add it 00326 if (initMsgList_.size() == 0) { 00327 this->add(initMsgView); 00328 } 00329 00330 // if this is a subsequent INIT message, check if it is unique 00331 else { 00332 00333 // loop over the existing messages 00334 std::vector<InitMsgSharedPtr>::const_iterator msgIter; 00335 for (msgIter = initMsgList_.begin(); msgIter != initMsgList_.end(); msgIter++) { 00336 InitMsgSharedPtr serializedProds = *msgIter; 00337 InitMsgView existingInitMsg(&(*serializedProds)[0]); 00338 std::string existingOMLabel = existingInitMsg.outputModuleLabel(); 00339 00340 // check if the output module labels match 00341 if (inputOMLabel == existingOMLabel) { 00342 // we already have a copy of the INIT message 00343 addToList = false; 00344 break; 00345 } 00346 } 00347 00348 // if we've found no problems, add the new message to the collection 00349 if (addToList) { 00350 this->add(initMsgView); 00351 } 00352 } 00353 00354 // indicate whether the message was added or not
Removes all entries from the collection.
Definition at line 455 of file InitMsgCollection.cc.
00458 { 00459 boost::mutex::scoped_lock sl(listLock_); 00460 initMsgList_.clear();
InitMsgSharedPtr InitMsgCollection::getElementAt | ( | unsigned int | index | ) |
Returns a shared pointer to the requested element in the collection or an empty pointer if the requested index if out of bounds.
index | The index of the requested element. |
Definition at line 441 of file InitMsgCollection.cc.
00444 { 00445 boost::mutex::scoped_lock sl(listLock_); 00446 00447 InitMsgSharedPtr ptrToElement; 00448 if (index >= 0 && index < initMsgList_.size()) { 00449 ptrToElement = initMsgList_[index]; 00450 }
InitMsgSharedPtr InitMsgCollection::getElementForOutputModule | ( | std::string | requestedOMLabel | ) |
Fetches the single INIT message that matches the requested HLT output module label.
If no messages match the request, an empty pointer is returned.
If the requested HLT output module label is empty, and there is only one INIT message in the collection, that INIT message is returned. However, if there is more than one INIT message in the collection, and an empty request is passed into this method, an exception will be thrown. (How can we decide which is the best match when we have nothing to work with?)
requestedOMLabel | The HLT output module label of the INIT message to be returned. |
cms::Exception | if the input HLT output module label string is empty and there is more than one INIT message in the collection. |
Definition at line 376 of file InitMsgCollection.cc.
00379 { 00380 boost::mutex::scoped_lock sl(listLock_); 00381 InitMsgSharedPtr serializedProds; 00382 00383 // handle the special case of an empty request 00384 // (If we want to use class methods to check the collection size and 00385 // fetch the last element in the collection, then we would need to 00386 // switch to recursive mutexes...) 00387 if (requestedOMLabel.empty()) { 00388 if (initMsgList_.size() == 1) { 00389 serializedProds = initMsgList_.back(); 00390 } 00391 else if (initMsgList_.size() > 1) { 00392 std::string msg = "Invalid INIT message lookup: the requested "; 00393 msg.append("HLT output module label is empty but there are multiple "); 00394 msg.append("HLT output modules to choose from."); 00395 throw cms::Exception("InitMsgCollection", "getElementForOutputModule:") 00396 << msg << std::endl; 00397 } 00398 } 00399 00400 else { 00401 // loop over the existing messages 00402 std::vector<InitMsgSharedPtr>::const_iterator msgIter; 00403 for (msgIter = initMsgList_.begin(); msgIter != initMsgList_.end(); msgIter++) { 00404 InitMsgSharedPtr workingMessage = *msgIter; 00405 InitMsgView existingInitMsg(&(*workingMessage)[0]); 00406 std::string existingOMLabel = existingInitMsg.outputModuleLabel(); 00407 00408 // check if the output module labels match 00409 if (requestedOMLabel == existingOMLabel) { 00410 serializedProds = workingMessage; 00411 break; 00412 } 00413 } 00414 } 00415
InitMsgSharedPtr stor::InitMsgCollection::getFullCollection | ( | ) | [inline] |
Definition at line 46 of file InitMsgCollection.h.
References serializedFullSet_.
00046 { return serializedFullSet_; }
InitMsgSharedPtr InitMsgCollection::getLastElement | ( | ) |
Returns a shared pointer to the last element in the collection or an empty pointer if the collection has no elements.
Definition at line 423 of file InitMsgCollection.cc.
00426 { 00427 boost::mutex::scoped_lock sl(listLock_); 00428 00429 InitMsgSharedPtr ptrToLast; 00430 if (initMsgList_.size() > 0) { 00431 ptrToLast = initMsgList_.back(); 00432 }
std::string InitMsgCollection::getOutputModuleName | ( | uint32 | outputModuleId | ) |
Returns the name of the output module with the specified module ID, or an empty string of the specified module ID is not known.
Definition at line 528 of file InitMsgCollection.cc.
00531 { 00532 if (outModNameTable_.find(outputModuleId) == outModNameTable_.end()) 00533 { 00534 return ""; 00535 } 00536 else { 00537 return outModNameTable_[outputModuleId];
std::string InitMsgCollection::getSelectionHelpString | ( | ) |
Returns a string with information on which selections are available.
Definition at line 478 of file InitMsgCollection.cc.
Referenced by edm::ServiceManager::manageInitMsg().
00481 { 00482 // nothing much we can say if the collection is empty 00483 if (initMsgList_.size() == 0) { 00484 return "No information is available about the available triggers."; 00485 } 00486 00487 // list the full set of available triggers 00488 std::string helpString; 00489 helpString.append("The full list of trigger paths is the following:"); 00490 00491 // we can just use the list from the first entry since all 00492 // subsequent entries are forced to be the same 00493 InitMsgSharedPtr serializedProds = initMsgList_[0]; 00494 InitMsgView existingInitMsg(&(*serializedProds)[0]); 00495 Strings existingTriggerList; 00496 existingInitMsg.hltTriggerNames(existingTriggerList); 00497 for (unsigned int idx = 0; idx < existingTriggerList.size(); idx++) { 00498 helpString.append("\n " + existingTriggerList[idx]); 00499 } 00500 00501 // list the output modules (INIT messages) 00502 helpString.append("\nThe registered HLT output modules and their "); 00503 helpString.append("trigger selections are the following:"); 00504 00505 // loop over the existing messages 00506 std::vector<InitMsgSharedPtr>::const_iterator msgIter; 00507 for (msgIter = initMsgList_.begin(); msgIter != initMsgList_.end(); msgIter++) { 00508 serializedProds = *msgIter; 00509 InitMsgView workingInitMsg(&(*serializedProds)[0]); 00510 helpString.append("\n *** Output module \""); 00511 helpString.append(workingInitMsg.outputModuleLabel()); 00512 helpString.append("\" ***"); 00513 Strings workingSelectionList; 00514 workingInitMsg.hltTriggerSelections(workingSelectionList); 00515 for (unsigned int idx = 0; idx < workingSelectionList.size(); idx++) { 00516 helpString.append("\n " + workingSelectionList[idx]); 00517 } 00518 } 00519 00520 // return the result
Returns the number of INIT messages in the collection.
Definition at line 467 of file InitMsgCollection.cc.
std::string InitMsgCollection::stringsToText | ( | Strings const & | list, | |
unsigned int | maxCount = 0 | |||
) | [static] |
Creates a single text string from the elements in the specified list of strings.
The specified maximum number of elements are included, however a zero value for the maximum number will include all elements.
list | the list of strings to include (vector of strings); | |
maxCount | the maximum number of list elements to include. |
Definition at line 549 of file InitMsgCollection.cc.
Referenced by stor::SMProxyServer::eventServerWebPage(), and stor::StorageManager::eventServerWebPage().
00553 { 00554 std::string resultString = ""; 00555 unsigned int elementCount = list.size(); 00556 if (maxCount > 0 && maxCount < elementCount) {elementCount = maxCount;} 00557 for (unsigned int idx = 0; idx < elementCount; idx++) 00558 { 00559 resultString.append(list[idx]); 00560 if (idx < (elementCount-1)) { 00561 resultString.append(", "); 00562 } 00563 } 00564 if (elementCount < list.size()) 00565 { 00566 resultString.append(", ..."); 00567 }
std::vector<InitMsgSharedPtr> stor::InitMsgCollection::initMsgList_ [private] |
Definition at line 65 of file InitMsgCollection.h.
std::map<uint32, std::string> stor::InitMsgCollection::outModNameTable_ [private] |
Definition at line 61 of file InitMsgCollection.h.
Referenced by getFullCollection(), and InitMsgCollection().