InterpreterUtilities Namespace Reference

Utility functions to make executing commands with an given Interpreter implementation easier. More...


Functions

bool executeScopedCommand (const std::string &interpreterName, const std::string &command, const Slot &output, const Slot &error, Progress *pProgress)
bool executeScopedCommand (const std::string &interpreterName, const std::string &command, std::string &outputAndError, bool &hasErrorText, Progress *pProgress)
bool isInterpreterAvailable (const std::string &interpreterName)
std::vector< std::string > getInterpreters ()
InterpretergetInterpreter (const std::string &interpreterName)


Detailed Description

Utility functions to make executing commands with an given Interpreter implementation easier.

Function Documentation

bool InterpreterUtilities::executeScopedCommand ( const std::string &  interpreterName,
const std::string &  command,
std::string &  outputAndError,
bool &  hasErrorText,
Progress pProgress 
)

Executes the provided statement(s) with the given interpreter while reporting output and error text from command execution.

This function blocks and will not return until all provided statements have been executed to completion.

Variables created while executing the provided command can be created in a nested scope that is closed at command completion causing local variables to be freed. A given interpreter implementation can support this nested scope behavior or can share the global and persistent scope used by Interpreter::executeCommand().

Parameters:
interpreterName The name of the interpreter to execute commands with. This should correspond to PlugIn::getName() of the given InterpreterManager instance.
command The command to execute. This may be a single statement or multiple statements. The syntax for single statements and multi-statements is defined by the given interpreter implementation.
outputAndError The provided string will be populated with all of the output and error text reported while executing the command.
hasErrorText The provided bool will be set to true if any error text was reported while executing the command will be set to false if only output text was reported.
pProgress If a non-NULL progress is provided, the execution of the provided command may report progress to this instance. A given interpreter implementation is permitted to ignore this parameter. An interpreter will only report progress to this progress instance while executing the provided command.
Returns:
False if a InterpreterManager instance with the given name cannot not be located or is not already started. Returns false if there was a syntatic problem with the given command, or an exception. was thrown from the interpreter. true will be returned otherwise.
See also:
Interpreter::executeScopedCommand()

bool InterpreterUtilities::executeScopedCommand ( const std::string &  interpreterName,
const std::string &  command,
const Slot output,
const Slot error,
Progress pProgress 
)

Executes the provided statement(s) with the given interpreter while reporting output and error text from command execution.

This function blocks and will not return until all provided statements have been executed to completion.

Variables created while executing the provided command can be created in a nested scope that is closed at command completion causing local variables to be freed. A given interpreter implementation can support this nested scope behavior or can share the global and persistent scope used by Interpreter::executeCommand().

Parameters:
interpreterName The name of the interpreter to execute commands with. This should correspond to PlugIn::getName() of the given InterpreterManager instance.
command The command to execute. This may be a single statement or multiple statements. The syntax for single statements and multi-statements is defined by the given interpreter implementation.
output This Slot will be called as output text is generated from executing this command. The boost::any provided to the slot will contain a std::string with the output text.
error This Slot will be called as error text is generated from executing this command. The boost::any provided to the slot will contain a std::string with the error text.
pProgress If a non-NULL progress is provided, the execution of the provided command may report progress to this instance. A given interpreter implementation is permitted to ignore this parameter. An interpreter will only report progress to this progress instance while executing the provided command.
Returns:
False if a InterpreterManager instance with the given name cannot not be located or is not already started. Returns false if there was a syntatic problem with the given command, or an exception. was thrown from the interpreter. true will be returned otherwise.
See also:
Interpreter::executeScopedCommand()

Interpreter* InterpreterUtilities::getInterpreter ( const std::string &  interpreterName  ) 

Returns an Interpreter instance for the given name that can be used to execute commands.

Parameters:
interpreterName The name of the interpreter to execute commands with. This should correspond to PlugIn::getName() of the given InterpreterManager instance.
Returns:
An Interpreter instance if isInterpreterAvailable() would return true, otherwise NULL is returned.

std::vector<std::string> InterpreterUtilities::getInterpreters (  ) 

Returns the names of all Interpreter implementations (e.g.

all plug-ins that return PlugInManagerServices::InterpreterManagerType() from PlugIn::getType() ). The implementations will be added to the list even if InterpreterManager::isStarted() returns false.

Returns:
The names of all Interpreter implementations.

bool InterpreterUtilities::isInterpreterAvailable ( const std::string &  interpreterName  ) 

Queries whether an interpreter is available and has been started.

This function will NOT start the interpreter, it must have already been started using InterpreterManager::start() for this function to return true.

Parameters:
interpreterName The name of the interpreter to execute commands with. This should correspond to PlugIn::getName() of the given InterpreterManager instance.
Returns:
True if an InterpreterManager instance with the given name can be located and InterpreterManager::isStarted() returns true. Otherwise false is returned.


Software Development Kit - Opticks 4.9.0 Build 16218