ocra-recipes
Doxygen documentation for the ocra-recipes repository
|
Computation ability of a ocra function. More...
#include <IFunction.h>
Public Types | |
typedef ocra_function_traits< Property >::type_t | return_type |
typedef ocra_function_traits< Property >::sub_type_t | return_sub_type |
Protected Member Functions | |
IFunction (const std::vector< bool > &props) | |
IFunction Constructor. More... | |
~IFunction () | |
void | invalidate () |
bool | isValid () const |
bool | canBeComputed () const |
template<class FunctionType > | |
const return_type & | get (FunctionType &data) const |
template<class FunctionType > | |
return_sub_type | get (FunctionType &data, int index) const |
void | resizeData (int m, int n) |
Protected Attributes | |
return_type | _val |
Computation ability of a ocra function.
This class provides a generic way to implement the function ability to compute some mathematical quantity (typical example are its value or some derivatives at a point). This computation is done by the method update which is inherited from ocra_function_traits and its result is accessed by get. IFunction provides an update mechanism around the update method to avoid computing several time the same quantity. To do so it uses a memory _val whose type (return_type) is derived from the value of the template parameter Property to cache the computation result and a boolean to flag the current value as valid or not. This update mechanism requires from the user to overload the virtual function called in update, and to inform of the invalidation of the value. The part where it is decide wether to recompute the value or not and call update if needed is transparent to the user.
IFunction is only meant to be derived and as such does not offer public constructors.
invalidate()
method) and if necessary the computations of others abilities, whenever they change the value of _val. Definition at line 243 of file IFunction.h.
typedef ocra_function_traits<Property>::sub_type_t ocra::IFunction< Property >::return_sub_type |
Definition at line 282 of file IFunction.h.
typedef ocra_function_traits<Property>::type_t ocra::IFunction< Property >::return_type |
Definition of the type of the quantity computed in this class and its subtype. The type is derived from the template parameter of the class. /sa ocra_function_traits, return_type_traits
Definition at line 281 of file IFunction.h.
|
inlineprotected |
IFunction Constructor.
[in] | props | A vector of bool whose element numbered Property indicates wether to use or not this function ability. |
Definition at line 256 of file IFunction.h.
|
inlineprotected |
Definition at line 263 of file IFunction.h.
|
inlineprotected |
Definition at line 293 of file IFunction.h.
|
inlineprotected |
Get the quantity computed by this function ability. The quantity is recomputed if needed in a transparent way for the user.
[in] | data | The actual class instance on which to call the update function. It should be *this . |
Definition at line 322 of file IFunction.h.
|
inlineprotected |
Get a subpart of the quantity.
[in] | data | The actual class instance on which to call the update function. It should be *this . |
[in] | index | The index of the subpart we're interested in. |
Definition at line 343 of file IFunction.h.
|
inlineprotected |
Flags the cached value _val as invalid, indicating to the get methods the need for recomputation.
Definition at line 287 of file IFunction.h.
|
inlineprotected |
Return the validity of the actual value.
Definition at line 290 of file IFunction.h.
|
inlineprotected |
Resizes _val
according to the size of the function
[in] | m | dimension of the output space of the function |
[in] | n | dimension of the input space of the function |
Definition at line 354 of file IFunction.h.
|
mutableprotected |
Definition at line 363 of file IFunction.h.