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...
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.
|
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.
|
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.
Member Function Documentation
Creates an object that generates unique IDs (in the scope of the current instance) and provides registration of objects of the given type.
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. |
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:
-
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.
Returns true if object with the specified ID is already registered with the current object, false otherwise.
- Parameters:
-
Returns true if the specified object is registered with the current object, false otherwise.
Returns object that is registered with this object with the specified id, or null if such an object is not registered.
Unregisters object with the specified ID. WARNING: This method should only be used in finalization methods of objects that implement the IRegisterable interface.
- Parameters:
-
- Returns:
- Reference of the object that has been
Member Data Documentation
The documentation for this class was generated from the following file: