Skip to main content

ClikaRT::graph::Pattern

class

Header: ClikaRT/graph/pattern.h

A graph of operator constraints to find in a ModelGraph. Move-only.

Types​

using NodeId​

using NodeId = std::size_t

The handle add_node returns: the node's position in add_node order, the index of its entry in Match::nodes.

Declared in ClikaRT/graph/pattern.h, line 96

Static member functions​

chain()​

static Pattern chain(ClikaRT::Span<const OpCode> codes)

The straight line codes[0] -> codes[1] -> ..., each node feeding the next on any port, none optional.

Declared in ClikaRT/graph/pattern.h, line 138

Member functions​

Pattern()​

Pattern()

An empty pattern; add nodes and edges to it.

Declared in ClikaRT/graph/pattern.h, line 99

~Pattern()​

~Pattern()

Releases the pattern.

Declared in ClikaRT/graph/pattern.h, line 101

Pattern(Pattern)​

Pattern(Pattern&&) noexcept

Move-only: transfers the pattern.

Declared in ClikaRT/graph/pattern.h, line 103

operator=(Pattern)​

Pattern& operator=(Pattern&&) noexcept

Move-assign: transfers the pattern.

Declared in ClikaRT/graph/pattern.h, line 105

Pattern(Pattern)​

Pattern(const Pattern&) =delete

Declared in ClikaRT/graph/pattern.h, line 106

operator=(Pattern)​

Pattern& operator=(const Pattern&) =delete

Declared in ClikaRT/graph/pattern.h, line 107

add_node(OpCode, bool)​

NodeId add_node(OpCode code, bool optional = false)

A pattern node that matches a graph node whose op_code() is code. The first node added is the root, and the root is always required: optional is honored on every later node, where it means the occurrence may lack the node (its Match entry is then std::nullopt, and the nodes feeding it are read as feeding what it feeds; do not add that bypass edge yourself).

Declared in ClikaRT/graph/pattern.h, line 115

add_node(Span< OpCode>, bool)​

NodeId add_node(ClikaRT::Span<const OpCode> alternatives, bool optional = false)

A pattern node that matches a graph node whose op_code() is one of alternatives. An empty list matches no node.

Declared in ClikaRT/graph/pattern.h, line 118

add_node(NodePredicate, bool)​

NodeId add_node(NodePredicate predicate, bool optional = false)

A pattern node that matches every graph node predicate accepts. The predicate runs inside the search, throw-contained: a throw ends the search and find_pattern returns the failure.

Declared in ClikaRT/graph/pattern.h, line 122

add_edge()​

void add_edge(
    NodeId from,
    NodeId to,
    std::optional<int> from_port = std::nullopt,
    std::optional<int> to_port = std::nullopt
)

The output of pattern node from feeds an input of pattern node to. With a port given, on exactly that port: from_port is the output port of from, to_port the input port of to; without, any port. Spell the edges of the full line only: an edge that bypasses an optional node is the search's own when that node is absent, and named explicitly it demands a direct edge the full line does not have. An id that names no node is reported by find_pattern as Status::InvalidArgument.

Declared in ClikaRT/graph/pattern.h, line 133

size()​

std::size_t size() const noexcept

How many pattern nodes were added.

Declared in ClikaRT/graph/pattern.h, line 141