feisty meow concerns codebase  2.140
structures::roller< contents > Class Template Reference

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

#include <roller.h>

Public Member Functions

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

Detailed Description

template<class contents>
class structures::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 35 of file roller.h.

Constructor & Destructor Documentation

◆ roller()

template<class contents >
structures::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 90 of file roller.h.

◆ ~roller()

template<class contents >
structures::roller< contents >::~roller

Definition at line 100 of file roller.h.

Member Function Documentation

◆ current()

template<class contents >
contents structures::roller< contents >::current

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 102 of file roller.h.

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

◆ maximum()

template<class contents >
contents structures::roller< contents >::maximum ( )
inline

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

Definition at line 51 of file roller.h.

Referenced by configuration::ini_roller::next_id().

◆ minimum()

template<class contents >
contents structures::roller< contents >::minimum ( )
inline

the smallest value that the roller can have.

Definition at line 49 of file roller.h.

◆ next_id()

template<class contents >
contents structures::roller< contents >::next_id

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

Definition at line 105 of file roller.h.

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

◆ set_current()

template<class contents >
void structures::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 94 of file roller.h.

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


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