The Gaudi Framework  master (3de0aae8)
Loading...
Searching...
No Matches
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)
MsgCounter & operator++ ()
MsgCounter & operator+= (const bool by)
 MsgCounter (MsgCounter const &)=delete
MsgCounter & operator= (MsgCounter const &)=delete
 ~MsgCounter ()
template<typename stream>
stream & printImpl (stream &o, bool tableFormat) const
std::ostream & print (std::ostream &os, bool tableFormat) const override
 prints the counter to a stream
MsgStream & print (MsgStream &os, bool tableFormat) const override
bool toBePrinted () const override
 hint whether we should print that counter or not.
virtual std::ostream & print (std::ostream &o, std::string_view tag) const
 prints the counter to a stream in table format, with the given tag
virtual MsgStream & print (MsgStream &o, std::string_view tag) const
Public Member Functions inherited from Gaudi::Accumulators::PrintableCounter
 PrintableCounter ()=default
virtual ~PrintableCounter ()=default
 destructor
template<typename stream>
stream & printImpl (stream &s, std::string_view tag) const
std::string toString () const
 get a string representation
Public Member Functions inherited from Gaudi::Accumulators::GenericAccumulator< bool, unsigned long, Atomicity, Identity, Identity, Handler< Atomicity > >
GenericAccumulator operator+= (const InputType by)
 GenericAccumulator ()=default
 GenericAccumulator (construct_empty_t, const GenericAccumulator< InputType, unsigned long, ato, Identity, Identity, VH > &)
 constructor of an empty GenericAccumulator, copying the (non existent) config from another GenericAccumulator
 GenericAccumulator (std::in_place_t, Args &&... args)
 GenericAccumulator (const GenericAccumulator &other)
GenericAccumulator & operator= (const GenericAccumulator &other)
OutputType value () const
void reset ()
void mergeAndReset (GenericAccumulator< InputType, unsigned long, ato, Identity, Identity, VH > &other)
void operator+ (GenericAccumulator< InputType, unsigned long, ato, Identity, Identity, 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::Hub * m_monitoringHub { nullptr }
const CommonMessagingBase * logger { nullptr }
std::string msg
unsigned long max

Friends

void reset (MsgCounter &c)
void mergeAndReset (MsgCounter &c, MsgCounter &o)
void to_json (nlohmann::json &j, MsgCounter const &c)

Additional Inherited Members

Public Types inherited from Gaudi::Accumulators::GenericAccumulator< bool, unsigned long, Atomicity, Identity, Identity, Handler< Atomicity > >
using InputType
using OutputType
using InternalType
using JSONStringEntriesType
Protected Member Functions inherited from Gaudi::Accumulators::GenericAccumulator< bool, unsigned long, Atomicity, Identity, Identity, Handler< Atomicity > >
 GenericAccumulator (unsigned long in)
auto rawValue () const
void reset (unsigned long in)
Static Protected Member Functions inherited from Gaudi::Accumulators::GenericAccumulator< bool, unsigned long, Atomicity, Identity, Identity, Handler< Atomicity > >
static unsigned long 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 1192 of file Accumulators.h.

Constructor & Destructor Documentation

◆ MsgCounter() [1/3]

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

1197 : m_monitoringHub{ &o->serviceLocator()->monitoringHub() }, logger( o ), msg( ms ), max( nMax ) {
1198 m_monitoringHub->registerEntity( o->name(), ms, typeString, *this );
1199 }
static const std::string typeString
const CommonMessagingBase * logger

◆ MsgCounter() [2/3]

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

1211 {
1212 if ( m_monitoringHub ) m_monitoringHub->removeEntity( *this );
1213 }

◆ MsgCounter() [3/3]

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

Member Function Documentation

◆ fromJSON()

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

Definition at line 1229 of file Accumulators.h.

1229 {
1230 return { j.at( "msg" ).get<std::string>(), j.at( "max" ).get<unsigned long>(),
1231 j.at( "nEntries" ).get<unsigned long>() };
1232 }

◆ log()

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

Definition at line 1242 of file Accumulators.h.

1242 {
1243 if ( this->value() <= max && logger ) {
1244 if ( this->value() == max ) {
1245 logger->msgStream( level ) << "Suppressing message: " << std::quoted( msg, '\'' ) << endmsg;
1246 } else {
1247 logger->msgStream( level ) << msg << endmsg;
1248 }
1249 }
1250 }

◆ operator++()

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

Definition at line 1200 of file Accumulators.h.

1200 {
1201 ( *this ) += true;
1202 return *this;
1203 }

◆ operator+=()

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

◆ operator=()

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

◆ print() [1/4]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
virtual MsgStream & Gaudi::Accumulators::PrintableCounter::print ( MsgStream & o,
std::string_view tag ) const
inlinevirtual

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 906 of file Accumulators.h.

906{ return printImpl( o, tag ); }
stream & printImpl(stream &o, bool tableFormat) const

◆ print() [2/4]

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

1220{ return printImpl( os, tableFormat ); }

◆ print() [3/4]

template<MSG::Level level, atomicity Atomicity = atomicity::full>
virtual std::ostream & Gaudi::Accumulators::PrintableCounter::print ( std::ostream & o,
std::string_view tag ) const
inlinevirtual

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

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 905 of file Accumulators.h.

905{ return printImpl( o, tag ); }

◆ print() [4/4]

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

prints the counter to a stream

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 1219 of file Accumulators.h.

1219{ 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 1215 of file Accumulators.h.

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

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

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

◆ mergeAndReset

template<MSG::Level level, atomicity Atomicity = atomicity::full>
void mergeAndReset ( MsgCounter< level, Atomicity > & c,
MsgCounter< level, Atomicity > & o )
friend

Definition at line 1223 of file Accumulators.h.

1223{ c.mergeAndReset( o ); }
friend void mergeAndReset(MsgCounter &c, MsgCounter &o)

◆ reset

template<MSG::Level level, atomicity Atomicity = atomicity::full>
void reset ( MsgCounter< level, Atomicity > & c)
friend

Definition at line 1222 of file Accumulators.h.

1222{ c.reset(); }
friend void reset(MsgCounter &c)

◆ to_json

template<MSG::Level level, atomicity Atomicity = atomicity::full>
void to_json ( nlohmann::json & j,
MsgCounter< level, Atomicity > const & c )
friend

Definition at line 1224 of file Accumulators.h.

1224 {
1225 j = { { "type", c.typeString }, { "empty", c.value() == 0 },
1226 { "nEntries", c.value() }, { "level", level },
1227 { "max", c.max }, { "msg", c.msg } };
1228 }

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

1239{ nullptr };

◆ m_monitoringHub

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

Definition at line 1238 of file Accumulators.h.

1238{ nullptr };

◆ max

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

Definition at line 1241 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 1240 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 1194 of file Accumulators.h.

1194{ "counter:MsgCounter" };

The documentation for this class was generated from the following file: