Library of Assembled Shared Sources
lass::util::IdGenerator< T > Class Template Reference

Generates sequential and unique ID's. More...

#include <id_generator.h>

Public Member Functions

 IdGenerator (typename CallTraits< T >::TParam iFirstId=0)
 Construct an ID generator of which iFirstId is the first ID to be generated.
 
CallTraits< T >::TValue operator() ()
 Generate an ID.
 
void setNext (typename CallTraits< T >::TParam iNextId)
 set the next ID to be drawn.
 

Detailed Description

template<typename T>
class lass::util::IdGenerator< T >

Generates sequential and unique ID's.

Author
Bram de Greve
Date
2003

Pretty simple. This object generates unique ID numbers, each incremented by one, starting from a given ID.

LASS_COUT << generator() << "\n"; // will print '0'
LASS_COUT << generator() << "\n"; // will print '1'
LASS_COUT << generator() << "\n"; // will print '2'
LASS_COUT << generator() << "\n"; // will print '3'
...
IdGenerator(typename CallTraits< T >::TParam iFirstId=0)
Construct an ID generator of which iFirstId is the first ID to be generated.
#define LASS_COUT
return reference to 'cout' proxy stream of the lass::io::ProxyMan singleton.
Definition io_fwd.h:69
requirements for T:
  • T must implement prefix increment, operator++
  • T must be less-than comparable, operator<
  • T must be copy-constructible

Definition at line 89 of file id_generator.h.

Member Function Documentation

◆ operator()()

template<typename T>
CallTraits< T >::TValue lass::util::IdGenerator< T >::operator() ( )

Generate an ID.

Each call to this operator will give you a new ID incremented by one.

Exceptions
anexception is thrown if the generator can no longer increment the id field. Since the generator stores the id that will be returned on the next call, this means the maximum id returned will be num::NumTraits<T>::max-1

Definition at line 76 of file id_generator.inl.


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