CoreNodesLib Class Reference

#include <corenodes_lib.h>

Detailed Description

CoreNodesLib provides a set of static methods around core nodes.

Static Public Member Functions

static MAXON_METHOD Result< const ConversionSequence * > GetConversion (const DataType &to, const DataType &from, Bool allowIterations=false)
 
static MAXON_METHOD Bool IsEqualConversionSequence (const ConversionSequence &a, const ConversionSequence &b)
 
static MAXON_METHOD Bool IsBetterConversionSequence (const ConversionSequence &a, const ConversionSequence &b)
 
static MAXON_METHOD Result< DataConvert (const ConversionSequence &cs, const ConstDataPtr &value)
 
static MAXON_METHOD Result< DataConvert (const DataType &to, const ConstDataPtr &value)
 
static MAXON_METHOD Result< CoreNode > GetPassThroughNode (const DataType &type)
 
static MAXON_METHOD Result< CoreNode > WrapFunction (const reflection::Function &function)
 
static MAXON_METHOD Optimizer CreateOptimizer (const Block< const ShortCircuitRule > &rules)
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (CoreNodesLib, MAXON_REFERENCE_NONE, "net.maxon.corenode.interface.corenodeslib")
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( CoreNodesLib  ,
MAXON_REFERENCE_NONE  ,
"net.maxon.corenode.interface.corenodeslib"   
)
private

◆ GetConversion()

static MAXON_METHOD Result<const ConversionSequence*> GetConversion ( const DataType to,
const DataType from,
Bool  allowIterations = false 
)
static

Constructs a ConversionSequence from type #from to type #to. The sequence consists of zero to two ConversionNodes. If no suitable sequence can be found, nullptr is returned.

Parameters
[in]toThe destination type.
[in]fromThe source type.
[in]allowIterationsIf this is true, iteration conversions are considered too (such as from a Vector array to Vector).
Returns
A ConversionSequence #from → #to, or nullptr if no such sequence exists.

◆ IsEqualConversionSequence()

static MAXON_METHOD Bool IsEqualConversionSequence ( const ConversionSequence a,
const ConversionSequence b 
)
static

Checks if two conversion sequences are equal (consist of equal conversion nodes). You don't have to call this method explicitly, just use ConversionSequence::operator==.

Parameters
[in]aA conversion sequence.
[in]bAnother conversion sequence.
Returns
True if both conversion sequences are equal, false otherwise.

◆ IsBetterConversionSequence()

static MAXON_METHOD Bool IsBetterConversionSequence ( const ConversionSequence a,
const ConversionSequence b 
)
static

Checks if a conversion sequence is better than another one. You don't have to call this method explicitly, just use ConversionSequence::operator>.

Parameters
[in]aA conversion sequence.
[in]bAnother conversion sequence.
Returns
True if #a is better then #b, false otherwise.

◆ Convert() [1/2]

static MAXON_METHOD Result<Data> Convert ( const ConversionSequence cs,
const ConstDataPtr value 
)
static

Converts a given #value using conversion sequence #cs to the destination type of the conversion sequence.

Parameters
[in]csA conversion sequence.
[in]valueA value to convert. This has to match the source type of #cs, otherwise an error is returned.
Returns
The converted value, or an error if #value can't be converted by #cs.

◆ Convert() [2/2]

static MAXON_METHOD Result<Data> Convert ( const DataType to,
const ConstDataPtr value 
)
static

Converts a given #value to a destination type #to using registered ConversionNodes. This method obtains a ConversionSequence using Convert() and then calls that sequence to convert the #value. If no ConversionSequence can be found a conversion with DataType::Convert() is tried.

Parameters
[in]toThe destination type.
[in]valueA value to convert.
Returns
The converted value, or an error the conversion isn't possible.

◆ GetPassThroughNode()

static MAXON_METHOD Result<CoreNode> GetPassThroughNode ( const DataType type)
static

Constructs a CoreNode which implements a direct pass-through of its single input port to its single output port. Such nodes can be used by Optimizers to set up special cases, for example a multiplication by one can be optimized to a pass-through.

Parameters
[in]typeThe type of the values for the pass-through.
Returns
A CoreNode implementing a pass-through of values of the given #type.

◆ WrapFunction()

static MAXON_METHOD Result<CoreNode> WrapFunction ( const reflection::Function function)
static

Constructs a CoreNode which calls the given #function on execution. The returned CoreNode has input ports for function parameters and a single output port for the function result.

Parameters
[in]functionThe function to be wrapped by a CoreNode.
Returns
A CoreNode which calls #function on execution.

◆ CreateOptimizer()

static MAXON_METHOD Optimizer CreateOptimizer ( const Block< const ShortCircuitRule > &  rules)
static

Creates an Optimizer for a set of ShortCircuitRules, see there for the meaning of the rules. The returned Optimizer will test the rules in the given order and apply the first matching one.

Parameters
[in]rulesA set of rules. The Optimizer doesn't make a copy, to you have to ensure that the rules remain valid during the lifetime of the Optimizer. For example just put the rules in a global static variable as in the example given at ShortCircuitRule.
Returns
An Optimizer using the given #rules.