IGLib  1.5
The IGLib base library for development of numerical, technical and business applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
IG.Lib.IdGenerator Class Reference

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...

+ Inheritance diagram for IG.Lib.IdGenerator:
+ Collaboration diagram for IG.Lib.IdGenerator:

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. More...
 
 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. More...
 
int GetNewId ()
 Returns a new unique command ID (process-unique over all objects of this type and its subtypes). More...
 

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. More...
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 

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
firstIdThe 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).

Referenced by IG.Lib.IdProxy.IdProxy().

Member Data Documentation

object IG.Lib.IdGenerator._mainLock = new object()
private
int IG.Lib.IdGenerator._currentId = 0
private
object IG.Lib.IdGenerator._lockId = new object()
private

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.


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