| IGLib 1.7.2 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
IG.Lib.ObjectRegister< T > Class Template Reference

Provides implementation of register of objects of the specified type. Also generates unique IDs for objects of this type. This class utilizes implementation of IIdentifiable and IRegisterable interfaces. Implementation notes for IRegistable: For implementation, use a static instance of this class, and an a nonstatic instance of the IdProcy class (to generate and hold object's unique ID). subclass of this clas, initialized by that static instance. Example implementation can be found in the ExampleInterfaceImplementation subclass of this class. More...

Inheritance diagram for IG.Lib.ObjectRegister< T >:
[legend]
Collaboration diagram for IG.Lib.ObjectRegister< T >:
[legend]

## Public Member Functions
| ObjectRegister ()
| Creates an object that generates unique IDs (in the scope of the current instance) and provides registration of objects of the given type. More...
| ObjectRegister (int startId)
| Creates an object that generates unique IDs (in the scope of the current instance) with the specified first ID generated, and provides registration of objects of the given type. More...
void | Register (T obj)
| Adds the specified object to the register, using its Id property. If the object is already registered (i.e. the register already contains its Id) then More...
bool | IsRegistered (int id)
| Returns true if object with the specified ID is already registered with the current object, false otherwise. More...
bool | IsRegistered (T obj)
| Returns true if the specified object is registered with the current object, false otherwise. More...
T | GetRegisteredInstance (int id)
| Returns object that is registered with this object with the specified id, or null if such an object is not registered. More...
void | Unregister (int id)
| Unregisters object with the specified ID. WARNING: This method should only be used in finalization methods of objects that implement the IRegisterable interface. More...
Public Member Functions inherited from IG.Lib.IdGenerator
| 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...

## Protected Attributes
SortedDictionary< int, T > | _register = new SortedDictionary<int, T>()
object | _internalLock = new object()

## Private Member Functions
void | Register (int id, T obj)
| Registers the specified object with the specified key (ID). Warning: this method does not check whether the specified key actually corresponds to object's ID that is obtained by the object's IIdentifiable.Id property. Therefore it is private. More...

## Additional Inherited Members
Properties inherited from IG.Lib.IdGenerator
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]`

## Detailed Description

Provides implementation of register of objects of the specified type. Also generates unique IDs for objects of this type. This class utilizes implementation of IIdentifiable and IRegisterable interfaces. Implementation notes for IRegistable: For implementation, use a static instance of this class, and an a nonstatic instance of the IdProcy class (to generate and hold object's unique ID). subclass of this clas, initialized by that static instance. Example implementation can be found in the ExampleInterfaceImplementation subclass of this class.

Type Constraints

  T | : | class |
  T | : | IIdentifiable |

## Constructor & Destructor Documentation

IG.Lib.ObjectRegister< T >.ObjectRegister | ( |  | ) |
| inline

Creates an object that generates unique IDs (in the scope of the current instance) and provides registration of objects of the given type.

IG.Lib.ObjectRegister< T >.ObjectRegister | ( | int | startId | ) |
| inline

Creates an object that generates unique IDs (in the scope of the current instance) with the specified first ID generated, and provides registration of objects of the given type.

Parameters

  startId | The first ID that will be generated with this object's GetNewId() method.

## Member Function Documentation

void IG.Lib.ObjectRegister< T >.Register | ( | int | id,
|  | T | obj
| ) |  |
| inline private

Registers the specified object with the specified key (ID). Warning: this method does not check whether the specified key actually corresponds to object's ID that is obtained by the object's IIdentifiable.Id property. Therefore it is private.

Parameters

  id |
  obj |

void IG.Lib.ObjectRegister< T >.Register | ( | T | obj | ) |
| inline

Adds the specified object to the register, using its Id property. If the object is already registered (i.e. the register already contains its Id) then

bool IG.Lib.ObjectRegister< T >.IsRegistered | ( | int | id | ) |
| inline

Returns true if object with the specified ID is already registered with the current object, false otherwise.

Parameters

  id | IIdentifiable object's ID, obtained by its ID property.

bool IG.Lib.ObjectRegister< T >.IsRegistered | ( | T | obj | ) |
| inline

Returns true if the specified object is registered with the current object, false otherwise.

T IG.Lib.ObjectRegister< T >.GetRegisteredInstance | ( | int | id | ) |
| inline

Returns object that is registered with this object with the specified id, or null if such an object is not registered.

void IG.Lib.ObjectRegister< T >.Unregister | ( | int | id | ) |
| inline

Unregisters object with the specified ID. WARNING: This method should only be used in finalization methods of objects that implement the IRegisterable interface.

Parameters

  id |

Returns
  Reference of the object that has been

## Member Data Documentation

SortedDictionary<int, T> IG.Lib.ObjectRegister< T >._register = new SortedDictionary<int, T>()
| protected

object IG.Lib.ObjectRegister< T >._internalLock = new object()
| protected

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

- igbase/utilities/UtilIdRegistration.cs