MicroNodeInterface Class Reference

#include <corenodes_instances.h>

Inheritance diagram for MicroNodeInterface:

详细描述

A MicroNodeInterface instance wraps a MicroNode so that it can be part of a micro node group.

MicroNodeInterface instances aren't created directly, instead you create them by one of the MicroNodeGroupRef::Add functions which get a MicroNode as parameter and impliclity create the required MicroNodeInterface wrapper. For example in the following code

class MyNode { public: ... port declarations ...
class Impl : public BasicMicroNode { public: Result<void> Process(const Ports<...>& ports) const; }; static Result<void> Init(const MicroNodeGroupRef& group) { iferr_scope; MicroNodePtr<Impl> n = group.AddChild<Impl>() iferr_return; ... optionally do something with n, usually not needed ... return OK; } };

the call to Add adds an instance of the BasicMicroNode implementation class Impl to #group and returns a pointer to the MicroNodeInterface instance which wraps the Impl object.

MicroNodeInterface instances are always owned by the enclosing micro node group, therefore there is no reference class.

公共成员函数

const MAXON_FUNCTION MicroNodeGroupInterface GetParentGroup () const
MAXON_FUNCTION MicroNodeGroupInterface GetParentGroup ()
MAXON_METHOD MicroNode::TYPE   GetType () const
const MAXON_METHOD MN &  GetImplementation () const
MicroNode GetImplementation ()
MAXON_METHOD void  AddFlags ( MicroNode::FLAGS flags)
MAXON_METHOD Result < void >  SetDataType (const DataType &type)
template<typename VARIADIC_ACCESS , typename MN >
MAXON_FUNCTION Result < BaseArray < typename VARIADIC_ACCESS::VPort::PortId > >  AddVariadicPort (VARIADIC_ACCESS MN::*acc, const CString &prefix, const 数据 &arg, WIRETYPE wires=VARIADIC_ACCESS::VPort::DEFAULT_WIRE, const DataType &type= GetZeroRef < DataType >(), MicroNode::FLAGS flags= MicroNode::FLAGS::NONE )
template<typename VARIADIC_ACCESS , typename MN >
MAXON_FUNCTION Result < BaseArray < typename VARIADIC_ACCESS::VPort::PortId > >  AddVariadicPort (VARIADIC_ACCESS MN::*acc, const CString &prefix, Int count, Int base=0, WIRETYPE wires=VARIADIC_ACCESS::VPort::DEFAULT_WIRE, MicroNode::FLAGS flags= MicroNode::FLAGS::NONE )
template<typename VARIADIC_ACCESS , typename MN >
MAXON_FUNCTION Result < BaseArray < typename VARIADIC_ACCESS::VPort::PortId > >  AddVariadicPort (VARIADIC_ACCESS MN::*acc, const Block < const Member > &members, WIRETYPE wires=VARIADIC_ACCESS::VPort::DEFAULT_WIRE, MicroNode::FLAGS flags= MicroNode::FLAGS::NONE )
MAXON_METHOD Result < void >  连接 ( ACCESS_INDEX thisIndex, MicroNodeInterface *target, ACCESS_INDEX targetIndex, WIRETYPE wires)
MAXON_FUNCTION Result < void >  连接 ( MicroNodeInterface *target, WIRETYPE wires)
MAXON_FUNCTION Result < InPortId Export (const InPortId &parentPort, WIRETYPE wires= WIRETYPE::DEFAULT_INPUT , ACCESS_INDEX index= ACCESS_INDEX::UNUSED , const DataType &type= DataType::NullValue (), MicroNode::FLAGS flags= MicroNode::FLAGS::NONE )
MAXON_FUNCTION Result < OutPortId Export (const OutPortId &parentPort, WIRETYPE wires= WIRETYPE::DEFAULT_OUTPUT , ACCESS_INDEX index= ACCESS_INDEX::UNUSED , const DataType &type= DataType::NullValue (), MicroNode::FLAGS flags= MicroNode::FLAGS::NONE )
template<typename PORT >
MAXON_FUNCTION Result < typename PORT::PortIdType >  Export (const PORT &parentPort, WIRETYPE wires=PORT::PortIdType::DEFAULT_WIRE, ACCESS_INDEX index= ACCESS_INDEX::UNUSED , MicroNode::FLAGS flags= MicroNode::FLAGS::NONE )
template<typename MN , typename A , typename... ARGS>
MAXON_FUNCTION Result < void >  operator() ( Result < A > &&arg, ARGS &&... args)
template<typename MN , typename A , typename... ARGS>
MAXON_FUNCTION Result < void >  operator() (A &&arg, ARGS &&... args)
-  Public Member Functions inherited from CoreNodeInstanceBaseInterface
const MAXON_METHOD Id GetName () const
MAXON_METHOD void  SetName (const Id &name)
const MAXON_METHOD CoreNodeBaseInterface GetParentGroup () const
MAXON_FUNCTION CoreNodeBaseInterface GetParentGroup ()
const MAXON_METHOD NodeHandle *  GetHandle () const
template<typename... INSTANCEPATH>
MAXON_FUNCTION Result < const NodeHandle * >  GetHandle (const INSTANCEPATH &... path) const
MAXON_FUNCTION String   ToString (const FormatStatement *fmt=nullptr) const

私有成员函数

  MAXON_INTERFACE_NONVIRTUAL_DERIVED ( MicroNodeInterface , MAXON_REFERENCE_POINTER , "net.maxon.corenode.interface.micronode")
  MAXON_GENERIC ((std::is_base_of) typename MN= MicroNode )
MAXON_METHOD Result < Int ExportImpl (const PortId &parentPort, WIRETYPE wires, ACCESS_INDEX index, const DataType &type, MicroNode::FLAGS flags)
template<typename MN >
ResultOk < void >  operator() ()
template<typename MN , typename T , typename = typename std::enable_if<MN::template AllowsChild<T>::value && T::template AllowsParent<MN>::value>::type>
Result < void >  AddChild ( MicroNodePtr < T > mn, WIRETYPE wt= WIRETYPE::DOMAIN_FLOW | WIRETYPE::HIERARCHY )

Additional Inherited Members

-  Static Public Member Functions inherited from CoreNodeInstanceBaseInterface
static MAXON_METHOD Result < BaseArray < const CoreNodeInstanceBaseInterface * > >  GetInstancePath (const NodeHandle *handle)

成员函数文档编制

◆  MAXON_INTERFACE_NONVIRTUAL_DERIVED()

MAXON_INTERFACE_NONVIRTUAL_DERIVED ( MicroNodeInterface   ,
MAXON_REFERENCE_POINTER   ,
"net.maxon.corenode.interface.micronode"   
)
private

◆  MAXON_GENERIC()

MAXON_GENERIC ( (std::is_base_of) typename  MN = MicroNode )
private

The type of the micro node implementation class of this micro node.

◆  GetParentGroup() [1/2]

const MAXON_FUNCTION MicroNodeGroupInterface * GetParentGroup ( ) const

Returns the micro node group to which this micro node belongs.

返回
The parent group of this micro node.

◆  GetParentGroup() [2/2]

MAXON_FUNCTION MicroNodeGroupInterface * GetParentGroup ( )

Returns the micro node group to which this micro node belongs.

返回
The parent group of this micro node.

◆  GetType()

MAXON_METHOD MicroNode::TYPE GetType ( ) const

Returns the type of this micro node. This is the type of the MicroNode implementation wrapped by this node.

返回
The type of this node.

◆  GetImplementation() [1/2]

const MAXON_METHOD MN& GetImplementation ( ) const

Returns the MicroNode implementation which is wrapped by this MicroNodeInterface instance.

返回
The implementation type of this node.

◆  GetImplementation() [2/2]

MicroNode & GetImplementation ( )

Returns the MicroNode implementation which is wrapped by this MicroNodeInterface instance.

返回
The implementation type of this node.

◆  AddFlags()

MAXON_METHOD void AddFlags ( MicroNode::FLAGS   flags )

Adds additional flags to the micro node.

参数
[in] flags The flags to add. Only modifier flags ( MicroNode::FLAGS::MODIFIERS ) can be added.

◆  SetDataType()

MAXON_METHOD Result <void> SetDataType ( const DataType type )

Sets the data type of this micro node. This is only supported for a subset of micro nodes.

参数
[in] type The data type of this micro node.

◆  AddVariadicPort() [1/3]

MAXON_FUNCTION Result < BaseArray <typename VARIADIC_ACCESS::VPort::PortId> > AddVariadicPort ( VARIADIC_ACCESS MN::*  acc ,
const CString prefix ,
const 数据 arg ,
WIRETYPE   wires = VARIADIC_ACCESS::VPort::DEFAULT_WIRE ,
const DataType type = GetZeroRef<DataType>() ,
MicroNode::FLAGS   flags = MicroNode::FLAGS::NONE  
)

Adds a variadic port to this micro node. The number and names of the variadic port instances are determined from arg:

The typical use looks as follows:

template <typename T> class SumNode { public: MAXON_PORT_OUTPUT(T, out); class Impl : public BasicMicroNode { public: Result<void> Process(const Ports<out>& ports) const { T sum = T(); for (auto input : _inputs(ports)) sum += input(); ports.out.Update(sum); return OK; } typename VariadicPort<const T>::Access _inputs; }; static Result<void> Init(const MicroNodeGroupRef& group, const DataDictionary& args) { iferr_scope; MicroNodePtr<Impl> base = group.AddChild<Impl>() iferr_return; base.AddVariadicPort(&Impl::_inputs, "in"_cs, args.Get(Id("in"), Data())) iferr_return; return OK; } };
参数
[in] acc Pointer-to-member for a member of the micro node implementation MN of type VariadicPort<const T>::Access. This member can be used in the micro node implementation to loop over the port instances.
[in] prefix A name prefix.
[in] arg This controls the number and names of the port instances, see above.
[in] wires The wires to use for the connection to the port instances.
[in] type The type to use for the variadic ports. By default this is the type of #acc.
[in] flags Additional flags for the created ports.
返回
Array of identifiers for the variadic port instances.

◆  AddVariadicPort() [2/3]

MAXON_FUNCTION Result < BaseArray <typename VARIADIC_ACCESS::VPort::PortId> > AddVariadicPort ( VARIADIC_ACCESS MN::*  acc ,
const CString prefix ,
Int   count ,
Int   base = 0 ,
WIRETYPE   wires = VARIADIC_ACCESS::VPort::DEFAULT_WIRE ,
MicroNode::FLAGS   flags = MicroNode::FLAGS::NONE  
)

Adds a variadic port to this micro node. See the other AddVariadicPort function for a description. This functions differs from the other one in how the variadic ports are given: count is the number of variadic ports, and the names are given by the prefix, then a # and finally an index which starts with #base. If #base is negative, count has to be 1, then the name of the single port is just the prefix plus #.

参数
[in] acc Pointer-to-member for a member of the micro node implementation MN of type VariadicPort<const T>::Access. This member can be used in the micro node implementation to loop over the port instances.
[in] prefix A name prefix.
[in] count The number of port instances to create.
[in] base The base to use for name counting.
[in] wires The wire types to use for the connection to the port instances.
[in] flags Additional flags for the created ports.
返回
Array of identifiers for the variadic port instances.

◆  AddVariadicPort() [3/3]

MAXON_FUNCTION Result < BaseArray <typename VARIADIC_ACCESS::VPort::PortId> > AddVariadicPort ( VARIADIC_ACCESS MN::*  acc ,
const Block < const Member > &  members ,
WIRETYPE   wires = VARIADIC_ACCESS::VPort::DEFAULT_WIRE ,
MicroNode::FLAGS   flags = MicroNode::FLAGS::NONE  
)

◆  Connect() [1/2]

MAXON_METHOD Result <void> Connect ( ACCESS_INDEX   thisIndex ,
MicroNodeInterface target ,
ACCESS_INDEX   targetIndex ,
WIRETYPE   wires  
)

Adds a connection from this micro node to the target micro node. thisIndex and targetIndex control at which index the Process methods of #this and target produce/receive the value transported by the connection.

To connect a micro node with a port of its enclosing group, use Export() .

参数
[in] thisIndex The index of the parameter of this micro node which shall be transported along the connection. Use ACCESS_INDEX::UNUSED when this is not needed.
[in] target Another micro node.
[in] targetIndex The index of the parameter of the target micro node which shall receive the transported value of the connection. Use ACCESS_INDEX::UNUSED when this is not needed.
[in] wires The wires to use for the connection. Already existing wires aren't changed. Wires which aren't supported by both ends are ignored.

◆  Connect() [2/2]

MAXON_FUNCTION Result <void> Connect ( MicroNodeInterface target ,
WIRETYPE   wires  
)

Adds a connection from this micro node to the target micro node. If it is necessary to specify at least one ACCESS_INDEX for the connection, use the other Connect() 方法。

To connect a micro node with a port of its enclosing group, use Export() .

参数
[in] target Another micro node.
[in] wires The wires to use for the connection. Already existing wires aren't changed. Wires which aren't supported by both ends are ignored.

◆  Export() [1/3]

MAXON_FUNCTION Result < InPortId > Export ( const InPortId parentPort ,
WIRETYPE   wires = WIRETYPE::DEFAULT_INPUT ,
ACCESS_INDEX   index = ACCESS_INDEX::UNUSED ,
const DataType type = DataType::NullValue() ,
MicroNode::FLAGS   flags = MicroNode::FLAGS::NONE  
)

Exports an input parameter of this micro node to a port of the enclosing group. This is only needed for built-in micro nodes, custom micro nodes automatically export their ports according to the parameters of the Process method.

If parentPort is given by a name for which there is no port yet, a corresponding port is created at the enclosing group. If parentPort is empty or has an empty name, the name of this micro node is used instead of parentPort.

参数
[in] parentPort A port of the enclosing group.
[in] wires The wires to use for the export connection. Already existing wires aren't changed. Wires which aren't supported by this micro node are ignored.
[in] index The index of the input parameter of this micro node which shall be exported. Use ACCESS_INDEX::UNUSED (the default) when this is not needed.
[in] type An optional type for the exported port. This is combined with the current type of the exported port, which may result in an error if the types can't be combined.
[in] flags Optional flags for the input port.

◆  Export() [2/3]

MAXON_FUNCTION Result < OutPortId > Export ( const OutPortId parentPort ,
WIRETYPE   wires = WIRETYPE::DEFAULT_OUTPUT ,
ACCESS_INDEX   index = ACCESS_INDEX::UNUSED ,
const DataType type = DataType::NullValue() ,
MicroNode::FLAGS   flags = MicroNode::FLAGS::NONE  
)

Exports an output parameter of this micro node to a port of the enclosing group. This is only needed for built-in micro nodes, custom micro nodes automatically export their ports according to the parameters of the Process method.

If parentPort is given by a name for which there is no port yet, a corresponding port is created at the enclosing group. If parentPort is empty or has an empty name, the name of this micro node is used instead of parentPort.

参数
[in] parentPort A port of the enclosing group.
[in] wires The wires to use for the export connection. Already existing wires aren't changed. Wires which aren't supported by this micro node are ignored.
[in] index The index of the output parameter of this micro node which shall be exported. Use ACCESS_INDEX::UNUSED (the default) when this is not needed.
[in] type An optional type for the exported port. This is combined with the current type of the exported port, which may result in an error if the types can't be combined.
[in] flags Optional flags for the input port.

◆  Export() [3/3]

MAXON_FUNCTION Result <typename PORT::PortIdType> Export ( const PORT &  parentPort ,
WIRETYPE   wires = PORT::PortIdType::DEFAULT_WIRE ,
ACCESS_INDEX   index = ACCESS_INDEX::UNUSED ,
MicroNode::FLAGS   flags = MicroNode::FLAGS::NONE  
)

Exports a parameter of this micro node to a port of the enclosing group. This is only needed for built-in micro nodes, custom micro nodes automatically export their ports according to the parameters of the Process method.

This function can be used instead of the other Export functions when a port from a MAXON_PORT macro shall be used as argument instead of an index or name. The name of the port, followed by a pair of parentheses, has to be used as argument for parentPort:

class WhileNode { public: MAXON_PORT_INPUT(Bool, condition); static Result<void> Init(const MicroNodeGroupRef& group, const DataDictionary&) { ... MicroNodePtr<WhileConditionMicroNode> it = group.AddChild<WhileConditionMicroNode>() iferr_return; it.Export(condition(), WIRETYPE::DEFAULT, ACCESS_INDEX::INDEX_0) iferr_return; ... } };

For indexed ports you have to specify the indices within the parentheses, MicroNodeGroupInterface::GetPort .

参数
[in] parentPort One of the ports declared by a MAXON_PORT macro within the enclosing group. A parentheses pair, possibly including indices, is needed after the name, see example.
[in] wires The wires to use for the export connection. Already existing wires aren't changed. Wires which aren't supported by this micro node are ignored.
[in] index The index of the parameter of this micro node which shall be exported. Use ACCESS_INDEX::UNUSED (the default) when this is not needed.
[in] flags Optional flags for the input port.

◆  operator()() [1/3]

MAXON_FUNCTION Result <void> operator() ( Result < A > &&  arg ,
ARGS &&...  args  
)

@MAXON_ANNOTATION{returnsThis}

◆  operator()() [2/3]

MAXON_FUNCTION Result <void> operator() ( A &&  arg ,
ARGS &&...  args  
)

@MAXON_ANNOTATION{returnsThis}

◆  ExportImpl()

MAXON_METHOD Result < Int > ExportImpl ( const PortId parentPort ,
WIRETYPE   wires ,
ACCESS_INDEX   index ,
const DataType type ,
MicroNode::FLAGS   flags  
)
private

◆  operator()() [3/3]

ResultOk <void> operator() ( )
private

◆  AddChild()

Result <void> AddChild ( MicroNodePtr < T >  mn ,
WIRETYPE   wt = WIRETYPE::DOMAIN_FLOW | WIRETYPE::HIERARCHY  
)
private