IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.

IG::Lib::ICommandLineApplicationInterpreter Interface Reference

Interface for simple command-line applicatino interpreters. More...

Inheritance diagram for IG::Lib::ICommandLineApplicationInterpreter:

List of all members.

Public Member Functions

string GetVariable (string varName)
 Returns the value of the specified variable of the current command line interpreter. null is returned if the specified variable does not exist.
string SetVariable (string varName, string value)
 Sets the specified variable to the specified value.
string ClearVariable (string varName)
 Clears (removes) the specified variable.
string PrintVariable (string varName)
 Prints the specified variable.
string[] GetArguments (string commandLine)
 Parses a command line and extracts arguments from it. Arguments can be separated according to usual rules for command-line arguments: spaces are separators, there can be arbitraty number of spaces, and if we want an argument to contain spaces, we must enclose it in double quotes. Command line can also contain the command name followed by arguments. In this case it is treated in the same way, and command can be obtained simply as the first string in the returned array.
string RunFile (string filePath)
 Runs all commands that are written in a file. Each line of a file is interpreted as a single command, consisting of command name followed by arguments.
string RunInteractive ()
 Reads commands one by one from the standard input and executes them.
bool ContainsCommand (string commandName)
 Returns true if the interpreter contains a command with specified name, false otherwise.
string RunWithoutModifications (string commandName, params string[] commandArguments)
 Runs the specified command with specified name, installed on the current application object, without any modifications of the command arguments.
string Run (string commandName, string[] args)
 Runs the command with specified name, installed on the current application object.
string Run (string[] args)
 Runs command where the first argument is command name. Extracts application name and runs the corresponding application delegate.Before running it, arguments for the application delegate are extracted and then passed to the delegate.
string RunAsync (string[] args)
 Runs a command asynchronously where the first argument is command name. Extracts command name and runs the corresponding application delegate. Before running it, arguments for the application delegate are extracted and then passed to the delegate.
string RunAsync (string commandName, params string[] commandArguments)
 Runs the command with specified name (installed on the current interpreter object) asynchronously.
bool AsyncIsCompleted (int id)
 Returns true if the asynchronous command execution identified by id has completed, and false otherwise.
void AsyncWaitAll ()
 Waits until all asynchronously commands that have been eventually executed by the current interpreter, complete. It is sometimes necessary to call this method if any asynchronous command invocations were made because such commands are executed in background threads, which are automatically broken when all foreground threads complete.
string AsyncWait (int callId)
 Waits for the specified asynchronous command (specified by command ID) to complete.
void AddCommand (string appName, CommandLineApplicationInterpreter.ApplicationCommandDelegate appMain)
 Adds command with the specified name.
void RemoveCommand (string appName)
 Removes the command with the specified name.
void AddModule (string moduleName, CommandLineApplicationInterpreter.ModuleDelegate moduleDelegate)
 Adds a new module to the interpreter. This adds an initialization function (via a delegate) which is executed when module module initialization is performed.
void LoadModule (string moduleName)
 Loads and initializes the specified module.
bool IsModuleLoaded (string moduleName)
 Returns true if the specified module has been loaded on the interpreter, false if not.
string RunScriptFile (string scriptFilePath, string[] initAndRunArgs)
 Dynamically loads (temporarily, just for execution of the current commad) a class form the script contained in the specified file and executes its executable method. The file must contain the script that is dynamically loaded and executed, in form of definition of the appropriate class of type ILoadableScript . The dynamically loadable script class is loaded from the file and instantiated by the LoadableScriptInterpreter interpreter that is based on loadable scripts.
void LoadScript (string newCommandName, string scriptFilePath, string[] initArgs)
 Dynamically loads (compiles and instantiates) a loadable script class contained in the specified file, and installs a new command on LoadableScriptInterpreter and on the current interpreter, based on the dynamically created instance of the loaded (dynamically compiled) class.
string RunLoadedScript (string commandName, string[] arguments)
 Executes the specified command that has been dynamically loaded form a script.
string[] GetLoadableScriptReferencedAssemblies ()
 Returns an array of assemblies that are currently referenced by the script loader that takes care of loading the dynamic scripts.

Properties

string Name [get, set]
 Name of the current interpreter.
string Description [get, set]
 Description of hte current interpreter.
bool Exit [get]
 Whether the exit flag is set, usually causing interpreter to stop.
StopWatch Timer [get]
 Gets the stopwatch used for measuring time of commands. This property always returns an initialized stopwatch.
int OutputLevel [get, set]
 Level of output for some of the interpreter's functionality (e.g. asynchronous command execution).
bool WarnCommandReplacement [get, set]
 Specifies whether a wrning should be launched whenever an installed command is being replaced.
LoadableScriptInterpreterBase LoadableScriptInterpreter [get, set]
 Interprater based on dynamically loadable scripts. This enables installation and running of commands that are based on C# code that is dynamically compiled. Ihe object is created on first get access if it has not been assigned before. This property can be overridden in derived classes such that getter creates a dynamically loadable script - based interpreter of another kind. This is important because different script loaders (in particuar with different dynamic libraries referenced) will be used in different contexts. Another possibility is that a custom object is assigned to this property, usually in the initialization stage of the current interpreter.

Detailed Description

Interface for simple command-line applicatino interpreters.


Member Function Documentation

string IG::Lib::ICommandLineApplicationInterpreter::GetVariable ( string  varName)

Returns the value of the specified variable of the current command line interpreter. null is returned if the specified variable does not exist.

Parameters:
varNameName of the variable.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::SetVariable ( string  varName,
string  value 
)

Sets the specified variable to the specified value.

Parameters:
varNameName of the variable to be set.
valueValue that is assigned to the variable.
Returns:
New value of the variable (before the method was called).

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::ClearVariable ( string  varName)

Clears (removes) the specified variable.

Parameters:
varNameName of the variable to be cleared.
Returns:
null.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::PrintVariable ( string  varName)

Prints the specified variable.

Parameters:
varNameName of the variable to be cleared.
Returns:
null.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string [] IG::Lib::ICommandLineApplicationInterpreter::GetArguments ( string  commandLine)

Parses a command line and extracts arguments from it. Arguments can be separated according to usual rules for command-line arguments: spaces are separators, there can be arbitraty number of spaces, and if we want an argument to contain spaces, we must enclose it in double quotes. Command line can also contain the command name followed by arguments. In this case it is treated in the same way, and command can be obtained simply as the first string in the returned array.

Parameters:
commandLineCommand line that is split to individual arguments. Command line can also contain a command, which is treated equally.
Returns:
An array of arguments.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::RunFile ( string  filePath)

Runs all commands that are written in a file. Each line of a file is interpreted as a single command, consisting of command name followed by arguments.

Parameters:
filePathPath to the file containing commands.
Returns:
Return value of the last command.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::RunInteractive ( )

Reads commands one by one from the standard input and executes them.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

bool IG::Lib::ICommandLineApplicationInterpreter::ContainsCommand ( string  commandName)

Returns true if the interpreter contains a command with specified name, false otherwise.

Parameters:
commandNameName of the command whose existence is queried.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::RunWithoutModifications ( string  commandName,
params string[]  commandArguments 
)

Runs the specified command with specified name, installed on the current application object, without any modifications of the command arguments.

Parameters:
appNameCommand name.
commandArgumentsCommand arguments.

This method should not be overriden, but the Run method can be, e.g. in order to perform some argument or command name transformations.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::Run ( string  commandName,
string[]  args 
)

Runs the command with specified name, installed on the current application object.

Parameters:
commandNameCommand name.
argsCommand arguments.
string IG::Lib::ICommandLineApplicationInterpreter::Run ( string[]  args)

Runs command where the first argument is command name. Extracts application name and runs the corresponding application delegate.Before running it, arguments for the application delegate are extracted and then passed to the delegate.

Parameters:
argsCommand arguments where the first argument is command name. The rest of the arguments are collected and passed to the command delegate.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::RunAsync ( string[]  args)

Runs a command asynchronously where the first argument is command name. Extracts command name and runs the corresponding application delegate. Before running it, arguments for the application delegate are extracted and then passed to the delegate.

Parameters:
argsCommand arguments where the first argument is command name. The rest of the arguments are collected and passed to the command delegate.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::RunAsync ( string  commandName,
params string[]  commandArguments 
)

Runs the command with specified name (installed on the current interpreter object) asynchronously.

Parameters:
appNameCommand name.
commandArgumentsCommand arguments.
Returns:
ID of asynchronous run used to query results and whether command has completed, or -1 if a call was not launched (actually, an exception would be thrown in this case).

Implemented in IG::Lib::CommandLineApplicationInterpreter.

bool IG::Lib::ICommandLineApplicationInterpreter::AsyncIsCompleted ( int  id)

Returns true if the asynchronous command execution identified by id has completed, and false otherwise.

Parameters:
idID of the asynchronous command execution that is querried.
Returns:

Implemented in IG::Lib::CommandLineApplicationInterpreter.

void IG::Lib::ICommandLineApplicationInterpreter::AsyncWaitAll ( )

Waits until all asynchronously commands that have been eventually executed by the current interpreter, complete. It is sometimes necessary to call this method if any asynchronous command invocations were made because such commands are executed in background threads, which are automatically broken when all foreground threads complete.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::AsyncWait ( int  callId)

Waits for the specified asynchronous command (specified by command ID) to complete.

Parameters:
callIdID of the asynchronous command execution.
Returns:
Results of the command if the command has not completed before, null otherwise.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

void IG::Lib::ICommandLineApplicationInterpreter::AddCommand ( string  appName,
CommandLineApplicationInterpreter.ApplicationCommandDelegate  appMain 
)

Adds command with the specified name.

Parameters:
interpreterInterpreter on which commad is run.
appNameName of the commant.
appMainDelegate that will be used to execute the command.
void IG::Lib::ICommandLineApplicationInterpreter::RemoveCommand ( string  appName)

Removes the command with the specified name.

Parameters:
appNameName of the commad.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

void IG::Lib::ICommandLineApplicationInterpreter::AddModule ( string  moduleName,
CommandLineApplicationInterpreter.ModuleDelegate  moduleDelegate 
)

Adds a new module to the interpreter. This adds an initialization function (via a delegate) which is executed when module module initialization is performed.

Parameters:
moduleNameName of the module. When used, module names are case sensitive if commands are case sensitive.
moduleDelegateMethod that performs module initialization.
void IG::Lib::ICommandLineApplicationInterpreter::LoadModule ( string  moduleName)

Loads and initializes the specified module.

Parameters:
moduleNameName of the module. It is case sensitive if commands are case sensitive.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

bool IG::Lib::ICommandLineApplicationInterpreter::IsModuleLoaded ( string  moduleName)

Returns true if the specified module has been loaded on the interpreter, false if not.

Parameters:
moduleNameName of the module.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::RunScriptFile ( string  scriptFilePath,
string[]  initAndRunArgs 
)

Dynamically loads (temporarily, just for execution of the current commad) a class form the script contained in the specified file and executes its executable method. The file must contain the script that is dynamically loaded and executed, in form of definition of the appropriate class of type ILoadableScript . The dynamically loadable script class is loaded from the file and instantiated by the LoadableScriptInterpreter interpreter that is based on loadable scripts.

Parameters:
scriptFilePathPath to the file containing loadable script must be the first argument to the method.
initAndRunArgsInitialization arguments for the object that will be instantiated in order to execute the script.
Returns:
Result of execution returned by the executable method of the dynamically loaded script object.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

void IG::Lib::ICommandLineApplicationInterpreter::LoadScript ( string  newCommandName,
string  scriptFilePath,
string[]  initArgs 
)

Dynamically loads (compiles and instantiates) a loadable script class contained in the specified file, and installs a new command on LoadableScriptInterpreter and on the current interpreter, based on the dynamically created instance of the loaded (dynamically compiled) class.

Parameters:
newCommandNameName of the newly installed command.
scriptFilePathName of the file containing the script code that defines a loadable script class.
initArgsArguments to the initialization method of the loaded object. The initialization method will be called before the first call to the executable method of the class, which takes care of execution of the newly installed command.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::RunLoadedScript ( string  commandName,
string[]  arguments 
)

Executes the specified command that has been dynamically loaded form a script.

Parameters:
commandNameName under which the command is installed on the current intepreter and on interpreder based on dynamically loaded scripts (LoadableScriptInterpreter).
argumentsArguments to the command.
Returns:
Results of command execution.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string [] IG::Lib::ICommandLineApplicationInterpreter::GetLoadableScriptReferencedAssemblies ( )

Returns an array of assemblies that are currently referenced by the script loader that takes care of loading the dynamic scripts.

Returns:

Implemented in IG::Lib::CommandLineApplicationInterpreter.


Property Documentation

string IG::Lib::ICommandLineApplicationInterpreter::Name [get, set]

Name of the current interpreter.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

string IG::Lib::ICommandLineApplicationInterpreter::Description [get, set]

Description of hte current interpreter.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

bool IG::Lib::ICommandLineApplicationInterpreter::Exit [get]

Whether the exit flag is set, usually causing interpreter to stop.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

StopWatch IG::Lib::ICommandLineApplicationInterpreter::Timer [get]

Gets the stopwatch used for measuring time of commands. This property always returns an initialized stopwatch.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

int IG::Lib::ICommandLineApplicationInterpreter::OutputLevel [get, set]

Level of output for some of the interpreter's functionality (e.g. asynchronous command execution).

Implemented in IG::Lib::CommandLineApplicationInterpreter.

bool IG::Lib::ICommandLineApplicationInterpreter::WarnCommandReplacement [get, set]

Specifies whether a wrning should be launched whenever an installed command is being replaced.

Implemented in IG::Lib::CommandLineApplicationInterpreter.

LoadableScriptInterpreterBase IG::Lib::ICommandLineApplicationInterpreter::LoadableScriptInterpreter [get, set]

Interprater based on dynamically loadable scripts. This enables installation and running of commands that are based on C# code that is dynamically compiled. Ihe object is created on first get access if it has not been assigned before. This property can be overridden in derived classes such that getter creates a dynamically loadable script - based interpreter of another kind. This is important because different script loaders (in particuar with different dynamic libraries referenced) will be used in different contexts. Another possibility is that a custom object is assigned to this property, usually in the initialization stage of the current interpreter.

Exceptions:
ArgumentNullExceptionWhen set to null reference.

$A Igor Aug11;

Implemented in IG::Lib::CommandLineApplicationInterpreter.


The documentation for this interface was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties Events