Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Protected Attributes | List of all members
Mezzanine::UIDGenerator Class Reference

This class will generate keep track of a pool of unique 32-bit ID's that can be used for distinct object instances. More...

#include <uidgenerator.h>

+ Collaboration diagram for Mezzanine::UIDGenerator:

Public Types

typedef IDContainer::const_iterator ConstIDIterator
 Const Iterator type for IDs generated and stored by this class.
 
typedef std::vector< IntervalTypeIDContainer
 Basic container type for IDs generated and stored by this class.
 
typedef IDContainer::iterator IDIterator
 Iterator type for IDs generated and stored by this class.
 
typedef UInt32 IDType
 Convenience type for the ID to be used. Should be some flavor of int.
 
typedef Interval< IDTypeIntervalType
 Convenience type for Intervals used by this class.
 

Public Member Functions

 UIDGenerator ()
 Class constructor.
 
 ~UIDGenerator ()
 Class destructor.
 
IDType GenerateID ()
 Generates a new ID unique to the pool made by this generator. More...
 
Boole IsIDUsed (const IDType ID) const
 Checks to see if an ID is in use. More...
 
Boole ReleaseID (const IDType ID)
 Frees up an ID so that it can be reused. More...
 
Boole ReserveID (const IDType ID)
 Adds a specific ID to the pool of used IDs. More...
 
void Sort ()
 Sorts the free IDs stored in this generator.
 

Protected Attributes

IDContainer FreeIDs
 The container storing all IDs generated and in use by this generator. More...
 

Detailed Description

This class will generate keep track of a pool of unique 32-bit ID's that can be used for distinct object instances.

Definition at line 53 of file uidgenerator.h.

Member Function Documentation

UIDGenerator::IDType Mezzanine::UIDGenerator::GenerateID ( )

Generates a new ID unique to the pool made by this generator.

Returns
Returns a new unique ID, or zero if there was a failure.

Definition at line 62 of file uidgenerator.cpp.

Boole Mezzanine::UIDGenerator::IsIDUsed ( const IDType  ID) const

Checks to see if an ID is in use.

Parameters
IDThe ID to check whether or not it is used.
Returns
Returns true if the specified ID has already been generated and is in use.

Definition at line 78 of file uidgenerator.cpp.

Boole Mezzanine::UIDGenerator::ReleaseID ( const IDType  ID)

Frees up an ID so that it can be reused.

Parameters
IDThe ID to be freed up for reuse.
Returns
Returns true of the ID was successfully released, false if it was already free.

Definition at line 133 of file uidgenerator.cpp.

Boole Mezzanine::UIDGenerator::ReserveID ( const IDType  ID)

Adds a specific ID to the pool of used IDs.

Parameters
IDThe ID to be reserved.
Returns
Returns true if the ID was successfully reserved, false if it is already generated.

Definition at line 89 of file uidgenerator.cpp.

Member Data Documentation

IDContainer Mezzanine::UIDGenerator::FreeIDs
protected

The container storing all IDs generated and in use by this generator.

Definition at line 69 of file uidgenerator.h.


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