The Gaudi Framework  v36r9 (fd2bdac3)
Gaudi::Accumulators::MsgCounter< level, Atomicity > Class Template Reference

#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Accumulators.h>

Inheritance diagram for Gaudi::Accumulators::MsgCounter< level, Atomicity >:
Collaboration diagram for Gaudi::Accumulators::MsgCounter< level, Atomicity >:

Public Member Functions

template<typename OWNER >
 MsgCounter (OWNER *o, std::string const &ms, unsigned long nMax=10)
 
template<typename OWNER >
 MsgCounter (OWNER *o, std::string const &ms, int nMax)
 
MsgCounteroperator++ ()
 
MsgCounteroperator+= (const bool by)
 
 MsgCounter (MsgCounter const &)=delete
 
MsgCounteroperator= (MsgCounter const &)=delete
 
 ~MsgCounter ()
 
template<typename stream >
stream & printImpl (stream &o, bool tableFormat) const
 
std::ostreamprint (std::ostream &os, bool tableFormat) const override
 prints the counter to a stream More...
 
MsgStreamprint (MsgStream &os, bool tableFormat) const override
 
bool toBePrinted () const override
 hint whether we should print that counter or not. More...
 
virtual nlohmann::json toJSON () const override
 Basic JSON export for Gaudi::Monitoring::Hub support. More...
 
virtual std::ostreamprint (std::ostream &, bool tableFormat=false) const=0
 prints the counter to a stream More...
 
virtual MsgStreamprint (MsgStream &, bool tableFormat=true) const=0
 
virtual std::ostreamprint (std::ostream &o, std::string_view tag) const
 prints the counter to a stream in table format, with the given tag More...
 
virtual MsgStreamprint (MsgStream &o, std::string_view tag) const
 
- Public Member Functions inherited from Gaudi::Accumulators::PrintableCounter
 PrintableCounter ()=default
 
virtual ~PrintableCounter ()=default
 destructor More...
 
template<typename stream >
stream & printImpl (stream &s, std::string_view tag) const
 
virtual std::ostreamprint (std::ostream &o, std::string_view tag) const
 prints the counter to a stream in table format, with the given tag More...
 
virtual MsgStreamprint (MsgStream &o, std::string_view tag) const
 
std::string toString () const
 get a string representation More...
 
- Public Member Functions inherited from Gaudi::Accumulators::GenericAccumulator< InputTypeT, InnerType, Atomicity, InputTransform, OutputTransform, ValueHandler >
GenericAccumulator operator+= (const InputType by)
 
 GenericAccumulator ()=default
 
template<atomicity ato, typename VH >
 GenericAccumulator (construct_empty_t, const GenericAccumulator< InputType, InnerType, ato, InputTransform, OutputTransform, VH > &)
 constructor of an empty GenericAccumulator, copying the (non existent) config from another GenericAccumulator More...
 
template<typename... Args>
 GenericAccumulator (std::in_place_t, Args &&... args)
 
 GenericAccumulator (const GenericAccumulator &other)
 
GenericAccumulatoroperator= (const GenericAccumulator &other)
 
OutputType value () const
 
void reset ()
 
template<atomicity ato, typename VH >
void mergeAndReset (GenericAccumulator< InputType, InnerType, ato, InputTransform, OutputTransform, VH > &&other)
 
template<atomicity ato, typename VH >
void operator+ (GenericAccumulator< InputType, InnerType, ato, InputTransform, OutputTransform, VH > &&other)
 

Static Public Member Functions

static MsgCounter fromJSON (const nlohmann::json &j)
 

Static Public Attributes

static const std::string typeString { "counter:MsgCounter" }
 

Private Member Functions

 MsgCounter (std::string const &ms, unsigned long nMax, unsigned long count)
 
void log ()
 

Private Attributes

Monitoring::Hubm_monitoringHub { nullptr }
 
const CommonMessagingBaselogger { nullptr }
 
std::string msg
 
unsigned long max
 

Additional Inherited Members

- Public Types inherited from Gaudi::Accumulators::GenericAccumulator< InputTypeT, InnerType, Atomicity, InputTransform, OutputTransform, ValueHandler >
using InputType = InputTypeT
 
using OutputType = std::decay_t< std::result_of_t< OutputTransform(InnerType)> >
 
using InternalType = InnerType
 
using JSONStringEntriesType = std::string
 
- Protected Member Functions inherited from Gaudi::Accumulators::GenericAccumulator< InputTypeT, InnerType, Atomicity, InputTransform, OutputTransform, ValueHandler >
 GenericAccumulator (InnerType in)
 
auto rawValue () const
 
void reset (InnerType in)
 
- Static Protected Member Functions inherited from Gaudi::Accumulators::GenericAccumulator< InputTypeT, InnerType, Atomicity, InputTransform, OutputTransform, ValueHandler >
static InnerType extractJSONData (const nlohmann::json &j, const JSONStringEntriesType &entries)
 

Detailed Description

template<MSG::Level level, atomicity Atomicity = atomicity::full>
class Gaudi::Accumulators::MsgCounter< level, Atomicity >

Definition at line 1125 of file Accumulators.h.

Constructor & Destructor Documentation

◆ MsgCounter() [1/4]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
template<typename OWNER >
Gaudi::Accumulators::MsgCounter< level, Atomicity >::MsgCounter ( OWNER *  o,
std::string const &  ms,
unsigned long  nMax = 10 
)
inline

Definition at line 1129 of file Accumulators.h.

1130  : m_monitoringHub{ &o->serviceLocator()->monitoringHub() }, logger( o ), msg( ms ), max( nMax ) {
1131  m_monitoringHub->registerEntity( o->name(), ms, typeString, *this );
1132  }

◆ MsgCounter() [2/4]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
template<typename OWNER >
Gaudi::Accumulators::MsgCounter< level, Atomicity >::MsgCounter ( OWNER *  o,
std::string const &  ms,
int  nMax 
)
inline

Definition at line 1134 of file Accumulators.h.

1134 : MsgCounter( o, ms, static_cast<unsigned long>( nMax ) ) {}

◆ MsgCounter() [3/4]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
Gaudi::Accumulators::MsgCounter< level, Atomicity >::MsgCounter ( MsgCounter< level, Atomicity > const &  )
delete

◆ ~MsgCounter()

template<MSG::Level level, atomicity Atomicity = atomicity::full>
Gaudi::Accumulators::MsgCounter< level, Atomicity >::~MsgCounter ( )
inline

Definition at line 1146 of file Accumulators.h.

1146  {
1147  if ( m_monitoringHub ) m_monitoringHub->removeEntity( *this );
1148  }

◆ MsgCounter() [4/4]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
Gaudi::Accumulators::MsgCounter< level, Atomicity >::MsgCounter ( std::string const &  ms,
unsigned long  nMax,
unsigned long  count 
)
inlineprivate

Definition at line 1171 of file Accumulators.h.

1172  : details::MsgCounter::MsgAccumulator<Atomicity>{ count }, msg( ms ), max( nMax ) {}

Member Function Documentation

◆ fromJSON()

template<MSG::Level level, atomicity Atomicity = atomicity::full>
static MsgCounter Gaudi::Accumulators::MsgCounter< level, Atomicity >::fromJSON ( const nlohmann::json &  j)
inlinestatic

Definition at line 1165 of file Accumulators.h.

1165  {
1166  return { j.at( "msg" ).get<std::string>(), j.at( "max" ).get<unsigned long>(),
1167  j.at( "nEntries" ).get<unsigned long>() };
1168  }

◆ log()

template<MSG::Level level, atomicity Atomicity = atomicity::full>
void Gaudi::Accumulators::MsgCounter< level, Atomicity >::log ( )
inlineprivate

Definition at line 1178 of file Accumulators.h.

1178  {
1179  if ( this->value() <= max && logger ) {
1180  if ( this->value() == max ) {
1181  logger->msgStream( level ) << "Suppressing message: " << std::quoted( msg, '\'' ) << endmsg;
1182  } else {
1183  logger->msgStream( level ) << msg << endmsg;
1184  }
1185  }
1186  }

◆ operator++()

template<MSG::Level level, atomicity Atomicity = atomicity::full>
MsgCounter& Gaudi::Accumulators::MsgCounter< level, Atomicity >::operator++ ( )
inline

Definition at line 1135 of file Accumulators.h.

1135  {
1136  ( *this ) += true;
1137  return *this;
1138  }

◆ operator+=()

template<MSG::Level level, atomicity Atomicity = atomicity::full>
MsgCounter& Gaudi::Accumulators::MsgCounter< level, Atomicity >::operator+= ( const bool  by)
inline

Definition at line 1139 of file Accumulators.h.

1139  {
1141  if ( by ) log();
1142  return *this;
1143  }

◆ operator=()

template<MSG::Level level, atomicity Atomicity = atomicity::full>
MsgCounter& Gaudi::Accumulators::MsgCounter< level, Atomicity >::operator= ( MsgCounter< level, Atomicity > const &  )
delete

◆ print() [1/6]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
virtual MsgStream& Gaudi::Accumulators::PrintableCounter::print

◆ print() [2/6]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
virtual MsgStream& Gaudi::Accumulators::PrintableCounter::print
inline

Definition at line 848 of file Accumulators.h.

848 { return printImpl( o, tag ); }

◆ print() [3/6]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
MsgStream& Gaudi::Accumulators::MsgCounter< level, Atomicity >::print ( MsgStream os,
bool  tableFormat 
) const
inlineoverridevirtual

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 1155 of file Accumulators.h.

1155 { return printImpl( os, tableFormat ); }

◆ print() [4/6]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
virtual std::ostream& Gaudi::Accumulators::PrintableCounter::print

prints the counter to a stream

◆ print() [5/6]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
virtual std::ostream& Gaudi::Accumulators::PrintableCounter::print
inline

prints the counter to a stream in table format, with the given tag

Definition at line 847 of file Accumulators.h.

847 { return printImpl( o, tag ); }

◆ print() [6/6]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
std::ostream& Gaudi::Accumulators::MsgCounter< level, Atomicity >::print ( std::ostream ,
bool  tableFormat 
) const
inlineoverridevirtual

prints the counter to a stream

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 1154 of file Accumulators.h.

1154 { return printImpl( os, tableFormat ); }

◆ printImpl()

template<MSG::Level level, atomicity Atomicity = atomicity::full>
template<typename stream >
stream& Gaudi::Accumulators::MsgCounter< level, Atomicity >::printImpl ( stream &  o,
bool  tableFormat 
) const
inline

Definition at line 1150 of file Accumulators.h.

1150  {
1151  return o << boost::format{ tableFormat ? "|%|10d| |" : "#=%|-7lu|" } % this->value();
1152  }

◆ toBePrinted()

template<MSG::Level level, atomicity Atomicity = atomicity::full>
bool Gaudi::Accumulators::MsgCounter< level, Atomicity >::toBePrinted ( ) const
inlineoverridevirtual

hint whether we should print that counter or not.

Typically empty counters may not be printed

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 1156 of file Accumulators.h.

1156 { return this->value() > 0; }

◆ toJSON()

template<MSG::Level level, atomicity Atomicity = atomicity::full>
virtual nlohmann::json Gaudi::Accumulators::MsgCounter< level, Atomicity >::toJSON ( ) const
inlineoverridevirtual

Basic JSON export for Gaudi::Monitoring::Hub support.

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 1157 of file Accumulators.h.

1157  {
1158  return { { "type", typeString },
1159  { "empty", this->value() == 0 },
1160  { "nEntries", this->value() },
1161  { "level", level },
1162  { "max", max },
1163  { "msg", msg } };
1164  }

Member Data Documentation

◆ logger

template<MSG::Level level, atomicity Atomicity = atomicity::full>
const CommonMessagingBase* Gaudi::Accumulators::MsgCounter< level, Atomicity >::logger { nullptr }
private

Definition at line 1175 of file Accumulators.h.

◆ m_monitoringHub

template<MSG::Level level, atomicity Atomicity = atomicity::full>
Monitoring::Hub* Gaudi::Accumulators::MsgCounter< level, Atomicity >::m_monitoringHub { nullptr }
private

Definition at line 1174 of file Accumulators.h.

◆ max

template<MSG::Level level, atomicity Atomicity = atomicity::full>
unsigned long Gaudi::Accumulators::MsgCounter< level, Atomicity >::max
private

Definition at line 1177 of file Accumulators.h.

◆ msg

template<MSG::Level level, atomicity Atomicity = atomicity::full>
std::string Gaudi::Accumulators::MsgCounter< level, Atomicity >::msg
private

Definition at line 1176 of file Accumulators.h.

◆ typeString

template<MSG::Level level, atomicity Atomicity = atomicity::full>
const std::string Gaudi::Accumulators::MsgCounter< level, Atomicity >::typeString { "counter:MsgCounter" }
inlinestatic

Definition at line 1127 of file Accumulators.h.


The documentation for this class was generated from the following file:
Gaudi::Accumulators::MsgCounter::logger
const CommonMessagingBase * logger
Definition: Accumulators.h:1175
Gaudi::Accumulators::MsgCounter::log
void log()
Definition: Accumulators.h:1178
std::string
STL class.
Gaudi::Accumulators::MsgCounter::m_monitoringHub
Monitoring::Hub * m_monitoringHub
Definition: Accumulators.h:1174
Gaudi::Accumulators::MsgCounter::MsgCounter
MsgCounter(OWNER *o, std::string const &ms, unsigned long nMax=10)
Definition: Accumulators.h:1129
Gaudi::Accumulators::MsgCounter::msg
std::string msg
Definition: Accumulators.h:1176
Gaudi::Units::ms
constexpr double ms
Definition: SystemOfUnits.h:154
Gaudi::Accumulators::GenericAccumulator::operator+=
GenericAccumulator operator+=(const InputType by)
Definition: Accumulators.h:447
std::string::at
T at(T... args)
Gaudi::Monitoring::Hub::registerEntity
void registerEntity(std::string c, std::string n, std::string t, T &ent)
Definition: MonitoringHub.h:163
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
Gaudi::Monitoring::Hub::removeEntity
void removeEntity(T &ent)
Definition: MonitoringHub.h:171
gaudirun.level
level
Definition: gaudirun.py:364
Gaudi::Accumulators::GenericAccumulator::value
OutputType value() const
Definition: Accumulators.h:464
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:81
Gaudi::Accumulators::MsgCounter::printImpl
stream & printImpl(stream &o, bool tableFormat) const
Definition: Accumulators.h:1150
Gaudi::Accumulators::MsgCounter::max
unsigned long max
Definition: Accumulators.h:1177
std::count
T count(T... args)
Gaudi::Accumulators::MsgCounter::typeString
static const std::string typeString
Definition: Accumulators.h:1127