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

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 >:
Collaboration diagram for IG::Lib::ObjectRegister< T >:

List of all members.

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.
 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.
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.
bool IsRegistered (int id)
 Returns true if object with the specified ID is already registered with the current object, false otherwise.
bool IsRegistered (T obj)
 Returns true if the specified object is registered with the current object, false otherwise.
GetRegisteredInstance (int id)
 Returns object that is registered with this object with the specified id, or null if such an object is not registered.
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.

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.

Detailed Description

template<T>
class IG::Lib::ObjectRegister< T >

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 

Member Function Documentation

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

template<T >
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:
startIdThe first ID that will be generated with this object's GetNewId() method.
template<T >
void IG::Lib::ObjectRegister< T >::Register ( int  id,
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
template<T >
void IG::Lib::ObjectRegister< T >::Register ( 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.

template<T >
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:
idIIdentifiable object's ID, obtained by its ID property.
template<T >
bool IG::Lib::ObjectRegister< T >::IsRegistered ( obj) [inline]

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

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

template<T >
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

template<T >
SortedDictionary<int, T> IG::Lib::ObjectRegister< T >::_register = new SortedDictionary<int, T>() [protected]
template<T >
object IG::Lib::ObjectRegister< T >::_internalLock = new object() [protected]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties Events