The Gaudi Framework  v37r1 (a7f61348)
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)
 
template<typename OWNER >
 MsgCounter (OWNER *o, std::string const &ms, int nMax)
 
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 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

 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< 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 >
 GenericAccumulator (InnerType in)
 
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 1135 of file Accumulators.h.

Constructor & Destructor Documentation

◆ MsgCounter() [1/4]

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

1140  : m_monitoringHub{ &o->serviceLocator()->monitoringHub() }, logger( o ), msg( ms ), max( nMax ) {
1141  m_monitoringHub->registerEntity( o->name(), ms, typeString, *this );
1142  }

◆ MsgCounter() [2/4]

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

Definition at line 1144 of file Accumulators.h.

1144 : MsgCounter( o, ms, static_cast<unsigned long>( nMax ) ) {}

◆ MsgCounter() [3/4]

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

1156  {
1157  if ( m_monitoringHub ) m_monitoringHub->removeEntity( *this );
1158  }

◆ MsgCounter() [4/4]

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

1181  : details::MsgCounter::MsgAccumulator<Atomicity>{ count }, msg( ms ), max( nMax ) {}

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

1174  {
1175  return { j.at( "msg" ).get<std::string>(), j.at( "max" ).get<unsigned long>(),
1176  j.at( "nEntries" ).get<unsigned long>() };
1177  }

◆ log()

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

Definition at line 1187 of file Accumulators.h.

1187  {
1188  if ( this->value() <= max && logger ) {
1189  if ( this->value() == max ) {
1190  logger->msgStream( level ) << "Suppressing message: " << std::quoted( msg, '\'' ) << endmsg;
1191  } else {
1192  logger->msgStream( level ) << msg << endmsg;
1193  }
1194  }
1195  }

◆ operator++()

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

Definition at line 1145 of file Accumulators.h.

1145  {
1146  ( *this ) += true;
1147  return *this;
1148  }

◆ operator+=()

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

Definition at line 1149 of file Accumulators.h.

1149  {
1151  if ( by ) log();
1152  return *this;
1153  }

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

850 { 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 1165 of file Accumulators.h.

1165 { 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 849 of file Accumulators.h.

849 { 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 1164 of file Accumulators.h.

1164 { 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 1160 of file Accumulators.h.

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

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

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

Friends And Related Function Documentation

◆ mergeAndReset

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

Definition at line 1168 of file Accumulators.h.

1168 { c.mergeAndReset( o ); }

◆ reset

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

Definition at line 1167 of file Accumulators.h.

1167 { c.reset(); }

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

1169  {
1170  j = { { "type", c.typeString }, { "empty", c.value() == 0 },
1171  { "nEntries", c.value() }, { "level", level },
1172  { "max", c.max }, { "msg", c.msg } };
1173  }

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

◆ m_monitoringHub

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

Definition at line 1183 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 1186 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 1185 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 1137 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:1184
Gaudi::Accumulators::MsgCounter::log
void log()
Definition: Accumulators.h:1187
std::string
STL class.
Gaudi::Accumulators::MsgCounter::m_monitoringHub
Monitoring::Hub * m_monitoringHub
Definition: Accumulators.h:1183
Gaudi::Accumulators::MsgCounter::MsgCounter
MsgCounter(OWNER *o, std::string const &ms, unsigned long nMax=10)
Definition: Accumulators.h:1139
Gaudi::Accumulators::MsgCounter::msg
std::string msg
Definition: Accumulators.h:1185
gaudirun.c
c
Definition: gaudirun.py:527
Gaudi::Units::ms
constexpr double ms
Definition: SystemOfUnits.h:154
Gaudi::Accumulators::GenericAccumulator::operator+=
GenericAccumulator operator+=(const InputType by)
Definition: Accumulators.h:449
ProduceConsume.j
j
Definition: ProduceConsume.py:101
Gaudi::Monitoring::Hub::registerEntity
void registerEntity(std::string c, std::string n, std::string t, T &ent)
Definition: MonitoringHub.h:174
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:182
gaudirun.level
level
Definition: gaudirun.py:366
Gaudi::Accumulators::GenericAccumulator::value
OutputType value() const
Definition: Accumulators.h:466
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:1160
Gaudi::Accumulators::MsgCounter::max
unsigned long max
Definition: Accumulators.h:1186
std::count
T count(T... args)
Gaudi::Accumulators::MsgCounter::typeString
static const std::string typeString
Definition: Accumulators.h:1137