| IGLib 1.5 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
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Private Attributes | List of all members
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]

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

## Protected Member Functions
virtual void | ClearIneligible ()
| Removes ineligible obects from the list. More...
virtual String | NotEligibleMessage (object obj)
| Returns a message indicating why the specified object is not eligible for storage in the current store. More...
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. More...
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. More...

## Protected Attributes
object | _lock = new object()
List< T > | _objects = new List<T>()

## Properties
object | Lock`[get]`
int | Count`[get, protected set]`
| Gets the current number of objects. More...
int | MaxCount`[get, set]`
| Gets or sets the maximal number of objects that can be stored by this object store. More...
Properties inherited from IG.Lib.IObjectStore< T >
int | Count`[get]`
| Gets the current number of objects. More...
int | MaxCount`[get, set]`
| Gets or sets the maximal number of objects that can be stored by this object store. More...
Properties inherited from IG.Lib.ILockable
object | Lock`[get]`

## Private Attributes
int | _maxCount = 0

## Detailed Description

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

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.

Parameters

  obj | Object to be stored.

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

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.

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

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.

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

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

## Property Documentation

object IG.Lib.ObjectStore< T >.Lock
| get

int IG.Lib.ObjectStore< T >.Count
| get protected set

Gets the current number of objects.

int IG.Lib.ObjectStore< T >.MaxCount
| get set

Gets or sets the maximal number of objects that can be stored by this object store.

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

- igbase/utilities/UtilObjectStore.cs