senf::StatisticsBase::OutputProxy< Owner > Class Template Reference

Output connection interface. More...

#include <senf/Utils/Statistics.hh>

Public Member Functions

template<class Target >
Owner & connect (Target &target, std::string label="") const
 Connect externally managed target. More...
 
template<class PTarget >
Owner & connect (std::unique_ptr< PTarget > target, std::string label="") const
 Connect internally managed target. More...
 
Owner & noconnect () const
 Don't connect the output. More...
 
console::ScopedDirectorydir () const
 Get target's console directory. More...
 

Detailed Description

template<class Owner>
class senf::StatisticsBase::OutputProxy< Owner >

Output connection interface.

This class is returned from senf::StatisticsBase::output() and the derived output() implementations to allow connecting an output with an arbitrary target.

There are two types of targets:

  • Externally managed targets. These targets live outside of the statistics module, just a reference to those targets is saved. The target should derive from boost::signals2::trackable to ensure they are automatically disconnected when destroyed.
  • Internally managed targets. Those targets are owned by the statistics module and will be destroyed when the statistics class is destroyed.

Externally managed targets are passed by non-const reference to connect(), internally managed targets are passed using std::auto_ptr.

A target is any callable object which takes three float values as argument: The current minimum, average and maximum value.

// Simple function as statistics target
void collect(float min, float avg, float max)
{ ... }
// Function object
struct Collector
{
void operator()(unsigned cnt, float min, float avg, float max, float dev)
{ ... }
};

Definition at line 123 of file Statistics.hh.

Member Function Documentation

◆ connect() [1/2]

template<class Owner>
template<class Target >
Owner& senf::StatisticsBase::OutputProxy< Owner >::connect ( Target &  target,
std::string  label = "" 
) const

Connect externally managed target.

◆ connect() [2/2]

template<class Owner>
template<class PTarget >
Owner& senf::StatisticsBase::OutputProxy< Owner >::connect ( std::unique_ptr< PTarget >  target,
std::string  label = "" 
) const

Connect internally managed target.

◆ dir()

template<class Owner>
console::ScopedDirectory& senf::StatisticsBase::OutputProxy< Owner >::dir ( ) const

Get target's console directory.

◆ noconnect()

template<class Owner>
Owner& senf::StatisticsBase::OutputProxy< Owner >::noconnect ( ) const

Don't connect the output.


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