#include <SIM_Cache.h>
Public Member Functions | |
| SIM_Cache () | |
| ~SIM_Cache () | |
| Destructor destroys all objects and temp files. | |
| void | setEngine (SIM_Engine *engine) |
| const SIM_CacheOptions & | getCacheOptions () const |
| Returns a reference to our caching option data. | |
| void | setCacheOptions (const SIM_CacheOptions &src) |
| Sets the cache options. | |
| void | cacheAndAdvance () |
| void | setCurrentTime (const SIM_Time &time) |
| bool | deleteAfterTime (const SIM_Time &time) |
| void | clear () |
| const SIM_Time & | getCurrentTime () const |
| const SIM_Time & | getEarliestTime () const |
| SIM_SimulationState & | getCurrentSimulationObjects () const |
| const SIM_Object * | getObjectAtTime (const SIM_Object &object, const SIM_Time &time, bool allowinterpolation) |
| SIM_Object * | getAffectorAtTime (SIM_Object &object, const SIM_Time &time, bool allowinterpolation) |
| SIM_Object * | createSubStepObject (const SIM_Object &object, const SIM_Time &time) |
| void | clearInterpolatedObjects (const SIM_ObjectArray &objects) |
| void | postSimulationStep () |
Definition at line 31 of file SIM_Cache.h.
| SIM_Cache::SIM_Cache | ( | ) |
Constructor intializes this class with no object data. A single cache entry is created to hold any new objects.
| SIM_Cache::~SIM_Cache | ( | ) |
Destructor destroys all objects and temp files.
| void SIM_Cache::cacheAndAdvance | ( | ) |
Caches the current object data and advances by one time step. Basically this consists of creating a copy of all objects in the simulation and setting the new current time. If the cache size is exceeded, a cache entry will be deleted. A cache entry may also get pushed to disk. If caching is disabled, this function does nothing except advance the current time.
| void SIM_Cache::clear | ( | ) |
Clears all cache entries. A single empty cache entry is then created to act as the current entry to shich new objects may be added.
| void SIM_Cache::clearInterpolatedObjects | ( | const SIM_ObjectArray & | objects | ) |
Deletes any objects from the myInterpolatedObjects array that match the provided object id. This function is called by the engine just prior to solving the object. The idea is that the object may have been used to create an interpolated object prior to its solve for a given timestep. After its solve, all the interpolation is incorrect, so leaving the interpolated objects around is potentially misleading and harmful.
| SIM_Object* SIM_Cache::createSubStepObject | ( | const SIM_Object & | object, | |
| const SIM_Time & | time | |||
| ) |
Returns a substep version of the specified object. The substep object is always created within the current simulation state regardless of the time value. The reason the SIM_Cache is used as an intermediary here is so that if we already have an interpolated version of the object at the requested time, we can convert the interpolated object into a substep (which is really different only in the sense of whether the SIM_Cache or the SIM_SimulationState owns it).
| bool SIM_Cache::deleteAfterTime | ( | const SIM_Time & | time | ) |
Deletes all cache entries after the specified time. The cache entry for the specified time itself is also deleted. The cache is moved to the entry just prior to the earliest deleted entry. If there is insufficient cache to fulfil the request, then nothing is changed and the function returns false. Otherwise it returns true.
| SIM_Object* SIM_Cache::getAffectorAtTime | ( | SIM_Object & | object, | |
| const SIM_Time & | time, | |||
| bool | allowinterpolation | |||
| ) |
Returns a non-const object from the specified earlier time. The returned value is always a pointer to the passed in object, or a substep object. If a time in some earlier timestep is specified, the earlier object is copied as a substep object of the current time. Otheriwse this function could be used to modify the past.
| const SIM_CacheOptions& SIM_Cache::getCacheOptions | ( | ) | const |
Returns a reference to our caching option data.
| SIM_SimulationState& SIM_Cache::getCurrentSimulationObjects | ( | ) | const |
Returns the objects that belong to the current cache entry. This function is called by the SIM_Engine getSimulationObject() and related functions.
| const SIM_Time& SIM_Cache::getCurrentTime | ( | ) | const |
Returns the time of the current cache entry. This function is called by the SIM_Engine::getSimulationTime() function.
| const SIM_Time& SIM_Cache::getEarliestTime | ( | ) | const |
Returns the time of the earliest cache entry. This function is called by the SIM_Engine::getEarliestCacheTime() function.
| const SIM_Object* SIM_Cache::getObjectAtTime | ( | const SIM_Object & | object, | |
| const SIM_Time & | time, | |||
| bool | allowinterpolation | |||
| ) |
Returns the specified object at an earlier time step. If the object at the exact specified time cannot be found, we create a new object by interpolating between the previous and next available states of the object.
| void SIM_Cache::postSimulationStep | ( | ) |
This performs the cleanup required after performing a simulation step. All temporary interpolated objects are deleted, and any excess cache entries in memory are flushed to disk.
| void SIM_Cache::setCacheOptions | ( | const SIM_CacheOptions & | src | ) |
Sets the cache options.
| void SIM_Cache::setCurrentTime | ( | const SIM_Time & | time | ) |
Tells the cache to move to a new current time. Whatever cache entry is the best match for the specfied time will be made the current cache entry. If the new time is earlier than any cache entry, then the earliest cache entry is used. If the new time is later than the latest cache entry, the last entry is used. Note that this means the cache's current time won't necessarily be set to the requested value. It is up to the SIM_Engine to perform simulation steps to get to the actual desired time.
| void SIM_Cache::setEngine | ( | SIM_Engine * | engine | ) |
Initialize this object with a SIM_Engine pointer. This must be done as soon as the SIM_Cache is created.
1.5.9