NxLibCommand¶
-
class NxLibCommand¶
This class simplifies the execution of NxLib commands. The
parameters()
andresult()
functions provide access to the corresponding parameter and result nodes of the tree. Theexecute()
method starts the command by writing the command name to the tree and allows for synchronous and asynchronous command execution.Public Functions
-
inline explicit NxLibCommand(std::string const &_commandName, std::string const nodeName = "")¶
- Parameters
_commandName – Name of the command to execute. This can be overwritten by the
execute()
methods.nodeName – Name of the execution slot the command should run in. By default the class will create a temporary slot used only by this instance of NxLibCommand, which is automatically deleted in the destructor.
-
inline NxLibItem const &slot() const¶
The slot returns the NxLibItem the NxLibCommand is running on.
- Returns
NxLibItem the command runs on.
-
inline const NxLibItem parameters() const¶
The command’s parameters , that will be fetched before the command executes.
- Returns
NxLibItem, in which the parameters are stored.
-
inline const NxLibItem result() const¶
The command’s result node after the command finishes.
- Returns
NxLibItem, in which the results are stored.
-
inline void cancel(bool wait = true) const¶
Cancels the current current command. Only works on commands, that support the Break command.
- Parameters
wait – If true, the function waits until execution of the command is finished. If set to true, the function will also throw an NxLibException if the command finished with an error.
-
inline 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 function waits until execution of the command is finished. If set to true, the function will also throw an NxLibException if the command finished with an error.
-
inline void execute(bool wait = true) const¶
Executes the current command.
- Parameters
wait – If true, the function waits until execution of the command is finished. If set to true, the function will also throw an NxLibException if the command finished with an error.
-
inline void execute(int *returnCode, bool wait = true) const¶
Executes the current command.
- Parameters
returnCode – The error code of the execution.
wait – If true, the function waits until execution of the command is finished. If set to true, the function will also throw an NxLibException if the command finished with an error.
-
inline void execute(char *_commandName, bool wait = true) const¶
Executes the command with the given name.
- Parameters
_commandName – Name of the command to execute. This overwrites the command name from the constructor.
wait – If true, the function waits until execution of the command is finished. If set to true, the function will also throw an NxLibException if the command finished with an error.
-
inline void execute(int *returnCode, char *_commandName, bool wait = true) const¶
Executes the command with the given name.
- Parameters
returnCode – The error code of the execution.
_commandName – Name of the command to execute. This overwrites the command name from the constructor.
wait – If true, the function waits until execution of the command is finished. If set to true, the function will also throw an NxLibException if the command finished with an error.
-
inline void execute(char const *_commandName, bool wait = true) const¶
Executes the command with the given name.
- Parameters
_commandName – Name of the command to execute. This overwrites the command name from the constructor.
wait – If true, the function waits until execution of the command is finished. If set to true, the function will also throw an NxLibException if the command finished with an error.
-
inline void execute(int *returnCode, char const *_commandName, bool wait = true) const¶
Executes the command with the given name.
- Parameters
returnCode – The error code of the execution.
_commandName – Name of the command to execute. This overwrites the command name from the constructor.
wait – If true, the function waits until execution of the command is finished. If set to true, the function will also throw an NxLibException if the command finished with an error.
-
inline void execute(std::string const &_commandName, bool wait = true) const¶
Executes the command with the given name.
- Parameters
_commandName – Name of the command to execute. This overwrites the command name from the constructor.
wait – If true, the function waits until execution of the command is finished. If set to true, the function will also throw an NxLibException if the command finished with an error.
-
inline void execute(int *returnCode, std::string const &_commandName, bool wait = true) const¶
Executes the command with the given name.
- Parameters
returnCode – The error code of execution.
_commandName – Name of the command to execute. This overwrites the command name from the constructor.
wait – If true, the function waits until execution of the command is finished. If set to true, the function will also throw an NxLibException if the command finished with an error.
-
inline bool finished() const¶
Checks whether the command execution has already finished.
- Returns
true, when NxLib is not currently executing a command, i.e. the command node is Null. Otherwise false.
-
inline bool finished(int *returnCode) const¶
Checks whether the command execution has already finished.
- Parameters
returnCode – The API return code .
- Returns
true, when NxLib is not currently executing a command, i.e. the command node is Null. Otherwise false.
-
inline void assertSuccessful() const¶
Checks whether the previous command execution is finished and was successful and throws an NxLibException if not.
-
inline bool successful() const¶
Checks whether the previous command execution was successful.
- Returns
true
, when the previous NxLib command execution was successful, i.e. there is no ErrorSymbol node under the Result node. Otherwisefalse
.
-
inline bool successful(int *returnCode) const¶
Checks whether the previous command execution was successful.
- Parameters
returnCode – The API return code .
- Returns
true
, when the previous NxLib command execution was successful, i.e. there is no ErrorSymbol node under the Result node. Otherwisefalse
.
Public Members
-
std::string commandName¶
Name of the command to execute.
-
inline explicit NxLibCommand(std::string const &_commandName, std::string const nodeName = "")¶