The Gaudi Framework  master (ff829712)
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)
 
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::ostream & print (std::ostream &os, bool tableFormat) const override
 prints the counter to a stream
 
MsgStreamprint (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 MsgStreamprint (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)
 
GenericAccumulatoroperator= (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)
 
 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 InputType by)
 
GenericAccumulatoroperator= (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::Hubm_monitoringHub { nullptr }
 
const CommonMessagingBaselogger { 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)
 
 GenericAccumulator (unsigned long in)
 
void reset (unsigned long in)
 
auto rawValue () const
 
- 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)
 
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 1160 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 1164 of file Accumulators.h.

1165 : m_monitoringHub{ &o->serviceLocator()->monitoringHub() }, logger( o ), msg( ms ), max( nMax ) {
1166 m_monitoringHub->registerEntity( o->name(), ms, typeString, *this );
1167 }
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 1179 of file Accumulators.h.

1179 {
1180 if ( m_monitoringHub ) m_monitoringHub->removeEntity( *this );
1181 }

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

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

1197 {
1198 return { j.at( "msg" ).get<std::string>(), j.at( "max" ).get<unsigned long>(),
1199 j.at( "nEntries" ).get<unsigned long>() };
1200 }

◆ log()

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

Definition at line 1210 of file Accumulators.h.

1210 {
1211 if ( this->value() <= max && logger ) {
1212 if ( this->value() == max ) {
1213 logger->msgStream( level ) << "Suppressing message: " << std::quoted( msg, '\'' ) << endmsg;
1214 } else {
1215 logger->msgStream( level ) << msg << endmsg;
1216 }
1217 }
1218 }

◆ operator++()

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

Definition at line 1168 of file Accumulators.h.

1168 {
1169 ( *this ) += true;
1170 return *this;
1171 }

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

874{ 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 1188 of file Accumulators.h.

1188{ 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 873 of file Accumulators.h.

873{ 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 & ,
bool tableFormat ) const
inlineoverridevirtual

prints the counter to a stream

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 1187 of file Accumulators.h.

1187{ 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 1183 of file Accumulators.h.

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

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

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

Friends And Related Symbol Documentation

◆ mergeAndReset

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

Definition at line 1191 of file Accumulators.h.

1191{ 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 1190 of file Accumulators.h.

1190{ 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 1192 of file Accumulators.h.

1192 {
1193 j = { { "type", c.typeString }, { "empty", c.value() == 0 },
1194 { "nEntries", c.value() }, { "level", level },
1195 { "max", c.max }, { "msg", c.msg } };
1196 }

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

1207{ 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 1206 of file Accumulators.h.

1206{ nullptr };

◆ max

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

Definition at line 1209 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 1208 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 1162 of file Accumulators.h.

1162{ "counter:MsgCounter" };

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