ocra-recipes
Doxygen documentation for the ocra-recipes repository
Protected Member Functions | Protected Attributes | List of all members
ocra::IFunction< Property > Class Template Reference

Computation ability of a ocra function. More...

#include <IFunction.h>

Inheritance diagram for ocra::IFunction< Property >:
[legend]
Collaboration diagram for ocra::IFunction< Property >:
[legend]

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_typeget (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
 

Detailed Description

template<eFunctionAbility Property>
class ocra::IFunction< Property >

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.

Warning
: the buffer _val is accessible from the derived classes. It is the responsibilty of those classes to invalidate the gradient computation (with the 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.

Member Typedef Documentation

template<eFunctionAbility Property>
typedef ocra_function_traits<Property>::sub_type_t ocra::IFunction< Property >::return_sub_type

Definition at line 282 of file IFunction.h.

template<eFunctionAbility Property>
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.

Constructor & Destructor Documentation

template<eFunctionAbility Property>
ocra::IFunction< Property >::IFunction ( const std::vector< bool > &  props)
inlineprotected

IFunction Constructor.

Parameters
[in]propsA vector of bool whose element numbered Property indicates wether to use or not this function ability.

Definition at line 256 of file IFunction.h.

template<eFunctionAbility Property>
ocra::IFunction< Property >::~IFunction ( )
inlineprotected

Definition at line 263 of file IFunction.h.

Member Function Documentation

template<eFunctionAbility Property>
bool ocra::IFunction< Property >::canBeComputed ( ) const
inlineprotected
Returns
true if this function ability is used, false otherwise.

Definition at line 293 of file IFunction.h.

template<eFunctionAbility Property>
template<class FunctionType >
const return_type& ocra::IFunction< Property >::get ( FunctionType &  data) const
inlineprotected

Get the quantity computed by this function ability. The quantity is recomputed if needed in a transparent way for the user.

Parameters
[in]dataThe actual class instance on which to call the update function. It should be *this.
Returns
the value of the quantity.
Precondition
_used==true. If this is not the case, no physical memory is allocated for the buffer and computation will fail or worse result in a buffer overflow.
Warning
Since there are no exeption throws in case the precondition is violated, a high-level usage should make its own check by calling first canBeComputed.

Definition at line 322 of file IFunction.h.

template<eFunctionAbility Property>
template<class FunctionType >
return_sub_type ocra::IFunction< Property >::get ( FunctionType &  data,
int  index 
) const
inlineprotected

Get a subpart of the quantity.

Parameters
[in]dataThe actual class instance on which to call the update function. It should be *this.
[in]indexThe index of the subpart we're interested in.
Returns
the subvalue of the quantity with index .
See also
get(FunctionType&)

Definition at line 343 of file IFunction.h.

template<eFunctionAbility Property>
void ocra::IFunction< Property >::invalidate ( )
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.

template<eFunctionAbility Property>
bool ocra::IFunction< Property >::isValid ( ) const
inlineprotected

Return the validity of the actual value.

Definition at line 290 of file IFunction.h.

template<eFunctionAbility Property>
void ocra::IFunction< Property >::resizeData ( int  m,
int  n 
)
inlineprotected

Resizes _val according to the size of the function

Parameters
[in]mdimension of the output space of the function
[in]ndimension of the input space of the function

Definition at line 354 of file IFunction.h.

Member Data Documentation

template<eFunctionAbility Property>
return_type ocra::IFunction< Property >::_val
mutableprotected

Definition at line 363 of file IFunction.h.


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