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)

函数

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

变量

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 OperatorNode<ConversionNode<Float, TimeValue>, 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);
警告
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.
参数
[in] TO The destination type of the conversion.
[in] FROM The source type of the conversion.
[in] flags The conversion flags, take care of setting the correct flags (see warning).