The Gaudi Framework  v36r1 (3e2fb5a8)
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, int nMax=10)
 
MsgCounteroperator++ ()
 
MsgCounteroperator+= (const bool by)
 
 ~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

void log ()
 

Private Attributes

Monitoring::Hubm_monitoringHub
 
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 >
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 1116 of file Accumulators.h.

Constructor & Destructor Documentation

◆ MsgCounter()

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 = 10 
)
inline

Definition at line 1120 of file Accumulators.h.

1121  : m_monitoringHub{o->serviceLocator()->monitoringHub()}, logger( o ), msg( ms ), max( nMax ) {
1122  m_monitoringHub.registerEntity( o->name(), std::move( ms ), typeString, *this );
1123  }

◆ ~MsgCounter()

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

Definition at line 1133 of file Accumulators.h.

1133 { m_monitoringHub.removeEntity( *this ); }

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 1150 of file Accumulators.h.

1150  {
1151  MsgCounter c = MsgCounter::extractJSONData( j, {"nEntries"} );
1152  c.msg = j.at( "msg" ).get<std::string>();
1153  c.max = j.at( "max" ).get<unsigned long>();
1154  }

◆ log()

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

Definition at line 1161 of file Accumulators.h.

1161  {
1162  if ( UNLIKELY( this->value() <= max ) && logger ) {
1163  if ( this->value() == max ) {
1164  logger->msgStream( level ) << "Suppressing message: " << std::quoted( msg, '\'' ) << endmsg;
1165  } else {
1166  logger->msgStream( level ) << msg << endmsg;
1167  }
1168  }
1169  }

◆ operator++()

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

Definition at line 1124 of file Accumulators.h.

1124  {
1125  ( *this ) += true;
1126  return *this;
1127  }

◆ operator+=()

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

Definition at line 1128 of file Accumulators.h.

1128  {
1130  if ( by ) log();
1131  return *this;
1132  }

◆ 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 842 of file Accumulators.h.

842 { 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 1140 of file Accumulators.h.

1140 { 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 841 of file Accumulators.h.

841 { 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 1139 of file Accumulators.h.

1139 { 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 1135 of file Accumulators.h.

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

◆ 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 1141 of file Accumulators.h.

1141 { 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 1142 of file Accumulators.h.

1142  {
1143  return {{"type", typeString},
1144  {"empty", this->value() == 0},
1145  {"nEntries", this->value()},
1146  {"level", level},
1147  {"max", max},
1148  {"msg", msg}};
1149  }

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 1158 of file Accumulators.h.

◆ m_monitoringHub

template<MSG::Level level, atomicity Atomicity = atomicity::full>
Monitoring::Hub& Gaudi::Accumulators::MsgCounter< level, Atomicity >::m_monitoringHub
private

Definition at line 1157 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 1160 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 1159 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 1118 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:1158
Gaudi::Accumulators::MsgCounter::log
void log()
Definition: Accumulators.h:1161
std::string
STL class.
std::move
T move(T... args)
Gaudi::Accumulators::MsgCounter::m_monitoringHub
Monitoring::Hub & m_monitoringHub
Definition: Accumulators.h:1157
Gaudi::Accumulators::MsgCounter::MsgCounter
MsgCounter(OWNER *o, std::string const &ms, int nMax=10)
Definition: Accumulators.h:1120
Gaudi::Accumulators::MsgCounter::msg
std::string msg
Definition: Accumulators.h:1159
gaudirun.c
c
Definition: gaudirun.py:509
Gaudi::Units::ms
constexpr double ms
Definition: SystemOfUnits.h:154
Gaudi::Accumulators::GenericAccumulator::operator+=
GenericAccumulator operator+=(const InputType by)
Definition: Accumulators.h:444
Gaudi::Monitoring::Hub::registerEntity
void registerEntity(std::string c, std::string n, std::string t, T &ent)
Definition: MonitoringHub.h:85
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:94
gaudirun.level
level
Definition: gaudirun.py:346
Gaudi::Accumulators::GenericAccumulator::value
OutputType value() const
Definition: Accumulators.h:461
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:1135
Gaudi::Accumulators::MsgCounter::max
unsigned long max
Definition: Accumulators.h:1160
Gaudi::Accumulators::GenericAccumulator::extractJSONData
static InnerType extractJSONData(const nlohmann::json &j, const JSONStringEntriesType &entries)
Definition: Accumulators.h:475
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:106
Gaudi::Accumulators::MsgCounter::typeString
static const std::string typeString
Definition: Accumulators.h:1118