iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::KeyTable< KeyType > Class Template Reference

#include <nrt/Core/Design/KeyTable.H>

template<class KeyType = size_t>
class nrt::KeyTable< KeyType >

A table used to create using Ids.

The KeyTable class provides a way to create unique keys, with recycling when keys get deleted. The keys are unique to each instance of the class, not globally unique.

KeyTable keeps track of the number of "users" for each Id. Each time create() is called, a user count is incremented, and each time remove() is called it is decremented. If the count becomes zero during a remove(), the Id is destroyed.

Note
Care must be taken when using this structure in a multithreaded environment. If not locked properly, the internal structures could get messed up.

Definition at line 58 of file KeyTable.H.

Public Member Functions

KeyType create ()
 Create a new unique key.
 
size_t users (KeyType const &key) const
 Get the user count for a given key, or zero if it does not exist.
 
size_t remove (KeyType const &key)
 Decrement the user count and, if zero, delete the key. More...
 
void clear ()
 Clear the entire KeyTable.
 

Member Function Documentation

template<class KeyType >
size_t nrt::KeyTable< KeyType >::remove ( KeyType const &  key)

Decrement the user count and, if zero, delete the key.

Returns
the new number of users after the decrement.
Exceptions
KeyNotFoundExceptionThrown if value does not exist in the table.

Definition at line 83 of file KeyTableImpl.H.


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