IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.
|
Object store. Objects of the specified type can be stored here for later reuse (efficiency improvement). IMPORTANT: Override IsEligible(), NotEligibleMessage() and TryGetNew() and possibly TryStore() methods in derived classes when applicable. More...
Public Member Functions | |
virtual bool | IsEligible (T obj) |
Returns true if the specified object is eligible for storing in this object storage, false if it is not. | |
virtual bool | TryStore (T obj) |
Stores the specified object if the object is eligible for storage in this store and if The maximal number of stored object will not be exceeded. | |
bool | StoreEligible (T obj) |
Stores the specified object in the store. WARNING: Throws ArgumentException if the specified object is not eligible for storing in this store. If the maximum number of objects would be exceeded then nothing happens. | |
T | TryGet () |
Returns an object from this object store, or null if it is not possible to provide an eligible object. If the store contains no objects, it tries to create and return a new eligible object. Should not throw an exception. | |
T | TryGetStored () |
Returns the last object from this object store, or null if there are no objects on it. Dose not attempt to create a new object. | |
T | GetEligible () |
Returns a non-null object that is eligible for storing in this object store. If the store itself does not contain any objects, an object is created anew, or exception is thrown if this is not possible. IMPORTANT: TryGet returns an object or null if the object can not be returned (does not throw an exception), and TryGetStored returns an eligible object only if any are stored, otherwise returns null. | |
Protected Member Functions | |
virtual void | ClearIneligible () |
Removes ineligible obects from the list. | |
virtual String | NotEligibleMessage (object obj) |
Returns a message indicating why the specified object is not eligible for storage in the current store. | |
virtual T | TryGetNew () |
Returns a newly created object eligible for storage, or null if such an object can not be created. This method should not throw an exception. | |
T | GetNew () |
Returns a newly xreated object eligible for storage in this object store. Exception is thrown if such an object can not be created. | |
Protected Attributes | |
object | _lock = new object() |
List< T > | _objects = new List<T>() |
Properties | |
object | Lock [get] |
int | Count [get, set] |
Gets the current number of objects. | |
int | MaxCount [get, set] |
Gets or sets the maximal number of objects that can be stored by this object store. | |
Private Attributes | |
int | _maxCount = 0 |
Object store. Objects of the specified type can be stored here for later reuse (efficiency improvement). IMPORTANT: Override IsEligible(), NotEligibleMessage() and TryGetNew() and possibly TryStore() methods in derived classes when applicable.
T | Type of objects to be stored, must be a reference type. |
T | : | class |
virtual bool IG::Lib::ObjectStore< T >::IsEligible | ( | T | obj | ) | [inline, virtual] |
Returns true if the specified object is eligible for storing in this object storage, false if it is not.
Implements IG::Lib::IObjectStore< T >.
Reimplemented in IG::Num::MatrixStore< T >, and IG::Num::VectorStore< T >.
virtual void IG::Lib::ObjectStore< T >::ClearIneligible | ( | ) | [inline, protected, virtual] |
Removes ineligible obects from the list.
virtual String IG::Lib::ObjectStore< T >::NotEligibleMessage | ( | object | obj | ) | [inline, protected, virtual] |
Returns a message indicating why the specified object is not eligible for storage in the current store.
virtual bool IG::Lib::ObjectStore< T >::TryStore | ( | T | obj | ) | [inline, virtual] |
Stores the specified object if the object is eligible for storage in this store and if The maximal number of stored object will not be exceeded.
obj | Object to be stored. |
Implements IG::Lib::IObjectStore< T >.
bool IG::Lib::ObjectStore< T >::StoreEligible | ( | T | obj | ) | [inline] |
Stores the specified object in the store. WARNING: Throws ArgumentException if the specified object is not eligible for storing in this store. If the maximum number of objects would be exceeded then nothing happens.
Implements IG::Lib::IObjectStore< T >.
T IG::Lib::ObjectStore< T >::TryGet | ( | ) | [inline] |
Returns an object from this object store, or null if it is not possible to provide an eligible object. If the store contains no objects, it tries to create and return a new eligible object. Should not throw an exception.
Implements IG::Lib::IObjectStore< T >.
T IG::Lib::ObjectStore< T >::TryGetStored | ( | ) | [inline] |
Returns the last object from this object store, or null if there are no objects on it. Dose not attempt to create a new object.
Implements IG::Lib::IObjectStore< T >.
T IG::Lib::ObjectStore< T >::GetEligible | ( | ) | [inline] |
Returns a non-null object that is eligible for storing in this object store. If the store itself does not contain any objects, an object is created anew, or exception is thrown if this is not possible. IMPORTANT: TryGet returns an object or null if the object can not be returned (does not throw an exception), and TryGetStored returns an eligible object only if any are stored, otherwise returns null.
Implements IG::Lib::IObjectStore< T >.
virtual T IG::Lib::ObjectStore< T >::TryGetNew | ( | ) | [inline, protected, virtual] |
Returns a newly created object eligible for storage, or null if such an object can not be created. This method should not throw an exception.
Reimplemented in IG::Num::VectorFunctionBaseGeneral::ObjectStoreResults.
T IG::Lib::ObjectStore< T >::GetNew | ( | ) | [inline, protected] |
Returns a newly xreated object eligible for storage in this object store. Exception is thrown if such an object can not be created.
object IG::Lib::ObjectStore< T >::_lock = new object() [protected] |
List<T> IG::Lib::ObjectStore< T >::_objects = new List<T>() [protected] |
int IG::Lib::ObjectStore< T >::_maxCount = 0 [private] |
object IG::Lib::ObjectStore< T >::Lock [get] |
Implements IG::Lib::ILockable.
int IG::Lib::ObjectStore< T >::Count [get, set] |
Gets the current number of objects.
Implements IG::Lib::IObjectStore< T >.
int IG::Lib::ObjectStore< T >::MaxCount [get, set] |
Gets or sets the maximal number of objects that can be stored by this object store.
Implements IG::Lib::IObjectStore< T >.