iopc::ExtendedCache Class Reference
[iopclib-cache]

#include <extendedCache.h>

Inheritance diagram for iopc::ExtendedCache:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 ExtendedCache (long minValue=MINLONG, long maxCost=MAXLONG, const Strategy &strat=Strategy::defaultStrategy)
 ExtendedCache (long minValue, long maxCost, StrategySelector *stratSel)
virtual long getActiveCost ()
virtual long getLockedCost ()
virtual long getWorstValue (const TimeStamp &current)
virtual long removeWorst ()
virtual bool maintainerStep (long &costChange)
virtual long getSleepTime (const TimeStamp &current, long minValue)
virtual bool imposeLimits (long minValue, long maxCost)
virtual bool imposeLimits ()
virtual bool setLimits (long minValue, long maxCost)

Protected Member Functions

virtual void clear ()
 Synchronizes states of the cache and database.
virtual CacheLockmakePersistent (const PersIdentification &persId, DatabaseObject &obj)
 Saves an object into database.
virtual CacheLockgetCacheLock (const PersIdentification &persId, bool rdonly=false)
 Assures an object is in cache, locks it and returns an instance making it possible to access the object.
virtual void dbDelete (const PersIdentification &persId)
 Deletes an object.
virtual void cacheDelete (const PersIdentification &persId)
 Represents a hint for the cache to remove local copy of an object.
virtual void updateDirty ()
 Synchronize the state of cache and DB by updating the DB.
virtual void removeAll ()
 Synchronize the state of cache and DB by discarding all kept object (without modifications to DB).
virtual void clear (const StrategySelector &strSel)=0
virtual CacheLockmakePersistent (const StrategySelector &strSel, const PersIdentification &persId, DatabaseObject &objectPtr)=0
virtual CacheLockgetCacheLock (const StrategySelector &strSel, const PersIdentification &persId, bool rdonly=false)=0
virtual void dbDelete (const StrategySelector &strSel, const PersIdentification &persId)=0
virtual void cacheDelete (const StrategySelector &strSel, const PersIdentification &persId)=0
virtual void updateDirty (const StrategySelector &strSel)=0
virtual void removeAll (const StrategySelector &strSel)=0

Protected Attributes

Strategy defaultStrategy
StrategySelector defaultStratSel
StrategySelectorstratSel
long minValue
long maxCost


Detailed Description

Common predecessor of so-called extended caches. Provides interface which makes it possible to specify db access strategies when using some methods. Includes interface for external maintenance of the cache.

Constructor & Destructor Documentation

iopc::ExtendedCache::ExtendedCache ( long  minValue = MINLONG,
long  maxCost = MAXLONG,
const Strategy strat = Strategy::defaultStrategy 
) [inline]

Initialize cache with the same strategies for all object.

Parameters:
minValue Minimal value of objects obliged to stay in the cache.
maxCost Maximal total cost of stored objects.
strat Default strategy.

iopc::ExtendedCache::ExtendedCache ( long  minValue,
long  maxCost,
StrategySelector stratSel 
) [inline]

Initialize cache with strategies passed by selector.

Parameters:
minValue Minimal value of objects obliged to stay in the cache.
maxCost Maximal total cost of stored objects.
strat strategy selector.


Member Function Documentation

void iopc::ExtendedCache::clear (  )  [inline, protected, virtual]

Synchronizes states of the cache and database.

Removes all objects. Makes it possible to harmlessly break association of the cache and its connection.

Implements iopc::Cache.

Reimplemented in iopc::FakeExtendedCache.

CacheLock & iopc::ExtendedCache::makePersistent ( const PersIdentification persId,
DatabaseObject objectPtr 
) [inline, protected, virtual]

Saves an object into database.

Locks it in cache.

Parameters:
persId ID of the object.
obj Object to be made persistent.
Returns:
An instance representing locked object and making it possible to read and modify the object.

Implements iopc::Cache.

CacheLock & iopc::ExtendedCache::getCacheLock ( const PersIdentification persId,
bool  rdonly = false 
) [inline, protected, virtual]

Assures an object is in cache, locks it and returns an instance making it possible to access the object.

Parameters:
persId ID of the object.
rdonly Indicates the type of required access to the object (read-only/write).
Returns:
An instance making it possible to access the object.

Implements iopc::Cache.

void iopc::ExtendedCache::dbDelete ( const PersIdentification persId  )  [inline, protected, virtual]

Deletes an object.

Parameters:
persId ID of the object.

Implements iopc::Cache.

Reimplemented in iopc::FakeExtendedCache.

void iopc::ExtendedCache::cacheDelete ( const PersIdentification persId  )  [inline, protected, virtual]

Represents a hint for the cache to remove local copy of an object.

Can be ignored.

Parameters:
persId ID of the object.

Implements iopc::Cache.

Reimplemented in iopc::FakeExtendedCache.

virtual void iopc::ExtendedCache::clear ( const StrategySelector strSel  )  [protected, pure virtual]

Synchronizes states of the cache and database. Removes all objects. Makes it possible to harmlessly break association of the cache and its connection. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.

Implemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::FakeExtendedCache, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

virtual CacheLock& iopc::ExtendedCache::makePersistent ( const StrategySelector strSel,
const PersIdentification persId,
DatabaseObject objectPtr 
) [protected, pure virtual]

Saves an object into database. Locks it in cache. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.
persId ID of the object.
obj Object to be made persistent.
Returns:
An instance representing locked object and making it possible to read and modify the object.

Implemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::FakeExtendedCache, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

virtual CacheLock& iopc::ExtendedCache::getCacheLock ( const StrategySelector strSel,
const PersIdentification persId,
bool  rdonly = false 
) [protected, pure virtual]

Assures an object is in cache, locks it and returns an instance making it possible to access the object. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.
persId ID of the object.
rdonly Indicates the type of required access to the object (read-only/write).
Returns:
An instance making it possible to access the object.

Implemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::FakeExtendedCache, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

virtual void iopc::ExtendedCache::dbDelete ( const StrategySelector strSel,
const PersIdentification persId 
) [protected, pure virtual]

Deletes an object. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.
persId ID of the object.

Implemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::FakeExtendedCache, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

virtual void iopc::ExtendedCache::cacheDelete ( const StrategySelector strSel,
const PersIdentification persId 
) [protected, pure virtual]

Represents a hint for the cache to remove local copy of an object. Can be ignored. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.
persId ID of the object.

Implemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::FakeExtendedCache, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

virtual void iopc::ExtendedCache::updateDirty ( const StrategySelector strSel  )  [protected, pure virtual]

Synchronize the state of cache and DB by updating the DB. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.

Implemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::FakeExtendedCache, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

virtual void iopc::ExtendedCache::removeAll ( const StrategySelector strSel  )  [protected, pure virtual]

Synchronize the state of cache and DB by discarding all kept object (without modifications to DB).http://www-ucjf.troja.mff.cuni.cz/scheirich/comics/mff_life_09.jpg Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.

Implemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::FakeExtendedCache, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

long iopc::ExtendedCache::getActiveCost (  )  [inline, virtual]

Returns total cost of objects which can be removed from cache (i.e. are not locked).

Reimplemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

long iopc::ExtendedCache::getLockedCost (  )  [inline, virtual]

Returns total cost of objects which can't be removed from cache (i.e. are locked).

Reimplemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

long iopc::ExtendedCache::getWorstValue ( const TimeStamp current  )  [inline, virtual]

Returns value of the object having minimal value.

Reimplemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

long iopc::ExtendedCache::removeWorst (  )  [inline, virtual]

bool iopc::ExtendedCache::maintainerStep ( long &  costChange  )  [inline, virtual]

Function executing one elementar maintenance step

Returns:
false when there's no work for maintainer, true otherwise.

Reimplemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

long iopc::ExtendedCache::getSleepTime ( const TimeStamp current,
long  minValue 
) [inline, virtual]

Gets the time it's possible to sleep for the external maintainer (unless it's woken up).

Returns:
Maximal number of milliseconds the cache doesn't need to be externally maintained for.

Reimplemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.

bool iopc::ExtendedCache::imposeLimits ( long  minValue,
long  maxCost 
) [virtual]

Function imposing specified limits on the cache. The limits are fullfilled just for the time of the call.

Parameters:
minValue Minimal value of an element being in the cache.
maxCost Maximal total cost of elements in the cache.
Returns:
false if specified limits cannot be achieved (e.g. due to locks), true otherwise (on success}.

bool iopc::ExtendedCache::imposeLimits (  )  [inline, virtual]

Imposes default limits (specified by attributes).

bool iopc::ExtendedCache::setLimits ( long  minValue,
long  maxCost 
) [inline, virtual]

Sets limits permanently (until next explicit change).

Parameters:
minValue MiStrategynimal value of an element being in the cache
maxCost Maximal total cost of elements in the cache.
Returns:
false if specified limits cannot be achived for time of the call, true otherwise (on success); even if false is returned the limits are set as specified and should be achieved in future (when possible).


Member Data Documentation

Default strategy

Default strategy selector.

Strategy selector created on cache initialization.

Minimal value of object obliged to stay in cache.

long iopc::ExtendedCache::maxCost [protected]

Maximal total cost of objects being in cache.


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

Generated on Tue Apr 14 16:46:43 2009 for IOPC 2 by  doxygen 1.5.6