Boost C++ Libraries

PrevUpHomeNext

Class template counter

boost::log::attributes::counter — A class of an attribute that counts an integral value.

Synopsis

// In header: <boost/log/attributes/counter.hpp>

template<typename T> 
class counter : public attribute {
public:
  // types
  typedef T held_type;  // A held counter type. 

  // construct/copy/destruct
  explicit counter(held_type const & = held_type(), long = 1);

  // public member functions
  shared_ptr< attribute_value > get_value();
};

Description

This type of attribute acts as a counter, that is, it returns a monotonously changing value each time requested. The attribute value type can be specified as a template parameter. However, the type must support basic arithmetic operations, such as addition and substraction.

counter public construct/copy/destruct

  1. explicit counter(held_type const & initial = held_type(), long step = 1);

    Constructor

    Parameters:
    initial

    Initial value of the counter

    step

    Changing step of the counter. Each value acquired from the attribute will be greater than the previous one to this amount.

counter public member functions

  1. shared_ptr< attribute_value > get_value();

    Returns:

    The actual attribute value. It shall not return NULL (exceptions shall be used to indicate errors).


PrevUpHomeNext