Utility class for generaton of unique IDs for objects of specific type. IDs generated by calls of GetNewId() from a specific object of this class are unique. Utilizes definition of IIdentifiable interface. Implementation notes: In every class whose instances should have unique IDs, instantiate a private static object of this type, and an instance member of the Proxy subtype of this class. Both objexts should be instantiated by appropriate initializers, and constructor of the proxy object should be called with static object as argument. Example implementation can be found in the ExampleInterfaceImplementation subclass of this class.
More...
List of all members.
Public Member Functions |
| IdGenerator () |
| Creates a new ID generator. The first ID generated will be 0. Subsequent IDs are generated by obtained by incrementing the last generated ID.
|
| IdGenerator (int firstId) |
| Created a new ID generator with the specified ID generated first. Subsequent IDs are generated by obtained by incrementing the last generated ID.
|
int | GetNewId () |
| Returns a new unique command ID (process-unique over all objects of this type and its subtypes).
|
Properties |
object | Lock [get] |
| This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.
|
Private Attributes |
object | _mainLock = new object() |
int | _currentId = 0 |
object | _lockId = new object() |
Detailed Description
Utility class for generaton of unique IDs for objects of specific type. IDs generated by calls of GetNewId() from a specific object of this class are unique. Utilizes definition of IIdentifiable interface. Implementation notes: In every class whose instances should have unique IDs, instantiate a private static object of this type, and an instance member of the Proxy subtype of this class. Both objexts should be instantiated by appropriate initializers, and constructor of the proxy object should be called with static object as argument. Example implementation can be found in the ExampleInterfaceImplementation subclass of this class.
Constructor & Destructor Documentation
IG::Lib::IdGenerator::IdGenerator |
( |
| ) |
[inline] |
Creates a new ID generator. The first ID generated will be 0. Subsequent IDs are generated by obtained by incrementing the last generated ID.
IG::Lib::IdGenerator::IdGenerator |
( |
int |
firstId | ) |
[inline] |
Created a new ID generator with the specified ID generated first. Subsequent IDs are generated by obtained by incrementing the last generated ID.
- Parameters:
-
firstId | The first ID generated by the current object. |
Member Function Documentation
int IG::Lib::IdGenerator::GetNewId |
( |
| ) |
[inline] |
Returns a new unique command ID (process-unique over all objects of this type and its subtypes).
Member Data Documentation
Property Documentation
object IG::Lib::IdGenerator::Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.
Implements IG::Lib::ILockable.
The documentation for this class was generated from the following file: