CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
sistrip::WarningSummary Class Reference

#include <WarningSummary.h>

Public Member Functions

void add (const std::string &message, const std::string &details="")
 
void printSummary () const
 
 WarningSummary (const std::string &category, const std::string &name, bool debug=false)
 

Private Attributes

std::string m_category
 
bool m_debug
 
std::string m_name
 
std::map< std::string, std::size_t > m_warnings
 

Detailed Description

Definition at line 8 of file WarningSummary.h.

Constructor & Destructor Documentation

sistrip::WarningSummary::WarningSummary ( const std::string &  category,
const std::string &  name,
bool  debug = false 
)
inline

Member Function Documentation

void sistrip::WarningSummary::add ( const std::string &  message,
const std::string &  details = "" 
)

Definition at line 6 of file WarningSummary.cc.

References begin, end, B2GTnPMonitor_cfi::item, m_category, m_debug, and m_warnings.

Referenced by sistrip::RawToDigiUnpacker::createDigis(), sistrip::DigiToRaw::createFedBuffers_(), counter.Counter::register(), SequenceTypes.Task::remove(), SequenceTypes.Task::replace(), and WarningSummary().

6  {
7  const auto wIt = std::find_if(
8  std::begin(m_warnings), std::end(m_warnings), [&message](const std::pair<std::string, std::size_t>& item) {
9  return item.first == message;
10  });
11  if (std::end(m_warnings) == wIt) {
12  m_warnings.emplace(message, 1);
13  edm::LogWarning(m_category) << message << ": " << details
14  << (m_debug ? ""
15  : "\nNote: further warnings of this type will be suppressed (this can be "
16  "changed by enabling debugging printout)");
17  } else {
18  ++(wIt->second);
19  if (m_debug) {
20  edm::LogWarning(m_category) << message << ": " << details;
21  }
22  }
23 }
std::map< std::string, std::size_t > m_warnings
Definition: helper.h:70
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
void sistrip::WarningSummary::printSummary ( ) const

Definition at line 25 of file WarningSummary.cc.

References m_category, m_name, and m_warnings.

Referenced by WarningSummary().

25  {
26  if (!m_warnings.empty()) {
27  std::stringstream message;
28  message << m_name << " warnings:";
29  for (const auto& warnAndCount : m_warnings) {
30  message << std::endl << warnAndCount.first << " (" << warnAndCount.second << ")";
31  }
32  edm::LogWarning(m_category) << message.str();
33  }
34 }
std::map< std::string, std::size_t > m_warnings

Member Data Documentation

std::string sistrip::WarningSummary::m_category
private

Definition at line 18 of file WarningSummary.h.

Referenced by add(), and printSummary().

bool sistrip::WarningSummary::m_debug
private

Definition at line 17 of file WarningSummary.h.

Referenced by add().

std::string sistrip::WarningSummary::m_name
private

Definition at line 19 of file WarningSummary.h.

Referenced by printSummary().

std::map<std::string, std::size_t> sistrip::WarningSummary::m_warnings
private

Definition at line 20 of file WarningSummary.h.

Referenced by add(), and printSummary().