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

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

Definition at line 22 of file WarningSummary.cc.

References m_category, m_name, and m_warnings.

Referenced by WarningSummary().

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

Member Data Documentation

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

Definition at line 21 of file WarningSummary.h.

Referenced by add(), and printSummary().

bool sistrip::WarningSummary::m_debug
private

Definition at line 20 of file WarningSummary.h.

Referenced by add().

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

Definition at line 22 of file WarningSummary.h.

Referenced by printSummary().

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

Definition at line 23 of file WarningSummary.h.

Referenced by add(), and printSummary().