roller< contents > Class Template Reference

Maintains a pseudo-unique identifier number and issues a new one on demand. More...

#include <roller.h>

Collaboration diagram for roller< contents >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 roller (contents start_of_range, contents end_of_range)
 constructs a roller between the start and end ranges.
 ~roller ()
contents minimum ()
 the smallest value that the roller can have.
contents maximum ()
 the outer limit of the roller; it should never reach this.
contents next_id ()
 returns a unique (per instance of this type) id.
contents current () const
 returns the current id to be used; be careful!
void set_current (contents new_current)
 allows the current id to be manipulated.

Detailed Description

template<class contents>
class roller< contents >

Maintains a pseudo-unique identifier number and issues a new one on demand.

The unique id is templated on the type of identifier, but the type used must support: 1) assigment to a value, 2) a greater than or equal operator (>=), and 3) the increment operator (++). Zero is often treated as the invalid / empty / inactive identifier, but roller does not prevent its use since some ranges might need to bridge between negative and positive numbers.

Definition at line 33 of file roller.h.


Constructor & Destructor Documentation

template<class contents>
roller< contents >::roller ( contents  start_of_range,
contents  end_of_range 
)

constructs a roller between the start and end ranges.

this constructs a roller that runs from the value "start_of_range" and will stay smaller than "end_of_range" (unless the initial parameters are screwed up; this class doesn't validate the start and end of range). when the roller hits the end of range, then its value is reset to the "start_of_range" again.

Definition at line 24 of file roller.cpp.

template<class contents>
roller< contents >::~roller (  ) 

Definition at line 34 of file roller.cpp.


Member Function Documentation

template<class contents>
contents roller< contents >::minimum (  )  [inline]

the smallest value that the roller can have.

Definition at line 47 of file roller.h.

template<class contents>
contents roller< contents >::maximum (  )  [inline]

the outer limit of the roller; it should never reach this.

Definition at line 49 of file roller.h.

Referenced by ini_roller::next_id().

template<class contents>
contents roller< contents >::next_id (  ) 

returns a unique (per instance of this type) id.

Definition at line 39 of file roller.cpp.

Referenced by thread_cabinet::add_thread(), safe_roller::next_id(), ini_roller::next_id(), and cromp_client::next_id().

template<class contents>
contents roller< contents >::current (  )  const

returns the current id to be used; be careful!

this value will be the next one returned, so only look at the current id and don't use it unwisely. this function is useful if you want to assign an id provisionally but might not want to complete the issuance of it.

Definition at line 36 of file roller.cpp.

Referenced by safe_roller::current(), ini_roller::current_id(), ini_roller::ini_roller(), ini_roller::next_id(), and ini_roller::~ini_roller().

template<class contents>
void roller< contents >::set_current ( contents  new_current  ) 

allows the current id to be manipulated.

this must be done with care lest existing ids be re-used.

Definition at line 28 of file roller.cpp.

Referenced by ini_roller::ini_roller(), cromp_client::reset(), and safe_roller::set_current().


The documentation for this class was generated from the following files:
Generated on Fri Nov 28 04:30:57 2008 for HOOPLE Libraries by  doxygen 1.5.1