Wires Struct Reference

#include <graph.h>

Detailed Description

A port connection consists of up to seven independent wires:

  1. The /value/ wire is used to pass data values along the connection.
  2. The /dependency/ wire is only needed for internal connections within evaluation nodes such as core node wrappers. A computed output port needs to have a dependency wire from each input port which is required for its computation.
  3. The /context/ wire connects a port which shall define a context to an input port which introduces that context.
  4. The /hidden/ wire is used mark a connection as hidden. What this means exactly is model-specific, for example NodesGraphModelInterface doesn't show those connections.
  5. The /inhibit/ wire is used to temporarily disable the other wires. When this wire is present, the other wires should be considered as non-existing.
  6. The /slink/ wire is a marker which is used for node-specific purposes, where the source port of the connection determines the meaning. For example it connects the output port of a context parameter node to the input port which introduces the context.
  7. The /tlink/ wire is a marker which is used for node-specific purposes, where the target port of the connection determines the meaning.

In most cases you only need a combination of a value and dependency wire.

The Wires class has the members value, dependency, context, hidden, inhibit, slink, tlink to store information about these wires for a connection. Each of them has the enumeration type WIRE_MODE with the following possible values:

  • WIRE_MODE::NONE means that there is no such wire in the connection. This does not necessarily mean that there is no such wire at all because a wire might be inherited from a base node system, or there may be an implicit wire due to an enclosing connection.
  • WIRE_MODE::MIN, WIRE_MODE::NORMAL and WIRE_MODE::MAX indicate that a wire exists. The values are priorities, so whenever an ambiguity between multiple wires has to be resolved, the wires with highest priority are taken.

The wires of a connection can also be accessed by index, see VALUE, DEPENDENCY, CONTEXT, HIDDEN, INHIBIT, SLINK, TLINK and operator[]. For a loop over the wires you have to use COUNT as upper bound:

for (Int i = 0; i < Wires::COUNT; ++i)
{
// do something with w[i]
}
w.value = WIRE_MODE::NONE;
w[Wires::VALUE] = WIRE_MODE::NONE; // same as line above
Py_ssize_t i
Definition: abstract.h:645
maxon::Int Int
Definition: ge_sys_math.h:60
static const Int COUNT
The number of wires (currently 8). Use this for a loop over all possible wire indices.
Definition: graph.h:160
static const Int VALUE
The index to address the value part, used in operator[] and Wires(Int,WIRE_MODE).
Definition: graph.h:152
constexpr Wires()=default
Constructs an empty Wires object. All wire modes are set to WIRE_MODE::NONE.

A Wires object can also be used as a mask to test another Wires object. Wires masks use the mask values of WIRE_MODE (WIRE_MODE::NONE, WIRE_MODE::ALL, WIRE_MODE::IMPLICIT, WIRE_MODE::ALL_INCLUDING_IMPLICIT, WIRE_MODE::INHERIT, WIRE_MODE::FULL_MASK). Testing against a mask is done by the bitwise operators & and |.

See also
$ref usernodes_wires
MutablePort::Connect
WIRE_MODE

Public Member Functions

constexpr Wires ()=default
 
constexpr MAXON_IMPLICIT Wires (WIRE_MODE mode)
 
 Wires (Int index, WIRE_MODE mode=WIRE_MODE::NORMAL)
 
constexpr Wires (WIRE_MODE val, WIRE_MODE dep)
 
constexpr Wires (WIRE_MODE val, WIRE_MODE dep, WIRE_MODE ctx, WIRE_MODE hid, WIRE_MODE inh, WIRE_MODE sln, WIRE_MODE tln)
 
WIRE_MODE operator[] (Int index) const
 
WIRE_MODEoperator[] (Int index)
 
 operator Bool () const
 
Wiresoperator&= (Wires other)
 
Wires operator& (Wires other) const
 
Wiresoperator|= (Wires other)
 
Wires operator| (Wires other) const
 
Wires operator~ () const
 
Bool operator== (Wires other) const
 
Bool operator!= (Wires other) const
 
HashInt GetHashCode () const
 
UniqueHash GetUniqueHashCode () const
 
Wires Concat (const Wires &other) const
 
Wires Combine (const Wires &other) const
 
Wires MaskByPriority (const Wires &priorityMask) const
 
Wires ToMask () const
 
Wires EqualWires (const Wires &other) const
 
String ToString (const FormatStatement *fs=nullptr) const
 
MAXON_IMPLICIT Wires (UInt64)=delete
 

Static Public Member Functions

static constexpr Wires All (WIRE_MODE mode=WIRE_MODE::ALL)
 
static constexpr Bool TriviallyHashable ()
 

Public Attributes

WIRE_MODE value
 
WIRE_MODE unused
 
WIRE_MODE dependency
 
WIRE_MODE context
 
WIRE_MODE hidden
 
WIRE_MODE inhibit
 
WIRE_MODE slink
 
WIRE_MODE tlink
 

Static Public Attributes

static const Int VALUE
 
static const Int UNUSED
 
static const Int DEPENDENCY
 
static const Int CONTEXT
 
static const Int HIDDEN
 
static const Int INHIBIT
 
static const Int SLINK
 
static const Int TLINK
 
static const Int COUNT
 
static const WIRE_MODE NONE
 

Private Member Functions

UInt64 ToInt () const
 
 Wires (UInt64 i, Bool)
 
constexpr Wires (WIRE_MODE val, WIRE_MODE un, WIRE_MODE dep, WIRE_MODE ctx, WIRE_MODE hid, WIRE_MODE inh, WIRE_MODE sln, WIRE_MODE tln)
 

Constructor & Destructor Documentation

◆ Wires() [1/8]

constexpr Wires ( )
constexprdefault

Constructs an empty Wires object. All wire modes are set to WIRE_MODE::NONE.

◆ Wires() [2/8]

constexpr MAXON_IMPLICIT Wires ( WIRE_MODE  mode)
constexpr

Constructs a normal wire for values and dependencies. The value and dependency members will be set to the given mode, all other members to WIRE_MODE::NONE.

Parameters
[in]modeThe mode to use for the value and dependency wires.

◆ Wires() [3/8]

Wires ( Int  index,
WIRE_MODE  mode = WIRE_MODE::NORMAL 
)
explicit

Constructs a single wire. The wire indexed by the given index will be set to the given mode, all other members to WIRE_MODE::NONE.

Parameters
[in]indexThe index of the wire, one of VALUE, DEPENDENCY, CONTEXT, HIDDEN, INHIBIT, SLINK.
[in]modeThe mode to use for the wire.

◆ Wires() [4/8]

constexpr Wires ( WIRE_MODE  val,
WIRE_MODE  dep 
)
constexpr

Constructs the wires using the given modes.

Parameters
[in]valThe mode for the value wire.
[in]depThe mode for the dependency wire.

◆ Wires() [5/8]

constexpr Wires ( WIRE_MODE  val,
WIRE_MODE  dep,
WIRE_MODE  ctx,
WIRE_MODE  hid,
WIRE_MODE  inh,
WIRE_MODE  sln,
WIRE_MODE  tln 
)
constexpr

Constructs the wires using the given modes.

Parameters
[in]valThe mode for the value wire.
[in]depThe mode for the dependency wire.
[in]ctxThe mode for the context wire.
[in]hidThe mode for the hidden wire.
[in]inhThe mode for the inherit wire.
[in]slnThe mode for the slink wire.
[in]tlnThe mode for the tlink wire.

◆ Wires() [6/8]

MAXON_IMPLICIT Wires ( UInt64  )
delete

◆ Wires() [7/8]

Wires ( UInt64  i,
Bool   
)
private

Only for internal use, dummy Bool parameter to disambiguate constructor calls.

◆ Wires() [8/8]

constexpr Wires ( WIRE_MODE  val,
WIRE_MODE  un,
WIRE_MODE  dep,
WIRE_MODE  ctx,
WIRE_MODE  hid,
WIRE_MODE  inh,
WIRE_MODE  sln,
WIRE_MODE  tln 
)
constexprprivate

Constructs the wires using the given modes.

Parameters
[in]valThe mode for the value wire.
[in]unThe mode for the unused wire.
[in]depThe mode for the dependency wire.
[in]ctxThe mode for the context wire.
[in]hidThe mode for the hidden wire.
[in]inhThe mode for the inherit wire.
[in]slnThe mode for the slink wire.
[in]tlnThe mode for the tlink wire.

Member Function Documentation

◆ operator[]() [1/2]

WIRE_MODE operator[] ( Int  index) const

Returns the mode for the wire indexed by index.

Parameters
[in]indexThe index of the wire, one of VALUE, DEPENDENCY, CONTEXT, HIDDEN, INHIBIT, SLINK, TLINK.
Returns
Mode for the wire.

◆ operator[]() [2/2]

WIRE_MODE& operator[] ( Int  index)

Returns the mode for the wire indexed by index.

Parameters
[in]indexThe index of the wire, one of VALUE, DEPENDENCY, CONTEXT, HIDDEN, INHIBIT, SLINK, TLINK.
Returns
Mode for the wire.

◆ All()

static constexpr Wires All ( WIRE_MODE  mode = WIRE_MODE::ALL)
staticconstexpr

Returns a Wires value where all wire modes are set to the given mode. With the default WIRE_MODE::ALL this can be used as a mask which represents all wires, this is useful as argument to PortTemplate::GetConnections to get all connections.

Parameters
[in]modeThe mode to use for all wires, WIRE_MODE::ALL by default.
Returns
Wires value having all wire modes set to mode.

◆ operator Bool()

operator Bool ( ) const
explicit

Checks if there is any wire.

Returns
True if at least one of the wire modes differs from WIRE_MODE::NONE, false otherwise.

◆ operator&=()

Wires& operator&= ( Wires  other)

Applies a mask to this Wires object. This is implemented by a bitwise and of the underlying integral values.

Parameters
[in]otherA mask. The wire modes of other should only be mask values of WIRE_MODE.
Returns
Reference to this.

◆ operator&()

Wires operator& ( Wires  other) const

Returns the bitwise and of the underlying integral values. This makes sense only if one of the two Wires objects is a mask where the wire modes are mask values of WIRE_MODE.

Parameters
[in]otherAnother Wires object.
Returns
The bitwise and of both Wires object.

◆ operator|=()

Wires& operator|= ( Wires  other)

Adds the wires of other to this Wires object. This is implemented by a bitwise or of the underlying integral values, and it makes sense only if both Wires objects only use mask values of WIRE_MODE, or if they don't have overlapping wires. For a parallel combination of two general Wires see Combine().

Parameters
[in]otherAnother Wires object.
Returns
Reference to this.

◆ operator|()

Wires operator| ( Wires  other) const

Returns the bitwise or of the underlying integral values. This makes sense only if both Wires objects only use mask values of WIRE_MODE, or if they don't have overlapping wires. For a parallel combination of two general Wires see Combine().

Parameters
[in]otherAnother Wires object.
Returns
The bitwise or of both Wires object.

◆ operator~()

Wires operator~ ( ) const

Returns the bitwise inverse of the underlying integral values. This makes sense only if this Wires object is a mask where the wire modes are mask values of WIRE_MODE. Then the returned object is the inverse of this mask.

Returns
The inverse of this mask.

◆ operator==()

Bool operator== ( Wires  other) const

Checks if this @CLASS equals other.

Parameters
[in]otherAnother @CLASS.
Returns
True if this equals other, false otherwise.

◆ operator!=()

Bool operator!= ( Wires  other) const

Checks if this @CLASS is not equal to other.

Parameters
[in]otherAnother @CLASS.
Returns
True if this is not equal to other, false otherwise.

◆ GetHashCode()

HashInt GetHashCode ( ) const

Returns the hash code of this @CLASS.

Returns
Hash code of this @CLASS.

◆ TriviallyHashable()

static constexpr Bool TriviallyHashable ( )
staticconstexpr

◆ GetUniqueHashCode()

UniqueHash GetUniqueHashCode ( ) const

◆ Concat()

Wires Concat ( const Wires other) const

Returns the concatenation of this Wires object and other. This takes the minimum of each wire value.

Parameters
[in]otherAnother Wires object.
Returns
The concatenation (minimum) of the wires.

◆ Combine()

Wires Combine ( const Wires other) const

Returns the parallel combination of this Wires object and other. This takes the maximum of each wire value.

Parameters
[in]otherAnother Wires object.
Returns
The parallel combination (maximum) of the wires.

◆ MaskByPriority()

Wires MaskByPriority ( const Wires priorityMask) const

Returns a Wires object which contains only those wires of this Wires object which aren't below the priority values given in #priorityMask.

Parameters
[in]priorityMaskAnother Wires object.
Returns
Those wires which aren't below the values of #priorityMask.

◆ ToMask()

Wires ToMask ( ) const

Converts this Wires object into a mask which uses WIRE_MODE::FULL_MASK for wires which are set in this Wires object, otherwise WIRE_MODE::NONE.

Returns
Mask object to mask those wires which are present in this Wires object.

◆ EqualWires()

Wires EqualWires ( const Wires other) const

Returns the wire-wise comparison of this and other. This uses WIRE_MODE::FULL_MASK for a wire with the same value in this and other, or WIRE_MODE::NONE if the values differ.

Parameters
[in]otherAnother Wires object.
Returns
Wire-wise comparison of this and other.

◆ ToString()

String ToString ( const FormatStatement fs = nullptr) const

Returns a String representation of this @CLASS.

Parameters
[in]formatStatementNullptr or additional formatting instruction.
Returns
String representation of this @CLASS.

◆ ToInt()

UInt64 ToInt ( ) const
private

Only for internal use.

Member Data Documentation

◆ value

WIRE_MODE value

The mode for the value part of the connection.

◆ unused

WIRE_MODE unused

Unused.

◆ dependency

WIRE_MODE dependency

The mode for the dependency part of the connection.

◆ context

WIRE_MODE context

The mode for the context part of the connection.

◆ hidden

WIRE_MODE hidden

The mode for the hidden part of the connection.

◆ inhibit

WIRE_MODE inhibit

The mode for the inhibit part of the connection.

◆ slink

WIRE_MODE slink

The mode for the slink part of the connection.

◆ tlink

WIRE_MODE tlink

The mode for the tlink part of the connection.

◆ VALUE

const Int VALUE
static

The index to address the value part, used in operator[] and Wires(Int,WIRE_MODE).

◆ UNUSED

const Int UNUSED
static

The index to address the unused part, used in operator[] and Wires(Int,WIRE_MODE).

◆ DEPENDENCY

const Int DEPENDENCY
static

The index to address the dependency part, used in operator[] and Wires(Int,WIRE_MODE).

◆ CONTEXT

const Int CONTEXT
static

The index to address the context part, used in operator[] and Wires(Int,WIRE_MODE).

◆ HIDDEN

const Int HIDDEN
static

The index to address the hidden part, used in operator[] and Wires(Int,WIRE_MODE).

◆ INHIBIT

const Int INHIBIT
static

The index to address the inhibit part, used in operator[] and Wires(Int,WIRE_MODE).

◆ SLINK

const Int SLINK
static

The index to address the slink part, used in operator[] and Wires(Int,WIRE_MODE).

◆ TLINK

const Int TLINK
static

The index to address the tlink part, used in operator[] and Wires(Int,WIRE_MODE).

◆ COUNT

const Int COUNT
static

The number of wires (currently 8). Use this for a loop over all possible wire indices.

◆ NONE

const WIRE_MODE NONE
static

Constant indicating no wires at all.