#include <extendedCache.h>
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 ¤t) |
virtual long | removeWorst () |
virtual bool | maintainerStep (long &costChange) |
virtual long | getSleepTime (const TimeStamp ¤t, 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 CacheLock & | makePersistent (const PersIdentification &persId, DatabaseObject &obj) |
Saves an object into database. | |
virtual CacheLock & | getCacheLock (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 CacheLock & | makePersistent (const StrategySelector &strSel, const PersIdentification &persId, DatabaseObject &objectPtr)=0 |
virtual CacheLock & | getCacheLock (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 |
StrategySelector * | stratSel |
long | minValue |
long | maxCost |
iopc::ExtendedCache::ExtendedCache | ( | long | minValue = MINLONG , |
|
long | maxCost = MAXLONG , |
|||
const Strategy & | strat = Strategy::defaultStrategy | |||
) | [inline] |
Initialize cache with the same strategies for all object.
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.
minValue | Minimal value of objects obliged to stay in the cache. | |
maxCost | Maximal total cost of stored objects. | |
strat | strategy selector. |
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.
persId | ID of the object. | |
obj | Object to be made persistent. |
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.
persId | ID of the object. | |
rdonly | Indicates the type of required access to the object (read-only/write). |
Implements iopc::Cache.
void iopc::ExtendedCache::dbDelete | ( | const PersIdentification & | persId | ) | [inline, protected, virtual] |
Deletes an object.
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.
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.
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.
strSel | The strategy selector. | |
persId | ID of the object. | |
obj | Object to be made persistent. |
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.
strSel | The strategy selector. | |
persId | ID of the object. | |
rdonly | Indicates the type of required access to the object (read-only/write). |
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.
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.
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.
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.
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] |
Removes the object with minimal value.
Reimplemented in iopc::ArcCache< MapType >, iopc::ArcCacheST< MapType >, iopc::LruCache< MapType >, and iopc::LruCacheST< MapType >.
bool iopc::ExtendedCache::maintainerStep | ( | long & | costChange | ) | [inline, virtual] |
Function executing one elementar maintenance step
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).
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.
minValue | Minimal value of an element being in the cache. | |
maxCost | Maximal total cost of elements in the cache. |
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).
minValue | MiStrategynimal value of an element being in the cache | |
maxCost | Maximal total cost of elements in the cache. |
Strategy iopc::ExtendedCache::defaultStrategy [protected] |
Default strategy
StrategySelector iopc::ExtendedCache::defaultStratSel [protected] |
Default strategy selector.
StrategySelector* iopc::ExtendedCache::stratSel [protected] |
Strategy selector created on cache initialization.
long iopc::ExtendedCache::minValue [protected] |
Minimal value of object obliged to stay in cache.
long iopc::ExtendedCache::maxCost [protected] |
Maximal total cost of objects being in cache.