micronodes_ports.h File Reference

Classes

struct  PortTypeWrapper< T >
 
class  DirectPortAccess< PORT, OWNER >
 
class  MappedPortAccess< PORT, OWNER >
 
class  PortOps< ACCESS, WRITE >
 
class  PortOps< ACCESS, true >
 
class  PortDef< C >
 
class  PortArrayAccess< T, ACCESS >
 
struct  Select< PORT, MODE, OWNER >
 
class  PortMembers< PORTS >
 
struct  PortsMode< M >
 
struct  PortsAccessHelper< MODE, PORTS >
 
struct  PortsAccessHelper< MODE, PortsMode< MODE2 >, PORTS... >
 
struct  UnannotatedType< T >
 
class  MicroNode::Lazy< PORT >
 
class  MicroNode::Lazy< PORT >::Port< OWNER >
 
class  MicroNode::PortsAccess< PMODE, PORTS >
 
class  MicroNode::PortsAccess< PMODE, PORTS >::InputMembers
 
class  MicroNode::PortsAccess< PMODE, PORTS >::OutputMembers
 
class  MicroNode::PortsAccess< PMODE, PORTS >::ReductionMembers
 
class  MicroNode::PortsAccess< PMODE, PORTS >::Members
 
class  MicroNode::PortsAccess< PMODE, PORTS >::Iterator< REF >
 

Namespaces

 maxon
 
 maxon::corenodes
 
 maxon::corenodes::details
 

Macros

#define MAXON_PORT_INPUT(T, name, ...)
 
#define MAXON_PORT_INPUT_LAMBDA(T, name)
 
#define MAXON_PORT_INPUT_NAMED(T, name, portId, ...)
 
#define MAXON_PORT_OUTPUT(T, name, ...)
 
#define MAXON_PORT_OUTPUT_NAMED(T, name, portId, ...)
 
#define MAXON_PORT_OUTPUT_LOCAL(T, name, ...)
 
#define PRIVATE_MAXON_PORT(W, name, portId, idtype, mtype, flags, mode, allowed)
 
#define PRIVATE_MAXON_PORT_INPUT(W, name, portId, MICROFLAGS)
 
#define PRIVATE_MAXON_PORT_OUTPUT(W, name, portId, MICROFLAGS)
 
#define PRIVATE_MAXON_PORT_LCV(W, name, portId, MICROFLAGS)
 
#define MAXON_PORT_LCV(T, name, ...)
 
#define MAXON_PORT_LCV_NAMED(T, name, portId, ...)
 
#define MAXON_PORT_LCV_LOCAL(T, name, ...)
 
#define PRIVATE_MAXON_PORT_REDUCTION(W, name, portId, MICROFLAGS)
 
#define PRIVATE_MAXON_REDUCTION_PORT(T, name, mtype, MICROFLAGS)
 
#define MAXON_PORT_REDUCTION(T, name, ...)
 
#define MAXON_PORT_REDUCTION_NAMED(T, name, portId, ...)
 
#define MAXON_PORT_REDUCTION_LOCAL(T, name, ...)
 

Typedefs

template<typename T >
using MyBegin = typename T::Begin
 
template<typename T >
using UnannotatedTypeHelper = typename SubstituteType< T, UnannotatedType >::type
 

Functions

template<typename T >
PortTypeWrapper< T > GetPortTypeWrapper ()
 
template<const auto & A>
std::decay_t< decltype(A)> GetPortTypeWrapper ()
 

Variables

static constexpr Char g_internalPortPrefix
 
static constexpr Char g_variadicPortIdSeparator
 

Macro Definition Documentation

◆ MAXON_PORT_INPUT

#define MAXON_PORT_INPUT (   T,
  name,
  ... 
)

Defines an input port of a micro node group with the given type and name. The macro has to be used within a micro node group implementation class, see MicroNodeGroupInterface for a complete example.

To be accessible within the Process method of a micro node, you have to add the port to the port list of the BasicMicroNode::Ports or BasicMicroNode::Batch template for the Process methods's parameter. Within the method you can use two operations on the port:

  • {ports.name()} returns the value of the input port.
  • {ports.name.HasValue()} returns true if the port has some explicitly given value (such as a default value or a value coming from a connected upstream port), false otherwise.

The following code shows the usage of MAXON_PORT_INPUT:

class MySquareRoot
{
public:
// Declaration of the input and output ports of the micro node group.
MAXON_PORT_INPUT(Float, input);
MAXON_PORT_OUTPUT(Float, result);
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.
MAXON_ATTRIBUTE_FORCE_RELEASE_INLINE Result<void> Process(const Ports<input, result>& ports) const
{
// Read value from input port.
Float x = ports.input();
// Check if the input port has a user-defined value.
Bool hasValue = ports.input.HasValue();
...
return OK;
}
};
...
};
Parameters
[in]TThe type of the port or a MAXON_ATTRIBUTE. In the latter case type and port id are taken from the attribute.
[in]nameThe name of the port.
[in]...Optional MicroNode::FLAGS for the port.

◆ MAXON_PORT_INPUT_LAMBDA

#define MAXON_PORT_INPUT_LAMBDA (   T,
  name 
)

◆ MAXON_PORT_INPUT_NAMED

#define MAXON_PORT_INPUT_NAMED (   T,
  name,
  portId,
  ... 
)

Defines a named input port with an id that can differ from the name.

See also
MAXON_PORT_INPUT, split name parameter into name + portId. portId supports any constexpr type, hardcoded strings, attribute, LiteralId.

◆ MAXON_PORT_OUTPUT

#define MAXON_PORT_OUTPUT (   T,
  name,
  ... 
)

Defines an output port of a micro node group with the given type and name. The macro has to be used within a micro node group implementation class, see MicroNodeGroupInterface for a complete example.

To be accessible within the Process method of a micro node, you have to add the port to the port list of the BasicMicroNode::Ports or BasicMicroNode::Batch template for the Process methods's parameter. Within the method you can use several operations on the port:

  • {ports.name.Update(v)} updates the output value with v. Update checks if the value differs from the previous value, and also updates the modification stamp in that case.
  • {ports.name.GetWritable()} returns an l-value-reference to the value of the output port. You can modify the value through that reference. The modification stamp of the port's value is automatically updated by the call to GetWritable(), whether there will be a subsequent modification of the value or not.
  • {ports.name.GetWritableTouchLater()} returns an l-value-reference to the value of the output port. You can modify the value through that reference. If you have made some modification, you have to make sure to update the modification stamp of the port's value by a call to Touch(), otherwise downstream parts of the core node graph might not get re-evaluated.
  • {ports.name.Touch()} updates the modification stamp of the port value. You have to call this after GetWritableTouchLater() if you've made an actual modification.
  • {ports.name.IsNeeded()} returns true if the port's value is needed at all, false otherwise. This is useful for micro nodes with multiple output ports where only some of them are needed by downstream parts of the core node graph to avoid unnecessary, time-consuming computations. If the micro node has just a single output port this isn't needed because the micro node won't be evaluated if the output port's value isn't used.
  • {ports.name.IsTimeStamped()} returns true if the port's value is time-stamped, false otherwise.

The following code shows the usage of MAXON_PORT_OUTPUT:

class MySquareRoot
{
public:
// Declaration of the input and output ports of the micro node group.
MAXON_PORT_INPUT(Float, input);
MAXON_PORT_OUTPUT(Float, result);
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.
MAXON_ATTRIBUTE_FORCE_RELEASE_INLINE Result<void> Process(const Ports<input, result>& ports) const
{
Float x = ports.input();
// Update the port's value, this will only update the time stamp if the new value differs from the previous one.
ports.result.Update(Sqrt(x));
// Directly set the port's value, this will always update the time stamp.
ports.result.GetWritable() = Sqrt(x);
// Same as above.
Float& r = ports.result.GetWritable();
r = Sqrt(x);
// GetWritableTouchLater() returns a writable reference for the port value. When you modify the referenced value
// you have to make sure to call Touch() on the port to update the time stamp.
Float& s = ports.result.GetWritableTouchLater();
if (s * s != x)
{
// Current value of output port isn't the square root of x, recompute and update time stamp.
// (In practice one wouldn't use this optimization for something as simple as Sqrt.)
s = Sqrt(x);
ports.result.Touch();
}
// Check if the value of the output port is actually needed.
Bool needed = ports.result.IsNeeded();
// Check if the output port is time-stamped.
Bool timeStamped = ports.result.IsTimeStamped();
return OK;
}
};
...
};
Parameters
[in]TThe type of the port or a MAXON_ATTRIBUTE. In the latter case type and port id are taken from the attribute.
[in]nameThe name of the port.
[in]...Optional MicroNode::FLAGS for the port.

◆ MAXON_PORT_OUTPUT_NAMED

#define MAXON_PORT_OUTPUT_NAMED (   T,
  name,
  portId,
  ... 
)

Defines a named output port with an id that can differ from the name.

See also
MAXON_PORT_INPUT, split name parameter into name + portId. portId supports any constexpr type, hardcoded strings, attribute, LiteralId.

◆ MAXON_PORT_OUTPUT_LOCAL

#define MAXON_PORT_OUTPUT_LOCAL (   T,
  name,
  ... 
)

Defines a local output port of a micro node group with the given type and name. A local port isn't exported automatically as a port of the group, instead it can only be used to connect micro nodes within a group.

Parameters
[in]TThe type of the port or a MAXON_ATTRIBUTE. In the latter case type and port id are taken from the attribute.
[in]nameThe name of the port.
[in]...Optional MicroNode::FLAGS for the port.

◆ PRIVATE_MAXON_PORT

#define PRIVATE_MAXON_PORT (   W,
  name,
  portId,
  idtype,
  mtype,
  flags,
  mode,
  allowed 
)

◆ PRIVATE_MAXON_PORT_INPUT

#define PRIVATE_MAXON_PORT_INPUT (   W,
  name,
  portId,
  MICROFLAGS 
)

◆ PRIVATE_MAXON_PORT_OUTPUT

#define PRIVATE_MAXON_PORT_OUTPUT (   W,
  name,
  portId,
  MICROFLAGS 
)

◆ PRIVATE_MAXON_PORT_LCV

#define PRIVATE_MAXON_PORT_LCV (   W,
  name,
  portId,
  MICROFLAGS 
)

◆ MAXON_PORT_LCV

#define MAXON_PORT_LCV (   T,
  name,
  ... 
)

◆ MAXON_PORT_LCV_NAMED

#define MAXON_PORT_LCV_NAMED (   T,
  name,
  portId,
  ... 
)

◆ MAXON_PORT_LCV_LOCAL

#define MAXON_PORT_LCV_LOCAL (   T,
  name,
  ... 
)

◆ PRIVATE_MAXON_PORT_REDUCTION

#define PRIVATE_MAXON_PORT_REDUCTION (   W,
  name,
  portId,
  MICROFLAGS 
)

◆ PRIVATE_MAXON_REDUCTION_PORT

#define PRIVATE_MAXON_REDUCTION_PORT (   T,
  name,
  mtype,
  MICROFLAGS 
)

◆ MAXON_PORT_REDUCTION

#define MAXON_PORT_REDUCTION (   T,
  name,
  ... 
)

◆ MAXON_PORT_REDUCTION_NAMED

#define MAXON_PORT_REDUCTION_NAMED (   T,
  name,
  portId,
  ... 
)

◆ MAXON_PORT_REDUCTION_LOCAL

#define MAXON_PORT_REDUCTION_LOCAL (   T,
  name,
  ... 
)