Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | List of all members
bitpit::IndexGenerator< id_t > Class Template Reference

The IndexGenerator class allows to generate unique ids. More...

Inheritance diagram for bitpit::IndexGenerator< id_t >:
Inheritance graph
[legend]

Public Types

typedef id_t id_type
 

Public Member Functions

 IndexGenerator ()
 
void dump (std::ostream &stream) const
 
id_type generate ()
 
id_type getHighest ()
 
id_type getLatest ()
 
bool isAssigned (id_type id)
 
void reset ()
 
void restore (std::istream &stream)
 
void setAssigned (id_type id)
 
void trash (id_type id)
 

Static Public Attributes

static BITPIT_PUBLIC_API const id_type NULL_ID = std::numeric_limits<typename IndexGenerator<id_t>::id_type>::min()
 

Detailed Description

template<typename id_t = long>
class bitpit::IndexGenerator< id_t >

The IndexGenerator class allows to generate unique ids.

Definition at line 39 of file index_generator.hpp.

Member Typedef Documentation

◆ id_type

template<typename id_t = long>
typedef id_t bitpit::IndexGenerator< id_t >::id_type

Definition at line 45 of file index_generator.hpp.

Constructor & Destructor Documentation

◆ IndexGenerator()

template<typename id_t >
bitpit::IndexGenerator< id_t >::IndexGenerator ( )

Creates a new generator.

Definition at line 37 of file index_generator.tpp.

Member Function Documentation

◆ dump()

template<typename id_t >
void bitpit::IndexGenerator< id_t >::dump ( std::ostream & stream) const

Write the index generator to the specified stream.

Parameters
streamis the stream to write to

Definition at line 280 of file index_generator.tpp.

◆ generate()

template<typename id_t >
IndexGenerator< id_t >::id_type bitpit::IndexGenerator< id_t >::generate ( )

Generates a unique index.

If the trash is empty a new index is generated, otherwise an index taken from the trash is recycled.

Returns
A new unique index.

Definition at line 52 of file index_generator.tpp.

◆ getHighest()

template<typename id_t >
IndexGenerator< id_t >::id_type bitpit::IndexGenerator< id_t >::getHighest ( )

Gets the highest assigned id.

Returns
The highest assigned index.

Definition at line 94 of file index_generator.tpp.

◆ getLatest()

template<typename id_t >
IndexGenerator< id_t >::id_type bitpit::IndexGenerator< id_t >::getLatest ( )

Gets the latest assigned id.

Returns
The latest assigned index.

Definition at line 83 of file index_generator.tpp.

◆ isAssigned()

template<typename id_t >
bool bitpit::IndexGenerator< id_t >::isAssigned ( id_type id)

Checks if an id is currently assigned.

Returns
True if the id has already been assigned, false otherwise.

Definition at line 105 of file index_generator.tpp.

◆ reset()

template<typename id_t >
void bitpit::IndexGenerator< id_t >::reset ( )

Reset the generator.

Definition at line 242 of file index_generator.tpp.

◆ restore()

template<typename id_t >
void bitpit::IndexGenerator< id_t >::restore ( std::istream & stream)

Restore the index generator from the specified stream.

Parameters
streamis the stream to read from

Definition at line 299 of file index_generator.tpp.

◆ setAssigned()

template<typename id_t = long>
void bitpit::IndexGenerator< id_t >::setAssigned ( id_type id)

Marks the specified id as currently assigned.

Parameters
idis the id to be marked as assigned

Definition at line 136 of file index_generator.tpp.

◆ trash()

template<typename id_t = long>
void bitpit::IndexGenerator< id_t >::trash ( id_type id)

Trashes an index.

A trashed index is an index no more used that can be recycled.

Parameters
idis the index that will be trashed

Definition at line 182 of file index_generator.tpp.

Member Data Documentation

◆ NULL_ID

template<typename id_t >
const IndexGenerator< id_t >::id_type bitpit::IndexGenerator< id_t >::NULL_ID = std::numeric_limits<typename IndexGenerator<id_t>::id_type>::min()
static

Definition at line 47 of file index_generator.hpp.


The documentation for this class was generated from the following files:
--- layout: doxygen_footer ---