corenodes_conversion.h File Reference

Classes

class  ConversionNode< TO, FROM, typename >
 
class  ConversionSequence
 

Namespaces

 maxon
 
 maxon::corenodes
 

Macros

#define MAXON_CORENODE_REGISTER_CONVERSION(TO, FROM, flags)
 

Typedefs

template<typename TO , typename FROM >
using ConversionNodeBase = OperatorNode< ConversionNode< TO, FROM >, TO(FROM)>
 

Functions

template<typename DEST , typename SRC >
MAXON_WARNING_POP CONVERSION_FLAGS GetScalarConversionFlags ()
 

Variables

constexpr MAXON_WARNING_PUSH LiteralId CORENODE_CONVERT_BASEID
 

Macro Definition Documentation

◆ MAXON_CORENODE_REGISTER_CONVERSION

#define MAXON_CORENODE_REGISTER_CONVERSION (   TO,
  FROM,
  flags 
)

MAXON_CORENODE_REGISTER_CONVERSION registers a conversion core node. The core node compiler uses such nodes to implicitly convert values where required. Also you can ask CoreNodesLib::GetConversion() for a ConversionSequence of several conversion core nodes which is capable of converting from a source type to a destination type.

If the conversion is implemented by a constructor of TO which takes a #FROM argument the MAXON_CORENODE_REGISTER_CONVERSION macro alone is sufficient to implement and register the conversion node. Otherwise you have to specialize the ConversionNode template before you use the MAXON_CORENODE_REGISTER_CONVERSION macro:

template <> class ConversionNode<Float, TimeValue> : public ConversionNodeBase<Float, TimeValue>
{
public:
static ResultOk<void> Process(Float& out, const TimeValue& value)
{
out = value.GetSeconds();
return OK;
}
};
MAXON_CORENODE_REGISTER_CONVERSION(Float, TimeValue, CONVERSION_FLAGS::NONE);
Warning
Take care of properly setting up the flags. The example uses CONVERSION_FLAGS::NONE because there is a one-to-one correspondence between Float and TimeValue. However typically you have narrowing conversions (such as from String to Float) or widening conversions (such as from Float to String), then you must not use CONVERSION_FLAGS::NONE, see CONVERSION_FLAGS. If not set properly the core nodes compiler might implicitly choose undesirable conversions.
Parameters
[in]TOThe destination type of the conversion.
[in]FROMThe source type of the conversion.
[in]flagsThe conversion flags, take care of setting the correct flags (see warning).