The Gaudi Framework  v36r4 (0a924e98)
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 (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

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

Constructor & Destructor Documentation

◆ MsgCounter() [1/2]

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

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

◆ MsgCounter() [2/2]

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

1134 { 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 1151 of file Accumulators.h.

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

◆ log()

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

Definition at line 1162 of file Accumulators.h.

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

◆ operator++()

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

Definition at line 1123 of file Accumulators.h.

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

◆ operator+=()

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

Definition at line 1127 of file Accumulators.h.

1127  {
1129  if ( by ) log();
1130  return *this;
1131  }

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

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

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

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

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

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

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

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

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

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 1159 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 1158 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 1161 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 1160 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 1117 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:1159
Gaudi::Accumulators::MsgCounter::log
void log()
Definition: Accumulators.h:1162
std::string
STL class.
std::move
T move(T... args)
Gaudi::Accumulators::MsgCounter::m_monitoringHub
Monitoring::Hub & m_monitoringHub
Definition: Accumulators.h:1158
Gaudi::Accumulators::MsgCounter::MsgCounter
MsgCounter(OWNER *o, std::string const &ms, int nMax=10)
Definition: Accumulators.h:1119
Gaudi::Accumulators::MsgCounter::msg
std::string msg
Definition: Accumulators.h:1160
gaudirun.c
c
Definition: gaudirun.py:525
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:136
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:144
gaudirun.level
level
Definition: gaudirun.py:364
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:1136
Gaudi::Accumulators::MsgCounter::max
unsigned long max
Definition: Accumulators.h:1161
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:1117