NxLibCommand

class NxLibCommand

This class simplifies the execution of NxLibcommands. The command name must be specified on construction. The parameters() and result() functions provide access to the corresponding Parameters and Result nodes of the tree. The execute() then writes the previously specified command name into the Command item and allows for synchronous and asynchronous command execution.

Public Functions

NxLibCommand(std::string const &_commandName, std::string const nodeName = "")

Constructor. Taking a command name and a node name for the NxLibItem the command is running on.

Parameters
  • _commandName: Name of the command to execute.

  • nodeName: Name of the NxLibItem slot, the command is running on.

NxLibItem const &slot() const

The slot returns the NxLibItem the NxLibCommand is running on.

Return

: NxLibItem the command runs on.

NxLibItem const parameters() const

The command’s parameters, that will be fetched before the commands executes.

Return

: NxLibItem, where the parameters are stored.

NxLibItem const result() const

The command’s results, after the command finsishes, or an error, in which case the results hold the error case.

Return

: NxLibItem, in which the results are stored.

void cancel(bool wait = true) const

Cancels the current current command. Does only work on commands, that support the Break command.

Parameters
  • wait: If true, the commands waits, whether the execution has been successful. If set to true, the command will throw a NxLibException if the execution was not successful.

void cancel(int *returnCode, bool wait = true) const

Cancels the current execution of the command.

Parameters
  • returnCode: The error code of the cancel operation.

  • wait: If true, the call blocks and waits, whether the execution has been successful. If set to true, the command will throw a NxLibException if the execution was not successful.

void execute(bool wait = true) const

Executes the current command.

Parameters
  • wait: If true, the call blocks and waits, whether the execution has been successful. If set to true, the command will throw a NxLibException if the execution was not successful.

void execute(int *returnCode, bool wait = true) const

Executes the current command.

Parameters
  • returnCode: The error code of the execution.

  • wait: If true, the call blocks and waits, whether the execution has been successful. If set to true, the command will throw a NxLibException if the execution was not successful.

void execute(char *_commandName, bool wait = true) const

Executes the command with the _commandName given.

Parameters
  • _commandName: Name of the command to execute.

  • wait: If true, the call blocks and waits, whether the execution has been successful. If set to true, the command will throw a NxLibException if the execution was not successful.

void execute(int *returnCode, char *_commandName, bool wait = true) const

Executes the command with the _commandName given.

Parameters
  • returnCode: The error code of the execution.

  • _commandName: Name of the command to execute.

  • wait: If true, the call blocks and waits, whether the execution has been successful. If set to true, the command will throw a NxLibException if the execution was not successful.

void execute(char const *_commandName, bool wait = true) const

Executes the command with the _commandName given.

Parameters
  • _commandName: Name of the command to execute.

  • wait: If true, the call blocks and waits, whether the execution has been successful. If set to true, the command will throw a NxLibException if the execution was not successful.

void execute(int *returnCode, char const *_commandName, bool wait = true) const

Executes the command with the _commandName given.

Parameters
  • returnCode: The error code of the execution.

  • _commandName: Name of the command to execute.

  • wait: If true, the call blocks and waits, whether the execution has been successful. If set to true, the command will throw a NxLibException if the execution was not successful.

void execute(std::string const &_commandName, bool wait = true) const

Executes the command with the _commandName given.

Parameters
  • _commandName: Name of the command to execute.

  • wait: If true, the call blocks and waits, whether the execution has been successful. If set to true, the command will throw a NxLibException if the execution was not successful.

void execute(int *returnCode, std::string const &_commandName, bool wait = true) const

Executes the command with the _commandName given.

Parameters
  • returnCode: The error code of execution.

  • _commandName: Name of the command to execute.

  • wait: If true, the call blocks and waits, whether the execution has been successful. If set to true, the command will throw a NxLibException if the execution was not successful.

bool finished() const

Checks whether the command execution has already finished.

Return

true, when NxLib is not currently executing a command, i.e. the Command node is Null. Otherwise false.

bool finished(int *returnCode) const

Checks whether the command execution has already finished.

Return

true, when NxLib is not currently executing a command, i.e. the Command node is Null. Otherwise false.

Parameters
  • returnCode: The API return code.

void assertSuccessful() const

Checks whether the previous command execution was successful and throws an NxLibException if not.

bool successful() const

Checks whether the previous command execution was successful.

Return

true, when the previous NxLib command execution was successful, i.e. there is no ErrorSymbol node under the Result node. Otherwise false.

bool successful(int *returnCode) const

Checks whether the previous command execution was successful.

Return

true, when the previous NxLib command execution was successful, i.e. there is no ErrorSymbol node under the Result node. Otherwise false.

Parameters
  • returnCode: The API return code.

Public Members

std::string commandName

Name of the command to execute.