Rumba C++ SDK
maquina::EvalContext Class Referenceabstract

This class holds the evaluation context passed to the evaluation handler during a plug evaluation. More...

#include <EvalContext.h>

Public Member Functions

virtual ~EvalContext ()
 
virtual int value_count () const =0
 Returns the number of dependencies value available. More...
 
virtual float frame (int index) const =0
 
virtual float evaluation_time () const =0
 
virtual bool evaluate_default () const =0
 
virtual Value value (int index) const =0
 Returns the n-th dependency value. More...
 
virtual bool as_bool (int index) const =0
 Returns the n-th dependency value as a bool. More...
 
virtual int as_int (int index) const =0
 Returns the n-th dependency value as an integer. More...
 
virtual float as_float (int index) const =0
 Returns the n-th dependency value as a float. More...
 
virtual double as_double (int index) const =0
 Returns the n-th dependency value as a double. More...
 
virtual const std::string & as_string (int index) const =0
 Returns the n-th dependency value as a string. More...
 
virtual std::wstring as_wstring (int index) const =0
 Returns the n-th dependency value as a wide string. More...
 
virtual const Imath::V2das_V2d (int index) const =0
 Returns the n-th dependency value as a V2d. More...
 
virtual const Imath::V3das_V3d (int index) const =0
 Returns the n-th dependency value as a V3d. More...
 
virtual const Imath::V4das_V4d (int index) const =0
 Returns the n-th dependency value as a V4d. More...
 
virtual const Imath::V2ias_V2i (int index) const =0
 Returns the n-th dependency value as a V2i. More...
 
virtual const Imath::V3ias_V3i (int index) const =0
 Returns the n-th dependency value as a V3i. More...
 
virtual const Imath::V4ias_V4i (int index) const =0
 Returns the n-th dependency value as a V4i. More...
 
virtual const Imath::M44das_M44d (int index) const =0
 Returns the n-th dependency value as a M44d. More...
 
virtual const Imath::Box3fas_Box3f (int index) const =0
 Returns the n-th dependency value as a Box3f. More...
 
virtual const Imath::Quatdas_Quatd (int index) const =0
 Returns the n-th dependency value as a Quatd. More...
 
virtual const Imath::Color4fas_Color4f (int index) const =0
 Returns the n-th dependency value as a Color4f. More...
 
virtual std::shared_ptr< const UserDataas_user_data (int index) const =0
 Returns the n-th dependency value as a user data. More...
 
virtual maquina::Plug plug () const =0
 
virtual maquina::Plug plug (int index) const =0
 Returns the n-th dependency plug. More...
 
virtual bool is_valid (int index) const =0
 Tell if the n-th value is valid. More...
 
virtual bool is_interactive () const =0
 Tell if the evaluation is done during an interactive session. More...
 
virtual std::pair< maquina::Value, maquina::PartialInvalidationPtrpartial_invalidation () const =0
 Returns the previous cached of the currently evaluated plug if available. If not, the second member is nullptr and value is Value::default_value. More...
 

Detailed Description

This class holds the evaluation context passed to the evaluation handler during a plug evaluation.

Use this interface to query the dependency count and the dependencies value. This interface is implemented by the application.

using namespace maquina;
// Compute the sum of the dependencies
Value eval_handler(EvalContext &ctx)
{
const auto count = ctx.value_count();
float sum = 0.f
for (int i = 0; i < count; ++i)
sum += ctx.as_double(i);
// The evaluation handler must return a valid Value
return sum;
}

Constructor & Destructor Documentation

◆ ~EvalContext()

virtual maquina::EvalContext::~EvalContext ( )
inlinevirtual

Member Function Documentation

◆ as_bool()

virtual bool maquina::EvalContext::as_bool ( int  index) const
pure virtual

Returns the n-th dependency value as a bool.

You must be sure this value is an integer, a float or a boolean or you get false.

Parameters
[in]indexindex of the dependency to query

◆ as_Box3f()

virtual const Imath::Box3f& maquina::EvalContext::as_Box3f ( int  index) const
pure virtual

Returns the n-th dependency value as a Box3f.

You must be sure this value is a Box3f or you will have an empty box.

Parameters
[in]indexindex of the dependency to query

◆ as_Color4f()

virtual const Imath::Color4f& maquina::EvalContext::as_Color4f ( int  index) const
pure virtual

Returns the n-th dependency value as a Color4f.

You must be sure this value is a Color4f or you will have a default value.

Parameters
[in]indexindex of the dependency to query

◆ as_double()

virtual double maquina::EvalContext::as_double ( int  index) const
pure virtual

Returns the n-th dependency value as a double.

You must be sure this value is an integer, a float or a boolean or you get 0.0.

Parameters
[in]indexindex of the dependency to query

◆ as_float()

virtual float maquina::EvalContext::as_float ( int  index) const
pure virtual

Returns the n-th dependency value as a float.

You must be sure this value is an integer, a float or a boolean or you get 0.0.

Parameters
[in]indexindex of the dependency to query

◆ as_int()

virtual int maquina::EvalContext::as_int ( int  index) const
pure virtual

Returns the n-th dependency value as an integer.

You must be sure this value is an integer, a float or a boolean or you get 0.

Parameters
[in]indexindex of the dependency to query

◆ as_M44d()

virtual const Imath::M44d& maquina::EvalContext::as_M44d ( int  index) const
pure virtual

Returns the n-th dependency value as a M44d.

You must be sure this value is a M44d or you will have an identity matrix.

Parameters
[in]indexindex of the dependency to query

◆ as_Quatd()

virtual const Imath::Quatd& maquina::EvalContext::as_Quatd ( int  index) const
pure virtual

Returns the n-th dependency value as a Quatd.

You must be sure this value is a Quatd or you will have an identity quaternion.

Parameters
[in]indexindex of the dependency to query

◆ as_string()

virtual const std::string& maquina::EvalContext::as_string ( int  index) const
pure virtual

Returns the n-th dependency value as a string.

You must be sure this value is a string or you will have an empty string.

Parameters
[in]indexindex of the dependency to query

◆ as_user_data()

virtual std::shared_ptr<const UserData> maquina::EvalContext::as_user_data ( int  index) const
pure virtual

Returns the n-th dependency value as a user data.

You must be sure this value is a user data or you will have a nullptr.

Parameters
[in]indexindex of the dependency to query

◆ as_V2d()

virtual const Imath::V2d& maquina::EvalContext::as_V2d ( int  index) const
pure virtual

Returns the n-th dependency value as a V2d.

You must be sure this value is a V2d or you will have {0,0}.

Parameters
[in]indexindex of the dependency to query

◆ as_V2i()

virtual const Imath::V2i& maquina::EvalContext::as_V2i ( int  index) const
pure virtual

Returns the n-th dependency value as a V2i.

You must be sure this value is a V2i or you will have {0,0}.

Parameters
[in]indexindex of the dependency to query

◆ as_V3d()

virtual const Imath::V3d& maquina::EvalContext::as_V3d ( int  index) const
pure virtual

Returns the n-th dependency value as a V3d.

You must be sure this value is a V3d or you will have {0,0,0}.

Parameters
[in]indexindex of the dependency to query

◆ as_V3i()

virtual const Imath::V3i& maquina::EvalContext::as_V3i ( int  index) const
pure virtual

Returns the n-th dependency value as a V3i.

You must be sure this value is a V3i or you will have {0,0,0}.

Parameters
[in]indexindex of the dependency to query

◆ as_V4d()

virtual const Imath::V4d& maquina::EvalContext::as_V4d ( int  index) const
pure virtual

Returns the n-th dependency value as a V4d.

You must be sure this value is a V4d or you will have {0,0,0,0}.

Parameters
[in]indexindex of the dependency to query

◆ as_V4i()

virtual const Imath::V4i& maquina::EvalContext::as_V4i ( int  index) const
pure virtual

Returns the n-th dependency value as a V4i.

You must be sure this value is a V4i or you will have {0,0,0,0}.

Parameters
[in]indexindex of the dependency to query

◆ as_wstring()

virtual std::wstring maquina::EvalContext::as_wstring ( int  index) const
pure virtual

Returns the n-th dependency value as a wide string.

You must be sure this value is a string or you will have an empty string.

Parameters
[in]indexindex of the dependency to query

◆ evaluate_default()

virtual bool maquina::EvalContext::evaluate_default ( ) const
pure virtual

Check the evaluation is done for the default value.

Returns true if the evaluation is computing a default value.

◆ evaluation_time()

virtual float maquina::EvalContext::evaluation_time ( ) const
pure virtual

Get the evaluation time.

This value can be used to read the value from a custom cache (be sure to use Plug::force_varying(true) when the cache is time varying).

◆ frame()

virtual float maquina::EvalContext::frame ( int  index) const
pure virtual

Get the frame of an index in a 'all_frames' dependence.

An 'all_frames' dependence takes the form of an Array storing all values of the dependence on the time line. If this array has a size of 1, the dependence is either constant or evaluated at a substep. Otherwise, this function makes the mapping from an index in that array to the corresponding frame.

Parameters
indexIndex in a 'all_frames' array of size greater than one.

◆ is_interactive()

virtual bool maquina::EvalContext::is_interactive ( ) const
pure virtual

Tell if the evaluation is done during an interactive session.

◆ is_valid()

virtual bool maquina::EvalContext::is_valid ( int  index) const
pure virtual

Tell if the n-th value is valid.

Values are always valid except when using temporal dependencies. Some temporal dependencies may have an invalid value, if they are out of the animation range for instance. In that case, the user must make sure the value is valid before to get it.

◆ partial_invalidation()

virtual std::pair<maquina::Value, maquina::PartialInvalidationPtr> maquina::EvalContext::partial_invalidation ( ) const
pure virtual

Returns the previous cached of the currently evaluated plug if available. If not, the second member is nullptr and value is Value::default_value.

◆ plug() [1/2]

virtual maquina::Plug maquina::EvalContext::plug ( ) const
pure virtual

Returns the plug evaluated with this context. Make sure to not modify the plug during the evaluation otherwise it will lead to undefined behaviors.

◆ plug() [2/2]

virtual maquina::Plug maquina::EvalContext::plug ( int  index) const
pure virtual

Returns the n-th dependency plug.

◆ value()

virtual Value maquina::EvalContext::value ( int  index) const
pure virtual

Returns the n-th dependency value.

The Value pointer is null if no plug is connected to this dependency entry. If this is an internal dependency set in the Node constructor, you shall assume the Value pointer is valid.

Parameters
[in]indexindex of the dependency to query

◆ value_count()

virtual int maquina::EvalContext::value_count ( ) const
pure virtual

Returns the number of dependencies value available.


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