CachedResults Class Template Reference

#include <IpCachedResults.hpp>

List of all members.


Detailed Description

template<class T>
class Ipopt::CachedResults< T >

Cache Priority Enum.

Templated class for Chached Results. This class stores up to a given number of "results", entities that are stored here together with identifies, that can be used to later retrieve the information again.

Typically, T is a SmartPtr for some calculated quantity that should be stored (such as a Vector). The identifiers (or dependencies) are a (possibly varying) number of Tags from TaggedObjects, and a number of Numbers. Results are added to the cache using the AddCachedResults methods, and the can be retrieved with the GetCachedResults methods. The second set of methods checks whether a result has been cached for the given identifiers. If a corresponding results is found, a copy of it is returned and the method evaluates to true, otherwise it evaluates to false.

Note that cached results can become "stale", namely when a TaggedObject that is used to identify this CachedResult is changed. When this happens, the cached result can never be asked for again, so that there is no point in storing it any longer. For this purpose, a cached result, which is stored as a DependentResult, inherits off an Observer. This Observer retrieves notification whenever a TaggedObject dependency has changed. Stale results are later removed from the cache.

Public Member Functions

bool InvalidateResult (const std::vector< const TaggedObject * > &dependents, const std::vector< Number > &scalar_dependents)
 Invalidates the result for given dependecies.
Constructors and Destructors.
 CachedResults (Int max_cache_size)
 Constructor, where max_cache_size is the maximal number of results that should be cached.
virtual ~CachedResults ()
 Destructor.
Generic methods for adding and retrieving cached results.
void AddCachedResult (const T &result, const std::vector< const TaggedObject * > &dependents, const std::vector< Number > &scalar_dependents)
 Generic method for adding a result to the cache, given a std::vector of TaggesObjects and a std::vector of Numbers.
bool GetCachedResult (T &retResult, const std::vector< const TaggedObject * > &dependents, const std::vector< Number > &scalar_dependents) const
 Generic method for retrieving a cached results, given the dependencies as a std::vector of TaggesObjects and a std::vector of Numbers.
void AddCachedResult (const T &result, const std::vector< const TaggedObject * > &dependents)
 Method for adding a result, providing only a std::vector of TaggedObjects.
bool GetCachedResult (T &retResult, const std::vector< const TaggedObject * > &dependents) const
 Method for retrieving a cached result, providing only a std::vector of TaggedObjects.
Pointer-based methods for adding and retrieving cached
results, providing dependencies explicitly.

void AddCachedResult1Dep (const T &result, const TaggedObject *dependent1)
 Method for adding a result to the cache, proving one dependency as a TaggedObject explicitly.
bool GetCachedResult1Dep (T &retResult, const TaggedObject *dependent1)
 Method for retrieving a cached result, proving one dependency as a TaggedObject explicitly.
void AddCachedResult2Dep (const T &result, const TaggedObject *dependent1, const TaggedObject *dependent2)
 Method for adding a result to the cache, proving two dependencies as a TaggedObject explicitly.
bool GetCachedResult2Dep (T &retResult, const TaggedObject *dependent1, const TaggedObject *dependent2)
 Method for retrieving a cached result, proving two dependencies as a TaggedObject explicitly.
void AddCachedResult3Dep (const T &result, const TaggedObject *dependent1, const TaggedObject *dependent2, const TaggedObject *dependent3)
 Method for adding a result to the cache, proving three dependencies as a TaggedObject explicitly.
bool GetCachedResult3Dep (T &retResult, const TaggedObject *dependent1, const TaggedObject *dependent2, const TaggedObject *dependent3)
 Method for retrieving a cached result, proving three dependencies as a TaggedObject explicitly.
Pointer-free version of the Add and Get methods
bool GetCachedResult1Dep (T &retResult, const TaggedObject &dependent1)
bool GetCachedResult2Dep (T &retResult, const TaggedObject &dependent1, const TaggedObject &dependent2)
bool GetCachedResult3Dep (T &retResult, const TaggedObject &dependent1, const TaggedObject &dependent2, const TaggedObject &dependent3)
void AddCachedResult1Dep (const T &result, const TaggedObject &dependent1)
void AddCachedResult2Dep (const T &result, const TaggedObject &dependent1, const TaggedObject &dependent2)
void AddCachedResult3Dep (const T &result, const TaggedObject &dependent1, const TaggedObject &dependent2, const TaggedObject &dependent3)


Constructor & Destructor Documentation

CachedResults ( Int  max_cache_size  )  [inline]

Constructor, where max_cache_size is the maximal number of results that should be cached.

If max_cache_size is negative, we allow an infinite abount of cache.

References DBG_START_METH.

~CachedResults (  )  [inline, virtual]

Destructor.

References DBG_START_METH.


Member Function Documentation

void AddCachedResult ( const T &  result,
const std::vector< const TaggedObject * > &  dependents,
const std::vector< Number > &  scalar_dependents 
) [inline]

Generic method for adding a result to the cache, given a std::vector of TaggesObjects and a std::vector of Numbers.

References DBG_ASSERT, DBG_EXEC, and DBG_START_METH.

Referenced by CachedResults::AddCachedResult(), CachedResults::AddCachedResult1Dep(), CachedResults::AddCachedResult2Dep(), and CachedResults::AddCachedResult3Dep().

bool GetCachedResult ( T &  retResult,
const std::vector< const TaggedObject * > &  dependents,
const std::vector< Number > &  scalar_dependents 
) const [inline]

Generic method for retrieving a cached results, given the dependencies as a std::vector of TaggesObjects and a std::vector of Numbers.

References DBG_EXEC, and DBG_START_METH.

Referenced by CachedResults::GetCachedResult(), CachedResults::GetCachedResult1Dep(), CachedResults::GetCachedResult2Dep(), and CachedResults::GetCachedResult3Dep().

void AddCachedResult ( const T &  result,
const std::vector< const TaggedObject * > &  dependents 
) [inline]

Method for adding a result, providing only a std::vector of TaggedObjects.

References CachedResults::AddCachedResult().

bool GetCachedResult ( T &  retResult,
const std::vector< const TaggedObject * > &  dependents 
) const [inline]

Method for retrieving a cached result, providing only a std::vector of TaggedObjects.

References CachedResults::GetCachedResult().

void AddCachedResult1Dep ( const T &  result,
const TaggedObject dependent1 
) [inline]

Method for adding a result to the cache, proving one dependency as a TaggedObject explicitly.

References CachedResults::AddCachedResult(), and DBG_START_METH.

Referenced by CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::AddCachedResult1Dep().

bool GetCachedResult1Dep ( T &  retResult,
const TaggedObject dependent1 
) [inline]

Method for retrieving a cached result, proving one dependency as a TaggedObject explicitly.

References DBG_START_METH, and CachedResults::GetCachedResult().

Referenced by CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::GetCachedResult1Dep().

void AddCachedResult2Dep ( const T &  result,
const TaggedObject dependent1,
const TaggedObject dependent2 
) [inline]

Method for adding a result to the cache, proving two dependencies as a TaggedObject explicitly.

References CachedResults::AddCachedResult(), and DBG_START_METH.

Referenced by CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::AddCachedResult2Dep().

bool GetCachedResult2Dep ( T &  retResult,
const TaggedObject dependent1,
const TaggedObject dependent2 
) [inline]

Method for retrieving a cached result, proving two dependencies as a TaggedObject explicitly.

References DBG_START_METH, and CachedResults::GetCachedResult().

Referenced by CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::GetCachedResult2Dep().

void AddCachedResult3Dep ( const T &  result,
const TaggedObject dependent1,
const TaggedObject dependent2,
const TaggedObject dependent3 
) [inline]

Method for adding a result to the cache, proving three dependencies as a TaggedObject explicitly.

References CachedResults::AddCachedResult(), and DBG_START_METH.

Referenced by CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::AddCachedResult3Dep().

bool GetCachedResult3Dep ( T &  retResult,
const TaggedObject dependent1,
const TaggedObject dependent2,
const TaggedObject dependent3 
) [inline]

Method for retrieving a cached result, proving three dependencies as a TaggedObject explicitly.

References DBG_START_METH, and CachedResults::GetCachedResult().

Referenced by CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::GetCachedResult3Dep().

bool GetCachedResult1Dep ( T &  retResult,
const TaggedObject dependent1 
) [inline]

bool GetCachedResult2Dep ( T &  retResult,
const TaggedObject dependent1,
const TaggedObject dependent2 
) [inline]

bool GetCachedResult3Dep ( T &  retResult,
const TaggedObject dependent1,
const TaggedObject dependent2,
const TaggedObject dependent3 
) [inline]

void AddCachedResult1Dep ( const T &  result,
const TaggedObject dependent1 
) [inline]

void AddCachedResult2Dep ( const T &  result,
const TaggedObject dependent1,
const TaggedObject dependent2 
) [inline]

void AddCachedResult3Dep ( const T &  result,
const TaggedObject dependent1,
const TaggedObject dependent2,
const TaggedObject dependent3 
) [inline]

bool InvalidateResult ( const std::vector< const TaggedObject * > &  dependents,
const std::vector< Number > &  scalar_dependents 
) [inline]

Invalidates the result for given dependecies.

Sets the stale flag for the corresponding cached result to true if it is found. Returns true, if the result was found.


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

Generated on Fri Sep 26 07:44:25 2008 for SimTKcore by  doxygen 1.5.6