MicroNodeGroupInterface Class Reference

#include <corenodes.h>

Inheritance diagram for MicroNodeGroupInterface:

Detailed Description

MicroNodeGroupInterface is a group of micro nodes. A micro node group is the most fundamental core node. In the usual case a group consists of just one micro node, then you set up a micro node group with the following pattern:

// This class defines a micro node group which adds two Int values.
class MyAddNode
{
public:
// Declaration of the input and output ports of the micro node group.
MAXON_PORT_INPUT(Int, in1);
MAXON_PORT_INPUT(Int, in2);
MAXON_PORT_OUTPUT(Int, out);
// Implementation of the single custom micro node.
class Impl : public BasicMicroNode
{
public:
// The Process method needs to specify which ports of the group the micro node accesses, in this case all ports.
// If the group contains more than one micro node, each micro node usually needs only a subset of the ports.
Result<void> Process(const Ports<in1, in2, out>& ports) const
{
ports.out.Update(ports.in1() + ports.in2());
return OK;
}
};
// The Init function will be called to set up the micro node group
// when you call CreateNode<MyAddNode>() or as part of the MAXON_CORENODE_REGISTER macro.
static Result<void> Init(const MicroNodeGroupRef& group)
{
iferr_scope;
group.AddChild<Impl>() iferr_return;
return OK;
}
};

The Init function can have additional parameters:

  • When called from one of the MAXON_CORENODE_REGISTER macros there may be one additional parameter of type {const DataDictionary&}. It receives the factory arguments which are passed to the Create method of the CoreNodeFactory registered by the macro. These arguments contain information such as the number of variadic ports to create, see MicroNodeInterface::AddVariadicPort.
  • When called from CreateNode an arbitrary number of extra arguments can be passed from the call to CreateNode to the call to Init.

Classes

struct  PrivateAutoCreatePortInfo
 

Public Member Functions

template<typename MN , typename... ARGS>
MAXON_FUNCTION Result< MicroNodePtr< MN > > AddChild (const Id &name, ARGS &&... args)
 
template<typename MN >
MAXON_FUNCTION Result< MicroNodePtr< MN > > AddChild ()
 
template<typename PORT >
MAXON_FUNCTION Result< typename PORT::PortIdType > GetPort (const PORT &port)
 
template<typename OUTPORT >
MAXON_FUNCTION Result< MicroNodePtr< typename OUTPORT::PortClass::MicroNodeClass > > GetPortMicroNode (const OUTPORT &port)
 
template<typename PORT >
MAXON_FUNCTION Result< void > SetDataType (const PORT &port, const DataType &type)
 
template<typename PORT >
MAXON_FUNCTION Result< void > AddWires (const PORT &port, WIRETYPE wires)
 
 MAXON_ADD_TO_REFERENCE_CLASS (Result< CoreNode > Finalize() { if(!this->GetPointer()) return IllegalArgumentError(MAXON_SOURCE_LOCATION);Result< CoreNode > result=this->GetPointer() ->PrivateFinalize();if(result==OK) this->ResetReference();return result;})
 
MAXON_METHOD Result< CoreNode > PrivateFinalize ()
 
template<typename PORTID >
Result< PORTID > PrivateGetPort (const corenodes::details::SourceCodePortId &pid, const Id &name, const DataType &vtype, WIRETYPE wtypes)
 
template<typename NODECLASS >
Result< void > PrivateAutoCreatePorts (const Generic *arg, Result< DataType >(*getPortType)(const Id &, const Generic *))
 
MAXON_FUNCTION Result< MicroNodePtr<> > CreatePort (const Id &name, MicroNode::TYPE type, MicroNode::FLAGS flags, const DataType &vtype)
 
MAXON_METHOD Result< MicroNodePtr<> > PrivateCreatePort (Int pid, const Id &name, MicroNode::TYPE type, MicroNode::FLAGS flags, const DataType &vtype, Int count)
 
MAXON_METHOD Result< IntPrivateGetPort (const corenodes::details::SourceCodePortId &declId, const PortId &pid, const DataType &vtype, WIRETYPE wtypes)
 
MAXON_METHOD Result< OutPortIdPrivateAddParameter (MicroNodeInterface *paramRoot, Int pid, const DataType &type, const Id &name, MicroNode::TYPE portType, MicroNode::FLAGS flags, const ConstDataPtr &constant, MicroNodeInterface *&portOut)
 
- Public Member Functions inherited from CoreNodeBaseInterface
const MAXON_METHOD IdGetId () const
 
MAXON_METHOD void SetId (const Id &name)
 
MAXON_METHOD CoreNodeFactory GetFactory () const
 
const MAXON_METHOD DataDictionary & GetArguments () const
 
MAXON_METHOD void InitFactory (const CoreNodeFactory &factory, const DataDictionary &args)
 
MAXON_METHOD Bool IsCoreNodeGroup () const
 
MAXON_METHOD Int GetChildCount () const
 
const MAXON_METHOD Interface::Instance * GetChild (Int index) const
 
MAXON_FUNCTION Interface::Instance * GetChild (Int index)
 
const MAXON_METHOD Interface::Instance * FindChild (const Id &name) const
 
MAXON_METHOD Int GetPortCount (PORT_DIR direction) const
 
MAXON_METHOD Int FindPortIndex (const PortId &port) const
 
MAXON_METHOD Result< IntFindValidPortIndex (const PortId &port) const
 
const MAXON_METHOD PortInfoGetPortInfo (const PortId &port) const
 
MAXON_METHOD Result< const PortInfo & > GetValidPortInfo (const PortId &port) const
 
MAXON_METHOD Result< IntAddPort (PORT_DIR direction, const Id &name, const DataType &type)
 
MAXON_METHOD Result< void > AddPassThrough (const InPortId &input, const OutPortId &output, WIRETYPE wires)
 
MAXON_METHOD Result< DataGetValue (const InternedId &attr) const
 
template<typename ATTR >
MAXON_FUNCTION Result< Opt< typename ATTR::ValueType > > GetValue (const ATTR &attr) const
 
MAXON_METHOD Result< void > SetValue (const InternedId &attr, ForwardingDataPtr &&value)
 
template<typename ATTR >
MAXON_FUNCTION Result< void > SetValue (const ATTR &attr, const typename ATTR::ValueType &value)
 
template<typename ATTR >
MAXON_FUNCTION Result< void > SetValue (const ATTR &attr, typename ATTR::ValueType &&value)
 
MAXON_METHOD HashValue GetHashValue () const
 
 MAXON_ATTRIBUTE_CLASS (Bool, Pure, "net.maxon.corenode.pure")
 
 MAXON_ATTRIBUTE_CLASS (maxon::corenodes::Optimizer, Optimizer, "net.maxon.corenode.optimizer")
 
 MAXON_ATTRIBUTE_CLASS (Id, NodeId, "net.maxon.corenode.nodeid")
 
 MAXON_ATTRIBUTE_CLASS (Data, Value, "net.maxon.corenode.value")
 
 MAXON_ATTRIBUTE_CLASS (DataType, Type, "net.maxon.corenode.type")
 
 MAXON_ATTRIBUTE_CLASS (Id, TypeId, "datatype")
 
 MAXON_ATTRIBUTE_CLASS (DataType, InType, "in")
 
 MAXON_ATTRIBUTE_CLASS (DataType, OutType, "out")
 
 MAXON_ATTRIBUTE_CLASS (DataType, SourceType, "net.maxon.corenode.sourcetype")
 
 MAXON_ATTRIBUTE_CLASS (BaseArray< Member >, Members, "net.maxon.corenode.members")
 
 MAXON_ATTRIBUTE_CLASS (Int, Count, "net.maxon.corenode.count")
 
 MAXON_ATTRIBUTE_CLASS (CONVERSION_FLAGS, ConversionFlags, "net.maxon.corenode.conversionflags")
 
 MAXON_ATTRIBUTE_CLASS (String, Message, "net.maxon.corenode.message")
 
 MAXON_ATTRIBUTE_CLASS (ErrorList, Errors, "net.maxon.corenode.errors")
 
 MAXON_ATTRIBUTE_CLASS (Id, VariableId, "net.maxon.corenode.variableid")
 
 MAXON_ATTRIBUTE_CLASS (Array< Id >, Filters, "net.maxon.corenode.filters")
 
MAXON_FUNCTION String ToString (const FormatStatement *fmt=nullptr) const
 

Static Public Member Functions

static MAXON_METHOD MicroNodeGroupInterfaceAlloc (MAXON_SOURCE_LOCATION_DECLARATION)
 
static MAXON_METHOD void PrivateDescribePortAccess (PortsDescription *desc, ACCESS_INDEX index, Int counter, Bool ref)
 
static MAXON_METHOD void PrivateBeginLazy (PortsDescription *desc)
 
static MAXON_METHOD void PrivateEndLazy (PortsDescription *desc)
 

Public Attributes

struct maxon::corenodes::MicroNodeGroupInterface::PrivateAutoCreatePortInfo MAXON_ENUM_FLAGS_CLASS
 

Private Types

using Instance = MicroNodeInterface
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL_DERIVED (MicroNodeGroupInterface, MAXON_REFERENCE_NORMAL, "net.maxon.corenode.interface.micronodegroup")
 
MAXON_METHOD Result< MicroNodePtr<> > AddMicroNode (const Id &name, MicroNode *child)
 
MAXON_METHOD Result< MicroNodePtr<> > PrivateGetMicroNode (const corenodes::details::SourceCodePortId &pid, const Id &name, const DataType &vtype, MicroNode::TYPE ptype, MicroNode::FLAGS flags)
 

Additional Inherited Members

- Public Types inherited from CoreNodeBaseInterface
using ErrorList = Array< Tuple< PortId, Error > >
 

Member Typedef Documentation

◆ Instance

using Instance = MicroNodeInterface
private

This defines the covariant return type of GetChild

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL_DERIVED()

MAXON_INTERFACE_NONVIRTUAL_DERIVED ( MicroNodeGroupInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.corenode.interface.micronodegroup"   
)
private

◆ Alloc()

Creates a new, empty micro node group.

Returns
A new micro node group.

◆ AddChild() [1/2]

MAXON_FUNCTION Result<MicroNodePtr<MN> > AddChild ( const Id name,
ARGS &&...  args 
)

Adds a micro node of class MN to this group using the given name. The created micro node is owned by this group.

Template Parameters
MNThe micro node class to instantiate.
Parameters
[in]nameThe name for the child. Names have to be unique within a group. If an empty name is passed a unique name will be chosen.
[in]argsAdditional arguments, these are forwarded to the constructor of MN.
Returns
A pointer to the micro node instance. The instance is owned by this group.

◆ AddChild() [2/2]

MAXON_FUNCTION Result<MicroNodePtr<MN> > AddChild ( )

Adds a micro node of class MN to this group. The created micro node is owned by this group. A unique name is chosen automatically.

Template Parameters
MNThe micro node class to instantiate.
Returns
A pointer to the micro node instance. The instance is owned by this group.

◆ GetPort()

MAXON_FUNCTION Result<typename PORT::PortIdType> GetPort ( const PORT &  port)

Returns the port id (either InPortId or OutPortId) of the given port. port has to be one of the ports defined by a MAXON_PORT macro, followed by a pair of parentheses as in {group.GetPort(in())}. For indexed ports you have to specify the index within the parentheses:

class MyNode
{
public:
MAXON_PORT_INPUT(Int, index);
MAXON_PORT_INPUT_INDEXED(Float, numbers, 5);
MAXON_PORT_OUTPUT(Float, result);
static Result<void> Init(const MicroNodeGroupRef& group)
{
iferr_scope;
InPortId indexPort = group.GetPort(index()) iferr_return;
for (Int i = 0; i < 5; ++i)
{
// Indexed port numbers needs port index within parentheses.
InPortId numberPort = group.GetPort(numbers(i)) iferr_return;
}
OutPortId resultPort = group.GetPort(result()) iferr_return;
return OK;
}
};
Parameters
[in]portOne of the ports declared by a MAXON_PORT macro (a parentheses pair, possibly including indices, is needed after the name, see example).
Returns
The InPortId or OutPortId of the port.

◆ GetPortMicroNode()

MAXON_FUNCTION Result<MicroNodePtr<typename OUTPORT::PortClass::MicroNodeClass> > GetPortMicroNode ( const OUTPORT &  port)

Returns the micro node which represents the given output port of this group. port has to be one of the ports defined by a MAXON_PORT_OUTPUT macro followed by a pair of parentheses, see GetPort() for more details.

This function can only be used for output ports because input ports aren't represented by micro nodes.

Parameters
[in]portOne of the output ports of this group declared by a MAXON_PORT_OUTPUT macro. A parentheses pair, possibly including indices, is needed after the name, see GetPort().
Returns
The micro node of the output port.

◆ SetDataType()

MAXON_FUNCTION Result<void> SetDataType ( const PORT &  port,
const DataType type 
)

Sets the data type of the given port of this group. port has to be one of the ports defined by a MAXON_PORT macro followed by a pair of parentheses, see GetPort() for more details.

Parameters
[in]portOne of the ports of this group declared by a MAXON_PORT macro. A parentheses pair, possibly including indices, is needed after the name, see GetPort().
[in]typeThe data type to set for port.

◆ AddWires()

MAXON_FUNCTION Result<void> AddWires ( const PORT &  port,
WIRETYPE  wires 
)

◆ MAXON_ADD_TO_REFERENCE_CLASS()

MAXON_ADD_TO_REFERENCE_CLASS ( Result< CoreNode > Finalize() { if(!this->GetPointer()) return IllegalArgumentError(MAXON_SOURCE_LOCATION);Result< CoreNode > result=this->GetPointer() ->PrivateFinalize();if(result==OK) this->ResetReference();return result;}  )

◆ PrivateFinalize()

MAXON_METHOD Result<CoreNode> PrivateFinalize ( )

◆ PrivateGetPort() [1/2]

Result<PORTID> PrivateGetPort ( const corenodes::details::SourceCodePortId pid,
const Id name,
const DataType vtype,
WIRETYPE  wtypes 
)

◆ PrivateAutoCreatePorts()

Result<void> PrivateAutoCreatePorts ( const Generic *  arg,
Result< DataType >(*)(const Id &, const Generic *)  getPortType 
)

◆ CreatePort()

MAXON_FUNCTION Result<MicroNodePtr<> > CreatePort ( const Id name,
MicroNode::TYPE  type,
MicroNode::FLAGS  flags,
const DataType vtype 
)

◆ PrivateCreatePort()

MAXON_METHOD Result<MicroNodePtr<> > PrivateCreatePort ( Int  pid,
const Id name,
MicroNode::TYPE  type,
MicroNode::FLAGS  flags,
const DataType vtype,
Int  count 
)

◆ PrivateGetPort() [2/2]

MAXON_METHOD Result<Int> PrivateGetPort ( const corenodes::details::SourceCodePortId declId,
const PortId pid,
const DataType vtype,
WIRETYPE  wtypes 
)

◆ PrivateAddParameter()

MAXON_METHOD Result<OutPortId> PrivateAddParameter ( MicroNodeInterface paramRoot,
Int  pid,
const DataType type,
const Id name,
MicroNode::TYPE  portType,
MicroNode::FLAGS  flags,
const ConstDataPtr constant,
MicroNodeInterface *&  portOut 
)

◆ PrivateDescribePortAccess()

static MAXON_METHOD void PrivateDescribePortAccess ( PortsDescription *  desc,
ACCESS_INDEX  index,
Int  counter,
Bool  ref 
)
static

◆ PrivateBeginLazy()

static MAXON_METHOD void PrivateBeginLazy ( PortsDescription *  desc)
static

◆ PrivateEndLazy()

static MAXON_METHOD void PrivateEndLazy ( PortsDescription *  desc)
static

◆ AddMicroNode()

MAXON_METHOD Result<MicroNodePtr<> > AddMicroNode ( const Id name,
MicroNode child 
)
private

◆ PrivateGetMicroNode()

MAXON_METHOD Result<MicroNodePtr<> > PrivateGetMicroNode ( const corenodes::details::SourceCodePortId pid,
const Id name,
const DataType vtype,
MicroNode::TYPE  ptype,
MicroNode::FLAGS  flags 
)
private

Member Data Documentation

◆ MAXON_ENUM_FLAGS_CLASS