Symple module

Command

Symple command message with a node path and action verb.

Command

#include <icy/symple/command.h>

Inherits: Message

Symple command message with a node path and action verb.

The node field is a colon-delimited path (e.g. "camera:zoom:in"). Individual path segments can be retrieved with param().

Public Methods

ReturnNameDescription
CommandConstructs an empty command with type set to "command".
CommandConstructs a command from a JSON value.
CommandCopy constructor.
std::stringnode constReturns the colon-delimited node path (e.g. "camera:zoom").
std::stringaction constReturns the action verb (defaults to "execute").
voidsetNodeSets the node path field.
voidsetActionSets the action verb field.
boolvalid virtual constReturns true if the base message is valid and the node field is set.
std::stringparam constReturns the nth colon-separated segment of the node path (1-based). Throws std::out_of_range if n exceeds the number of segments.
std::vector< std::string >paramsReturns all colon-separated segments of the node path.
boolmatches constReturns true if the node path matches the given pattern. Uses wildcard node matching via util::matchNodes.

Command

Command()

Constructs an empty command with type set to "command".


Command

Command(const json::Value & root)

Constructs a command from a JSON value.

Parameters

  • root JSON object to initialise from.

Command

Command(const Command & root)

Copy constructor.

Parameters

  • root Source command.

node

const

std::string node() const

Returns the colon-delimited node path (e.g. "camera:zoom").


action

const

std::string action() const

Returns the action verb (defaults to "execute").


setNode

void setNode(std::string_view node)

Sets the node path field.

Parameters

  • node Colon-delimited node path string.

setAction

void setAction(std::string_view action)

Sets the action verb field.

Parameters

  • action Action string (e.g. "execute", "get", "set").

valid

virtual const

virtual bool valid() const

Returns true if the base message is valid and the node field is set.


param

const

std::string param(int n) const

Returns the nth colon-separated segment of the node path (1-based). Throws std::out_of_range if n exceeds the number of segments.

Parameters

  • n 1-based segment index.

Returns

The nth path segment.


params

std::vector< std::string > params()

Returns all colon-separated segments of the node path.

Returns

Vector of path segment strings.


matches

const

bool matches(std::string_view xnode) const

Returns true if the node path matches the given pattern. Uses wildcard node matching via util::matchNodes.

Parameters

  • xnode Pattern to match against (colon-delimited, supports wildcards).