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

- Main Page
- Namespaces
- Classes
- Files
- Directories

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

Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Private Attributes

# IG::Lib::ObjectStore< T > Class Template Reference

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

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

List of all members.

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

## Detailed Description

### template<T>
class IG::Lib::ObjectStore< T >

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.

Template Parameters:

  T | Type of objects to be stored, must be a reference type.

Type Constraints

  T | : | class |

## Member Function Documentation

template<T >

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

template<T >

virtual void IG::Lib::ObjectStore< T >::ClearIneligible | ( |  | ) | `[inline, protected, virtual]`

Removes ineligible obects from the list.

template<T >

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.

template<T >

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.

Parameters:

  obj | Object to be stored.

Returns:
  true if the object has actually been stored, false if not.

Implements IG::Lib::IObjectStore< T >.

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

Returns:
  true if the object has actually been stored, false if not.

Implements IG::Lib::IObjectStore< T >.

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

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

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

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

template<T >

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.

## Member Data Documentation

template<T >

object IG::Lib::ObjectStore< T >::_lock = new object()`[protected]`

template<T >

List<T> IG::Lib::ObjectStore< T >::_objects = new List<T>()`[protected]`

template<T >

int IG::Lib::ObjectStore< T >::_maxCount = 0`[private]`

## Property Documentation

template<T >

object IG::Lib::ObjectStore< T >::Lock`[get]`

Implements IG::Lib::ILockable.

template<T >

int IG::Lib::ObjectStore< T >::Count`[get, set]`

Gets the current number of objects.

Implements IG::Lib::IObjectStore< T >.

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

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

- UtilObjectStore.cs

All Classes Namespaces Files Functions Variables Enumerations Properties Events