The Gaudi Framework  v36r7 (7f57a304)
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 1118 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 1122 of file Accumulators.h.

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

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

1137 { 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 1154 of file Accumulators.h.

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

◆ log()

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

Definition at line 1165 of file Accumulators.h.

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

◆ operator++()

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

Definition at line 1126 of file Accumulators.h.

1126  {
1127  ( *this ) += true;
1128  return *this;
1129  }

◆ operator+=()

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

Definition at line 1130 of file Accumulators.h.

1130  {
1132  if ( by ) log();
1133  return *this;
1134  }

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

846 { 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 1144 of file Accumulators.h.

1144 { 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 845 of file Accumulators.h.

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

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

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

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

1145 { 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 1146 of file Accumulators.h.

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

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 1162 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 1161 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 1164 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 1163 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 1120 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:1162
Gaudi::Accumulators::MsgCounter::log
void log()
Definition: Accumulators.h:1165
std::string
STL class.
std::move
T move(T... args)
Gaudi::Accumulators::MsgCounter::m_monitoringHub
Monitoring::Hub & m_monitoringHub
Definition: Accumulators.h:1161
Gaudi::Accumulators::MsgCounter::MsgCounter
MsgCounter(OWNER *o, std::string const &ms, int nMax=10)
Definition: Accumulators.h:1122
Gaudi::Accumulators::MsgCounter::msg
std::string msg
Definition: Accumulators.h:1163
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:447
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: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:1139
Gaudi::Accumulators::MsgCounter::max
unsigned long max
Definition: Accumulators.h:1164
Gaudi::Accumulators::GenericAccumulator::extractJSONData
static InnerType extractJSONData(const nlohmann::json &j, const JSONStringEntriesType &entries)
Definition: Accumulators.h:478
Gaudi::Accumulators::MsgCounter::typeString
static const std::string typeString
Definition: Accumulators.h:1120