IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.
|
Simple command-line application interpreters, holds a set of commands that can be executed by name. Each of these command can take an arbitrary number of string arguments. Interpreter has its internal variables, which are strings. Each variable has a name and a value. If any arguments (and even command) start with the '$' character then then it is treated as reference to a variable and is substituted with the value of that variable (whose name follows the '$' character) before it is used. More...
Public Member Functions | |
delegate string | ApplicationCommandDelegate (ICommandLineApplicationInterpreter interpreter, string commandName, string[] args) |
Delegate for commands that are installed on interpreter. | |
delegate void | ModuleDelegate (string modulename, ICommandLineApplicationInterpreter interpreter) |
Delegate for installing a module on the interpreter. | |
CommandLineApplicationInterpreter () | |
Creates a new MessyApplication object initialized with some basisc applications. The flag indicating whether interpreter is case sensitive or not is set to DefaultCaseSensitive | |
CommandLineApplicationInterpreter (bool caseSensitive) | |
Construct a new commandline interpreter object initialized with some basisc commands. | |
virtual 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. | |
virtual string | SetVariable (string varName, string value) |
Sets the specified variable to the specified value. | |
virtual string | ClearVariable (string varName) |
Clears (removes) the specified variable. | |
virtual string | PrintVariable (string varName) |
Prints the specified variable. | |
virtual 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. | |
virtual 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. | |
virtual string | RunInteractive () |
Reads commands one by one from the standard input and executes them. | |
string | ExpressionEvaluatorInteractive () |
Runs interpreter's expression evaluator interactively. | |
string | ExpressionEvaluatorEvaluate (string[] args) |
string[] | GetCommands () |
Returns an array of installed commands. | |
virtual bool | ContainsCommand (string commandName) |
Returns true if the interpreter contains a command with specified name, false otherwise. | |
virtual string | RunRepeat (string[] args) |
Runs command several times where the first argument is number of repetitions, second argument is command name. Extracts command name and runs the corresponding command delegate.Before running it, arguments for the application delegate are extracted and then passed to the delegate. | |
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. | |
virtual string | Run (string commandName, params string[] commandArguments) |
Runs the specified command with specified name, installed on the current application object. | |
string | Run (string[] args) |
Runs command where the first argument is command name. Extracts command name and runs the corresponding command delegate.Before running it, arguments for the application delegate are extracted and then passed to the delegate. | |
void | AddParallelCommand (CommandLineJobContainer commandData) |
Adds a new parallel command data to the list of commands executed by in parallel. | |
CommandLineJobContainer | GetParallelCommandData (int id) |
Returns the command data object of the parallel command that with the specified ID. | |
void | PrintParallelCommands (bool printAll) |
Prints the commands that were scheduled for parallel execution, together with their current status, results and execution times (when available). | |
virtual void | UpdateThreadPriorityFromSystem () |
Updates thread priority (property ThreadPriority) of the interpreter to the current global thread priority (the UtilSystem.ThreadPriority property). | |
void | RegisterSystemPriorityUpdating () |
Registers the UpdateThreadPriorityFromSystem method as "event handler" for system priority changes. After registration, this method will be called every time the value of the UtilSystem.ThreadPriority property changes. | |
void | UnregisterSystemPriorityUpdating () |
Unregisters the UpdateThreadPriorityFromSystem method as "event handler" for system priority changes. | |
int[] | RunParallelRepeat (int numRepeat, string command, string[] commandArguments) |
Runs the specified command with arguments the specified number of times in parallel threads by using the interpreter's job dispatcher with corresponding parallel servers. | |
int | RunParallel (string command, string[] commandArguments) |
Runs she specified command with arguments once in a parallel thread by using the interpreter's job dispatcher with corresponding parallel servers. | |
virtual 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. | |
virtual 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. | |
bool | AsyncIsAllCompleted () |
Returns true if all asynchronous command executions have 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. | |
virtual void | AddCommand (string commandName, ApplicationCommandDelegate commandDelegate) |
Adds command with the specified name. | |
virtual void | RemoveCommand (string commandName) |
Removes the command with the specified name. | |
virtual void | AddModule (string moduleName, 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. | |
virtual void | LoadModule (string moduleName) |
Loads and initializes the specified module. | |
virtual string | ModuleTestCommandName (string modulename) |
Returns the standard name for the command that gets installed when a module is loaded. | |
virtual bool | IsModuleLoaded (string moduleName) |
Returns true if the specified module has been loaded on the interpreter, false if not. | |
virtual 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. | |
virtual 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. | |
Static Public Member Functions | |
static void | ExecuteSystemCommand (string[] args) |
Executes the specified system commmand and blocks until the execution completes. | |
static void | ExecuteSystemCommand (string command, params string[] args) |
Executes system command with arguments. | |
Public Attributes | |
const bool | DefaultCaseSensitive = false |
Default value of the flg indicating whether command names are case sensitive. | |
const string | DefaultName = "ApplicationIntepreter" |
Default interpreter name. | |
const string | AutoGlobalName = "AutomaticGlobalInterpreter" |
const string | AutoGlobalDescription = "Automatically created global command-line interpreter." |
StopWatch | _timer |
Static Public Attributes | |
static int | DefaultOutputLevel = 1 |
static bool | DefaultWarnCommandReplacement = true |
Protected Member Functions | |
virtual bool | IsVariableReference (string str) |
Returns true if the specified string represents a variable reference, false otherwise. | |
virtual string | SubstituteVariableReference (string str) |
Returns value of the referenced variable if the specified string represents a variable reference (begins with the variableStart character, usually '$'), otherwise the original sting is returned. | |
virtual void | ExecuteSystemCommandsInteractive () |
Reads commands with their arguments ont by one from the console and executes them as system commands. | |
void | AsyncRunCallback (IAsyncResult ar) |
Callback method for asynchronous command executions. | |
virtual string | CmdSetVariable (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Sets the specified varuable to the specified value. Usage: 1. Set the variable to the specified value: SetVar varName value varName: name of the variable to be set. value: value that is assigned to the variable. 2. Set the variable to the return value of the specified command: SetVar varName command arg1 arg2 ... varName: name of the variable to be set. command: command whose return value is the value to be assigned to the variable. arg1: the first argument to the command (if any). arg2: the second argument to the command (if any). etc. | |
virtual string | CmdGetVariable (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Gets the specified varuable and returns its value (or null if the variable does not exist). Variable name must be the only argument of the command. | |
virtual string | CmdClearVariable (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Clears the specified varuable. Variable name must be the only argument of the command. | |
virtual string | CmdPrintVariable (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Prints the specified varuable. Variable name must be the only argument of the command. | |
virtual string | CmdWriteLine (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Prints concatenated argument with spaces between them. | |
virtual string | CmdWrite (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Prints concatenated argument with spaces between them. | |
virtual string | CmdRunFile (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Runs a file by running all its lines in the current interpreter. File name must be the only argument of the command. | |
virtual string | CmdRunRepeat (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Runs another command repetitively the specified number of times. First argument must be the number of times command is run, the second argument must be command to be run repetitively, and the rest of the arguments are passed to that command as its arguments. | |
virtual string | CmdThtrowExceptions (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Sets the flag for rethrowing exceptions in the interaction mode. Optional boolean arguemnt, default is true. | |
virtual string | CmdRunInteractive (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Runs interpreter commands interactively. Reads commands one by one from console and executes them, until only Enter is pressed.. | |
virtual string | CmdRunSystem (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Runs the specified command-line by the operating system. The first argument is the command to be executed while the following arguments are arguments to this command. If there are no arguments then user is requested to insert commands interactively. | |
virtual string | CmdExpressionEvaluatorInteractive (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Runs the built in expression evaluator. | |
virtual string | CmdSetPriority (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Interpreter command. Sets and returns the applicat dispatcher, if initialized.The optional first argument ion's thread priority. If the new priority is not specified then only the current priority is returned. The specified priority is set on application level, on the interpretr executing the command, and on the interpreter's parallel job dispatcher in the case it is initialized. | |
virtual string | CmdRunParallel (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Interpreter command. Runs the specified command-line in parallel thread. The first argument is the command to be executed while the following arguments are arguments to this command. | |
virtual string | CmdRunParallelRepeat (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Interpreter command. Runs the specified command-line several times in the specified number of parallel threads. The first argument is the number of parallel executions of the same command, the second argument is command to be executed while the following arguments are arguments to this command. | |
virtual string | CmdPrintParallelCommands (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Interpreter command. Prints data about commands executed in parallel threads. The optional first argument is a flag (boolean, can be integer) that specifies whether the completed commands are also printed or not. Default is true. | |
virtual string | CmdRunAsync (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Runs the specified command-line asynchronously. The first argument is the command to be executed while the following arguments are arguments to this command. | |
virtual string | CmdAsyncWaitResults (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Wait until asynchronously invoked command with the specified ID (first argument, must represent an int) completes. The first argument is the ID of asynchronous invocation whose results are waited. | |
virtual string | CmdAsyncCompleted (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Returns a flag indicating whether the asynchroneous command invocation identified by the specified ID (first argument, must represent an int) has completed. The first argument is the ID of asynchronous invocation whose completion is waited for. | |
virtual string | CmdSleepSeconds (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Sleeps (suspends execution of the executing thread) for the specified number of seconds. The first argument is the number of seconds (must be string representing double) to sleep. | |
virtual string | CmdLoadModule (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Command. Loads the specified module (whos name must be the first argument) and performs its initialization. If there are more than 1 arguments then the rest of the arguments specify a command and (if more than 1) its arguments, and the specified command is also run. | |
virtual string | CmdIsModuleLoaded (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Executinon method for command that checks if module is loaded. Writes to condole whether module is loaded or not, and returns "1" if module is loaded and "0" if not. | |
virtual string | CmdModuleTestCommand (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Executinon method for test command that is installed when a module is installed. This is a command that enables to verify that a module with the specified name has been installed. | |
virtual string | CmdTestFromTestModules (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Executinon method for test command, which just prints its name and arguments. This is a replacement for usuel test command, which gets installed when one of the two basic test modules are installed. | |
virtual string | CmdRunInternalScriptClass (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Interpreter command. Dynamically creates and runs an internal script object, i.e. an object of the class that is already compiled in the code. Interpreter command arguments: The first argument must be a full name of the script class whose object is run. The rest of the arguments (if any) are directly transferred to the executable method of the script and are also used as argument to script initialization method. | |
virtual string | CmdRunScriptFile (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Interpreter command. 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 loadable script-based interpreter object. Interpreter command arguments: Path to the file containing loadable script must be the first argument to the method. The rest of the arguments (if any) are directly transferred to the executable method of the script. | |
virtual string | CmdLoadScript (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Interpreter command. 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 allocated instance of the loaded (dynamically compiled) class. Required arguments to the interpreter command are:
| |
virtual string | CmdRunLoadedScript (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Interpreter command. Runs a command based on dynamically loaded loadable script class. Arguments passed to this command are directly passed on to the dynamically loaded script class installed on LoadableScriptInterpreter under the same cmdName . Typically, the command that is executed by the current method, has been previously installed by the CmdLoadScript(...) method. | |
virtual string | WriteLoadableScriptReferencedAssemblies (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Interpreter command. Writes to the console the assemblies that are currently referenced by compiler used for dynamic loading of scripts. This information can be used for control if something goes wrong with dynamic script loading. | |
virtual string | CmdExit (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Execution method that exits the interpreter. | |
virtual string | CmdHelp (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Execution method for applications help. | |
virtual string | CmdAbout (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Execution method that prints some information about the application. | |
virtual string | CmdComment (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Execution method that does nothing (for comments). | |
virtual string | CmdPrintCommands (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Execution method for command that prints names of all installed applications. | |
virtual string | CmdTest (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Executinon method for test command, which just prints its name and arguments. | |
virtual string | CmdTestSpeed (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Executinon method for TestSpeed command, performs test of speed of numerical computations on LU decomposition, and outputs the result and comparison with reference results (usually achieved on Igor's computer). | |
virtual string | CmdTestSpeedLong (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Executinon method for TestSpeedLong command, performs a longer test of speed of numerical computations on QR decomposition, and outputs the result and comparison with reference results (usually achieved on Igor's computer). | |
virtual string | CmdTestQR (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Executinon method for TestQR command, performs test of QR decomposition. Command takes 1 argument that is dimension of the system of equations to be solved. If dimension is not stated then default value is taken.Optionally, command can take the second argument that represents number of repetitions of the decomposition test. In this tame, command returns average total execution time for each test. | |
virtual double | TestComputationalTimesQR (int numEq, int outLevel) |
Test of QR decomposition. Writes times necessary for all steps. | |
virtual string | CmdTestLU (ICommandLineApplicationInterpreter interpreter, string cmdName, string[] args) |
Executinon method for TestLU command, performs test of LU decomposition. Command takes 1 argument that is dimension of the system of equations to be solved. If dimension is not stated then default value is taken.Optionally, command can take the second argument that represents number of repetitions of the decomposition test. In this tame, command returns average total execution time for each test. | |
virtual double | TestComputationalTimesLU (int numEq, int outLevel) |
Test of LU decomposition. | |
Protected Attributes | |
bool | _caseSensitive = false |
SortedDictionary< string, ApplicationCommandDelegate > | _commands = new SortedDictionary<string, ApplicationCommandDelegate>() |
SortedDictionary< string, string > | _variables = new SortedDictionary<string, string>() |
SortedDictionary< string, ModuleDelegate > | _modules = new SortedDictionary<string, ModuleDelegate>() |
List< String > | _loadedModules = new List<string>() |
string | _name = DefaultName |
string | _sescription = "Application's command-line interpreter." |
string | _description |
char | variableStart = '$' |
bool | _exit = false |
int | _outputLevel = DefaultOutputLevel |
Default level of output for some of the interpreters' functionality (e.g. asynchronous command execution). | |
ExpressionEvaluatorJs | _expressionEvaluator |
List< CommandLineJobContainer > | _parallelCommands |
ThreadPriority | _threadPriority = UtilSystem.ThreadPriority |
bool | _systemPriorityUpdatesRegistered = false |
Whether the "event" handler for system priprity changes has already been registered. | |
int | _maxNumParallelServers = 0 |
string | _ModuleTestCommandPrefix = "TestModule_" |
const string | TestSpeedReferenceSystem = "Intel Core i7 2.8 GHz" |
Description of reference configuration. | |
const int | TestSpeedNumEq = 500 |
Number of equations used to test speed of numerical computations. | |
const double | TestSpeedReferenceTime = 0.640917 |
Reference execution time for speed test for numerical operations. | |
const int | TestSpeedLongNumEq = 1000 |
Number of equations used to test speed of numerical computations. | |
const double | TestSpeedLongReferenceTime = 63.9688 |
Reference execution time for speed test for numerical operations. | |
Static Protected Attributes | |
static List < CommandLineApplicationInterpreter > | _interpreters = new List<CommandLineApplicationInterpreter>() |
static int | DefaultNumEquations = 1000 |
Properties | |
object | Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. | |
bool | Exit [get, set] |
Whether the exit flag is set, usually causing interpreter to stop. | |
static List < CommandLineApplicationInterpreter > | Interpreters [get] |
static CommandLineApplicationInterpreter | Global [get] |
Global command-line interpreter. This returns the first interpreter created in the application, or a new interpreter if no interpreters have been created yet. | |
string | Name [get, set] |
Name of the current interpreter. | |
string | Description [get, set] |
Description of hte current interpreter. | |
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. | |
virtual bool | ThrowExceptions [get, set] |
Flag specifying whether exceptions are thrown in interactive mode or not. If false then only error messages are written to console, but exceptions are not rethrown. | |
ExpressionEvaluatorJs | ExpressionEvaluator [get, set] |
Expression evaluator used by the current. | |
List< CommandLineJobContainer > | ParallelCommands [get] |
List where parallel commands are stored. | |
internal ParallelJobDispatcherGen < CommandLineJobContainer, CommandLineJobContainer > | ParallelDispatcher [get] |
Parallel job dispatcher that is responsible for parallel execution of commands. | |
ThreadPriority | ThreadPriority [get, set] |
Priority of the current interpreter main thread and threads for executing the parallel commands. Setting priority changes priority of the threads. | |
int | MaxNumParallelServers [get, set] |
Maximal number of parallel servers allowed to be created for parallel command execution. If less than 1 then creation of unlimited number of servers is allowed. As long as the number is not exceeded, new servers will be created whenever a new parallel jobs are created and no servers are idle, in order to start execution of new parallel jobs immediately. | |
List< IAsyncResult > | AsyncCommandResults [get] |
List of IAsyncResult objects that were returned by asynchronous command invocations. Lazy evaluation, created when getter is invoked first time. | |
bool | AsyncEndInvokeInCallback [get, set] |
Flag indicating whether Endinvoke must be called in the callback of asynchronous command calls. | |
virtual LoadableScriptInterpreterBase | LoadableScriptInterpreter [get, set] |
Interpreter 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. | |
ScriptLoaderBase | ScriptLoader [get] |
Gets the script loader that is used by the current command-line interpreter for dynamically loading commands from scripts. | |
Private Member Functions | |
void | ModuleTest1 (string name, ICommandLineApplicationInterpreter interpreter) |
Loads the first built-in test module (just for testing modules). | |
void | ModuleTest2 (string name, ICommandLineApplicationInterpreter interpreter) |
Loads the second built-in test module (just for testing modules). | |
Private Attributes | |
object | _mainLock = new object() |
bool | _warnCommandReplacement = DefaultWarnCommandReplacement |
bool | _throwExceptions = false |
ParallelJobDispatcherGen < CommandLineJobContainer, CommandLineJobContainer > | _parallelDispatcher |
List< IAsyncResult > | _asyncCommandResults |
List of asynchronous results objects from individual asynchronous executions. | |
bool | _asyncEndInvokeInCallback = true |
LoadableScriptInterpreterBase | _loadableScriptInterpreter |
Simple command-line application interpreters, holds a set of commands that can be executed by name. Each of these command can take an arbitrary number of string arguments. Interpreter has its internal variables, which are strings. Each variable has a name and a value. If any arguments (and even command) start with the '$' character then then it is treated as reference to a variable and is substituted with the value of that variable (whose name follows the '$' character) before it is used.
This is a case of a very primitive interpreter, which can be used only for finding and executing commands by name and passing an array of strig arguments to them. $A Igor Nov08;
IG::Lib::CommandLineApplicationInterpreter::CommandLineApplicationInterpreter | ( | ) | [inline] |
Creates a new MessyApplication object initialized with some basisc applications. The flag indicating whether interpreter is case sensitive or not is set to DefaultCaseSensitive
IG::Lib::CommandLineApplicationInterpreter::CommandLineApplicationInterpreter | ( | bool | caseSensitive | ) | [inline] |
Construct a new commandline interpreter object initialized with some basisc commands.
caseSensitive | Flag that specifies whether command names are case sensitive. |
delegate string IG::Lib::CommandLineApplicationInterpreter::ApplicationCommandDelegate | ( | ICommandLineApplicationInterpreter | interpreter, |
string | commandName, | ||
string[] | args | ||
) |
Delegate for commands that are installed on interpreter.
interpreter | Interpreter on which commad is run. Enables access to interpreter internal data from command body. |
name | Command name. |
args | Command arguments. |
delegate void IG::Lib::CommandLineApplicationInterpreter::ModuleDelegate | ( | string | modulename, |
ICommandLineApplicationInterpreter | interpreter | ||
) |
Delegate for installing a module on the interpreter.
name | Name of the module. |
interpreter | Interperter where module is installed. |
virtual string IG::Lib::CommandLineApplicationInterpreter::GetVariable | ( | string | varName | ) | [inline, virtual] |
Returns the value of the specified variable of the current command line interpreter. null is returned if the specified variable does not exist.
varName | Name of the variable. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual bool IG::Lib::CommandLineApplicationInterpreter::IsVariableReference | ( | string | str | ) | [inline, protected, virtual] |
Returns true if the specified string represents a variable reference, false otherwise.
str | String that is checked. |
virtual string IG::Lib::CommandLineApplicationInterpreter::SubstituteVariableReference | ( | string | str | ) | [inline, protected, virtual] |
Returns value of the referenced variable if the specified string represents a variable reference (begins with the variableStart character, usually '$'), otherwise the original sting is returned.
str | String that is eventually substituted by variable value in the case that it represents a variable reference. |
virtual string IG::Lib::CommandLineApplicationInterpreter::SetVariable | ( | string | varName, |
string | value | ||
) | [inline, virtual] |
Sets the specified variable to the specified value.
varName | Name of the variable to be set. |
value | Value that is assigned to the variable. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::ClearVariable | ( | string | varName | ) | [inline, virtual] |
Clears (removes) the specified variable.
varName | Name of the variable to be cleared. |
value | Value that is assigned to the variable. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::PrintVariable | ( | string | varName | ) | [inline, virtual] |
Prints the specified variable.
varName | Name of the variable to be cleared. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string [] IG::Lib::CommandLineApplicationInterpreter::GetArguments | ( | string | commandLine | ) | [inline, virtual] |
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.
commandLine | Command line that is split to individual arguments. Command line can also contain a command, which is treated equally. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::RunFile | ( | string | filePath | ) | [inline, virtual] |
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.
filePath | Path to the file containing commands. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::RunInteractive | ( | ) | [inline, virtual] |
Reads commands one by one from the standard input and executes them.
Implements IG::Lib::ICommandLineApplicationInterpreter.
static void IG::Lib::CommandLineApplicationInterpreter::ExecuteSystemCommand | ( | string[] | args | ) | [inline, static] |
Executes the specified system commmand and blocks until the execution completes.
args | Array of strings where the first element is command to be executed, and the subsequent elements are command-line arguments. |
static void IG::Lib::CommandLineApplicationInterpreter::ExecuteSystemCommand | ( | string | command, |
params string[] | args | ||
) | [inline, static] |
Executes system command with arguments.
command | Command string, usually a path to executable or other type of command. |
args | Arguments to system command. |
virtual void IG::Lib::CommandLineApplicationInterpreter::ExecuteSystemCommandsInteractive | ( | ) | [inline, protected, virtual] |
Reads commands with their arguments ont by one from the console and executes them as system commands.
string IG::Lib::CommandLineApplicationInterpreter::ExpressionEvaluatorInteractive | ( | ) | [inline] |
Runs interpreter's expression evaluator interactively.
string IG::Lib::CommandLineApplicationInterpreter::ExpressionEvaluatorEvaluate | ( | string[] | args | ) | [inline] |
string [] IG::Lib::CommandLineApplicationInterpreter::GetCommands | ( | ) | [inline] |
Returns an array of installed commands.
The returned array is created anew and command names are copied to it from a collection of keys of a sorted dictionary (type SortedDictionary<string, string>).
virtual bool IG::Lib::CommandLineApplicationInterpreter::ContainsCommand | ( | string | commandName | ) | [inline, virtual] |
Returns true if the interpreter contains a command with specified name, false otherwise.
commandName | Name of the command whose existence is queried. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::RunRepeat | ( | string[] | args | ) | [inline, virtual] |
Runs command several times where the first argument is number of repetitions, second argument is command name. Extracts command name and runs the corresponding command delegate.Before running it, arguments for the application delegate are extracted and then passed to the delegate.
args | Command arguments where the first argument is command name. The rest of the arguments are collected and passed to the command delegate. |
string IG::Lib::CommandLineApplicationInterpreter::RunWithoutModifications | ( | string | commandName, |
params string[] | commandArguments | ||
) | [inline] |
Runs the specified command with specified name, installed on the current application object, without any modifications of the command arguments.
appName | Command name. |
commandArguments | Command 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.
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::Run | ( | string | commandName, |
params string[] | commandArguments | ||
) | [inline, virtual] |
Runs the specified command with specified name, installed on the current application object.
appName | Command name. |
commandArguments | Command arguments. |
Reimplemented in IG::Lib::CommandLineApplicationScriptInterpreter.
string IG::Lib::CommandLineApplicationInterpreter::Run | ( | string[] | args | ) | [inline] |
Runs command where the first argument is command name. Extracts command name and runs the corresponding command delegate.Before running it, arguments for the application delegate are extracted and then passed to the delegate.
args | Command arguments where the first argument is command name. The rest of the arguments are collected and passed to the command delegate. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
void IG::Lib::CommandLineApplicationInterpreter::AddParallelCommand | ( | CommandLineJobContainer | commandData | ) | [inline] |
Adds a new parallel command data to the list of commands executed by in parallel.
commandData | Command data object that is added to the list of barallelly executed commands. |
CommandLineJobContainer IG::Lib::CommandLineApplicationInterpreter::GetParallelCommandData | ( | int | id | ) | [inline] |
Returns the command data object of the parallel command that with the specified ID.
id | Identification nuber of the job container that carries command data and executes it. |
void IG::Lib::CommandLineApplicationInterpreter::PrintParallelCommands | ( | bool | printAll | ) | [inline] |
Prints the commands that were scheduled for parallel execution, together with their current status, results and execution times (when available).
printAll | Whether all commands are printed (included those already completed). If false then only completed commands are printed. |
virtual void IG::Lib::CommandLineApplicationInterpreter::UpdateThreadPriorityFromSystem | ( | ) | [inline, virtual] |
Updates thread priority (property ThreadPriority) of the interpreter to the current global thread priority (the UtilSystem.ThreadPriority property).
void IG::Lib::CommandLineApplicationInterpreter::RegisterSystemPriorityUpdating | ( | ) | [inline] |
Registers the UpdateThreadPriorityFromSystem method as "event handler" for system priority changes. After registration, this method will be called every time the value of the UtilSystem.ThreadPriority property changes.
void IG::Lib::CommandLineApplicationInterpreter::UnregisterSystemPriorityUpdating | ( | ) | [inline] |
Unregisters the UpdateThreadPriorityFromSystem method as "event handler" for system priority changes.
int [] IG::Lib::CommandLineApplicationInterpreter::RunParallelRepeat | ( | int | numRepeat, |
string | command, | ||
string[] | commandArguments | ||
) | [inline] |
Runs the specified command with arguments the specified number of times in parallel threads by using the interpreter's job dispatcher with corresponding parallel servers.
numRepeat | Number of parallel executions of the command that are started. |
command | Command that is run in each of the parallel threads. |
commandArguments | Command arguments. |
Parallel commands are scheduled for execution by interpreter's dispathcer (the ParallelDispatcher property), which delegates execution to its parallel servers.
Before transferring them to the dispatcher, commands are wrapped into job container object of type CommandLineJobContainer. Job containers are stored in a list, such that execution status and results can be accessed through contaier ID (which is returned by the method).
New parallel servers are dynamically added to the dispatcher if there are no idle servers to execute the parallel command immediately at the time it is called. However, the maximal number of parallel servers can be limited by the MaxNumParallelServers property.
int IG::Lib::CommandLineApplicationInterpreter::RunParallel | ( | string | command, |
string[] | commandArguments | ||
) | [inline] |
Runs she specified command with arguments once in a parallel thread by using the interpreter's job dispatcher with corresponding parallel servers.
command | Command that is run in each of the parallel threads. |
commandArguments | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::RunAsync | ( | string[] | args | ) | [inline, virtual] |
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.
args | Command arguments where the first argument is command name. The rest of the arguments are collected and passed to the command delegate. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::RunAsync | ( | string | commandName, |
params string[] | commandArguments | ||
) | [inline, virtual] |
Runs the command with specified name (installed on the current interpreter object) asynchronously.
appName | Command name. |
commandArguments | Command arguments. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
bool IG::Lib::CommandLineApplicationInterpreter::AsyncIsCompleted | ( | int | id | ) | [inline] |
Returns true if the asynchronous command execution identified by id has completed, and false otherwise.
id | ID of the asynchronous command execution that is querried. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
bool IG::Lib::CommandLineApplicationInterpreter::AsyncIsAllCompleted | ( | ) | [inline] |
Returns true if all asynchronous command executions have completed, and false otherwise.
void IG::Lib::CommandLineApplicationInterpreter::AsyncWaitAll | ( | ) | [inline] |
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.
Implements IG::Lib::ICommandLineApplicationInterpreter.
string IG::Lib::CommandLineApplicationInterpreter::AsyncWait | ( | int | callId | ) | [inline] |
Waits for the specified asynchronous command (specified by command ID) to complete.
callId | ID of the asynchronous command execution. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
void IG::Lib::CommandLineApplicationInterpreter::AsyncRunCallback | ( | IAsyncResult | ar | ) | [inline, protected] |
Callback method for asynchronous command executions.
ar | Asynchronous results that are passed to the method. |
virtual void IG::Lib::CommandLineApplicationInterpreter::AddCommand | ( | string | commandName, |
ApplicationCommandDelegate | commandDelegate | ||
) | [inline, virtual] |
Adds command with the specified name.
commandName | Name of the commant. |
commandDelegate | Delegate that will be used to execute the command. |
virtual void IG::Lib::CommandLineApplicationInterpreter::RemoveCommand | ( | string | commandName | ) | [inline, virtual] |
Removes the command with the specified name.
commandName | Name of the commad. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual void IG::Lib::CommandLineApplicationInterpreter::AddModule | ( | string | moduleName, |
ModuleDelegate | moduleDelegate | ||
) | [inline, virtual] |
Adds a new module to the interpreter. This adds an initialization function (via a delegate) which is executed when module module initialization is performed.
moduleName | Name of the module. When used, module names are case sensitive if commands are case sensitive. |
moduleDelegate | Method that performs module initialization. |
virtual void IG::Lib::CommandLineApplicationInterpreter::LoadModule | ( | string | moduleName | ) | [inline, virtual] |
Loads and initializes the specified module.
moduleName | Name of the module. It is case sensitive if commands are case sensitive. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::ModuleTestCommandName | ( | string | modulename | ) | [inline, virtual] |
Returns the standard name for the command that gets installed when a module is loaded.
modulename | Name of the module that is loaded. |
Whenever a module is loaded,
virtual bool IG::Lib::CommandLineApplicationInterpreter::IsModuleLoaded | ( | string | moduleName | ) | [inline, virtual] |
Returns true if the specified module has been loaded on the interpreter, false if not.
moduleName | Name of the module. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::RunScriptFile | ( | string | scriptFilePath, |
string[] | initAndRunArgs | ||
) | [inline, virtual] |
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.
scriptFilePath | Path to the file containing loadable script must be the first argument to the method. |
initAndRunArgs | Initialization arguments for the object that will be instantiated in order to execute the script. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
void IG::Lib::CommandLineApplicationInterpreter::LoadScript | ( | string | newCommandName, |
string | scriptFilePath, | ||
string[] | initArgs | ||
) | [inline] |
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.
newCommandName | Name of the newly installed command. |
scriptFilePath | Name of the file containing the script code that defines a loadable script class. |
initArgs | Arguments 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. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::RunLoadedScript | ( | string | commandName, |
string[] | arguments | ||
) | [inline, virtual] |
Executes the specified command that has been dynamically loaded form a script.
commandName | Name under which the command is installed on the current intepreter and on interpreder based on dynamically loaded scripts (LoadableScriptInterpreter). |
arguments | Arguments to the command. |
Implements IG::Lib::ICommandLineApplicationInterpreter.
string [] IG::Lib::CommandLineApplicationInterpreter::GetLoadableScriptReferencedAssemblies | ( | ) | [inline] |
Returns an array of assemblies that are currently referenced by the script loader that takes care of loading the dynamic scripts.
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdSetVariable | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Sets the specified varuable to the specified value.
Usage:
1. Set the variable to the specified value: SetVar varName value
varName: name of the variable to be set.
value: value that is assigned to the variable.
2. Set the variable to the return value of the specified command:
SetVar varName command arg1 arg2 ...
varName: name of the variable to be set.
command: command whose return value is the value to be assigned to the variable.
arg1: the first argument to the command (if any).
arg2: the second argument to the command (if any).
etc.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdGetVariable | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Gets the specified varuable and returns its value (or null if the variable does not exist). Variable name must be the only argument of the command.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdClearVariable | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Clears the specified varuable. Variable name must be the only argument of the command.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdPrintVariable | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Prints the specified varuable. Variable name must be the only argument of the command.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdWriteLine | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Prints concatenated argument with spaces between them.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdWrite | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Prints concatenated argument with spaces between them.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdRunFile | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Runs a file by running all its lines in the current interpreter. File name must be the only argument of the command.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdRunRepeat | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Runs another command repetitively the specified number of times. First argument must be the number of times command is run, the second argument must be command to be run repetitively, and the rest of the arguments are passed to that command as its arguments.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdThtrowExceptions | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Sets the flag for rethrowing exceptions in the interaction mode. Optional boolean arguemnt, default is true.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdRunInteractive | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Runs interpreter commands interactively. Reads commands one by one from console and executes them, until only Enter is pressed..
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdRunSystem | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Runs the specified command-line by the operating system. The first argument is the command to be executed while the following arguments are arguments to this command. If there are no arguments then user is requested to insert commands interactively.
interpreter | Interpreter on which commad is run. |
cmdName | Command name of this command. |
args | Command arguments this command. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdExpressionEvaluatorInteractive | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Runs the built in expression evaluator.
interpreter | Interpreter on which commad is run. |
cmdName | Command name of this command. |
args | Command arguments this command. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdSetPriority | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Interpreter command. Sets and returns the applicat dispatcher, if initialized.The optional first argument ion's thread priority. If the new priority is not specified then only the current priority is returned. The specified priority is set on application level, on the interpretr executing the command, and on the interpreter's parallel job dispatcher in the case it is initialized.
interpreter | Interpreter by which commad is run. |
cmdName | Command name. |
args | Command arguments of this command. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdRunParallel | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Interpreter command. Runs the specified command-line in parallel thread. The first argument is the command to be executed while the following arguments are arguments to this command.
interpreter | Interpreter on which commad is run. |
cmdName | Command name of this command. |
args | Command arguments of this command. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdRunParallelRepeat | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Interpreter command. Runs the specified command-line several times in the specified number of parallel threads. The first argument is the number of parallel executions of the same command, the second argument is command to be executed while the following arguments are arguments to this command.
interpreter | Interpreter on which commad is run. |
cmdName | Command name of this command. |
args | Command arguments of this command. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdPrintParallelCommands | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Interpreter command. Prints data about commands executed in parallel threads. The optional first argument is a flag (boolean, can be integer) that specifies whether the completed commands are also printed or not. Default is true.
interpreter | Interpreter by which commad is run. |
cmdName | Command name of this command. |
args | Command arguments of this command. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdRunAsync | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Runs the specified command-line asynchronously. The first argument is the command to be executed while the following arguments are arguments to this command.
interpreter | Interpreter on which commad is run. |
cmdName | Command name of this command. |
args | Command arguments of this command. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdAsyncWaitResults | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Wait until asynchronously invoked command with the specified ID (first argument, must represent an int) completes. The first argument is the ID of asynchronous invocation whose results are waited.
interpreter | Interpreter on which commad is run. |
cmdName | Command name of this command. |
args | Command arguments of this command. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdAsyncCompleted | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Returns a flag indicating whether the asynchroneous command invocation identified by the specified ID (first argument, must represent an int) has completed. The first argument is the ID of asynchronous invocation whose completion is waited for.
interpreter | Interpreter on which commad is run. |
cmdName | Command name of this command. |
args | Command arguments of this command. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdSleepSeconds | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Sleeps (suspends execution of the executing thread) for the specified number of seconds. The first argument is the number of seconds (must be string representing double) to sleep.
interpreter | Interpreter on which commad is run. |
cmdName | Command name of this command. |
args | Command arguments of this command. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdLoadModule | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Command. Loads the specified module (whos name must be the first argument) and performs its initialization. If there are more than 1 arguments then the rest of the arguments specify a command and (if more than 1) its arguments, and the specified command is also run.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdIsModuleLoaded | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Executinon method for command that checks if module is loaded. Writes to condole whether module is loaded or not, and returns "1" if module is loaded and "0" if not.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdModuleTestCommand | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Executinon method for test command that is installed when a module is installed. This is a command that enables to verify that a module with the specified name has been installed.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdTestFromTestModules | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Executinon method for test command, which just prints its name and arguments. This is a replacement for usuel test command, which gets installed when one of the two basic test modules are installed.
interpreter | Interpreter on which commad is run. Enables access to interpreter internal data from command body. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdRunInternalScriptClass | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Interpreter command. Dynamically creates and runs an internal script object, i.e. an object of the class that is already compiled in the code. Interpreter command arguments: The first argument must be a full name of the script class whose object is run. The rest of the arguments (if any) are directly transferred to the executable method of the script and are also used as argument to script initialization method.
interpreter | Interpreter on which commad is run. |
commandName | Name of the command |
commandArgumens | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdRunScriptFile | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Interpreter command. 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 loadable script-based interpreter object. Interpreter command arguments: Path to the file containing loadable script must be the first argument to the method. The rest of the arguments (if any) are directly transferred to the executable method of the script.
interpreter | Interpreter on which commad is run. |
commandName | Name of the command |
commandArgumens | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdLoadScript | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Interpreter command. 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 allocated instance of the loaded (dynamically compiled) class. Required arguments to the interpreter command are:
interpreter | Interpreter on which commad is run. |
commandName | Name of the command |
commandArgumens | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdRunLoadedScript | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Interpreter command. Runs a command based on dynamically loaded loadable script class. Arguments passed to this command are directly passed on to the dynamically loaded script class installed on LoadableScriptInterpreter under the same cmdName . Typically, the command that is executed by the current method, has been previously installed by the CmdLoadScript(...) method.
interpreter | Interpreter on which commad is run. |
commandName | Name of the command, which must be the same as command name under which dynamically loaded class is installed on LoadableScriptInterpreter. |
commandArgumens | Command arguments. These arguments are directly passed to the executable method on the corresponding class. |
virtual string IG::Lib::CommandLineApplicationInterpreter::WriteLoadableScriptReferencedAssemblies | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Interpreter command. Writes to the console the assemblies that are currently referenced by compiler used for dynamic loading of scripts. This information can be used for control if something goes wrong with dynamic script loading.
interpreter | Interpreter on which commad is run. |
commandName | Name of the command. |
commandArgumens | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdExit | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Execution method that exits the interpreter.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdHelp | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Execution method for applications help.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdAbout | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Execution method that prints some information about the application.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
Reimplemented in IG::Lib::NeuralApplicationInterpreter.
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdComment | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Execution method that does nothing (for comments).
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdPrintCommands | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Execution method for command that prints names of all installed applications.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdTest | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Executinon method for test command, which just prints its name and arguments.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdTestSpeed | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Executinon method for TestSpeed command, performs test of speed of numerical computations on LU decomposition, and outputs the result and comparison with reference results (usually achieved on Igor's computer).
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdTestSpeedLong | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Executinon method for TestSpeedLong command, performs a longer test of speed of numerical computations on QR decomposition, and outputs the result and comparison with reference results (usually achieved on Igor's computer).
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdTestQR | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Executinon method for TestQR command, performs test of QR decomposition. Command takes 1 argument that is dimension of the system of equations to be solved. If dimension is not stated then default value is taken.Optionally, command can take the second argument that represents number of repetitions of the decomposition test. In this tame, command returns average total execution time for each test.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual double IG::Lib::CommandLineApplicationInterpreter::TestComputationalTimesQR | ( | int | numEq, |
int | outLevel | ||
) | [inline, protected, virtual] |
Test of QR decomposition. Writes times necessary for all steps.
numEq | Number of equations to be solved with decomposition. |
outLevel | Level of output. |
virtual string IG::Lib::CommandLineApplicationInterpreter::CmdTestLU | ( | ICommandLineApplicationInterpreter | interpreter, |
string | cmdName, | ||
string[] | args | ||
) | [inline, protected, virtual] |
Executinon method for TestLU command, performs test of LU decomposition. Command takes 1 argument that is dimension of the system of equations to be solved. If dimension is not stated then default value is taken.Optionally, command can take the second argument that represents number of repetitions of the decomposition test. In this tame, command returns average total execution time for each test.
interpreter | Interpreter on which commad is run. |
cmdName | Command name. |
args | Command arguments. |
virtual double IG::Lib::CommandLineApplicationInterpreter::TestComputationalTimesLU | ( | int | numEq, |
int | outLevel | ||
) | [inline, protected, virtual] |
Test of LU decomposition.
outLevel | Level of output. |
numEq | Number of equations to be solved with decomposition. |
void IG::Lib::CommandLineApplicationInterpreter::ModuleTest1 | ( | string | name, |
ICommandLineApplicationInterpreter | interpreter | ||
) | [inline, private] |
Loads the first built-in test module (just for testing modules).
name | Name under which the module is being loaded. |
interpreter | Command line interpreter under on which the module is loaded. |
void IG::Lib::CommandLineApplicationInterpreter::ModuleTest2 | ( | string | name, |
ICommandLineApplicationInterpreter | interpreter | ||
) | [inline, private] |
Loads the second built-in test module (just for testing modules).
name | Name under which the module is being loaded. |
interpreter | Command line interpreter under on which the module is loaded. |
const bool IG::Lib::CommandLineApplicationInterpreter::DefaultCaseSensitive = false |
Default value of the flg indicating whether command names are case sensitive.
bool IG::Lib::CommandLineApplicationInterpreter::_caseSensitive = false [protected] |
object IG::Lib::CommandLineApplicationInterpreter::_mainLock = new object() [private] |
List<CommandLineApplicationInterpreter> IG::Lib::CommandLineApplicationInterpreter::_interpreters = new List<CommandLineApplicationInterpreter>() [static, protected] |
SortedDictionary<string, ApplicationCommandDelegate> IG::Lib::CommandLineApplicationInterpreter::_commands = new SortedDictionary<string, ApplicationCommandDelegate>() [protected] |
SortedDictionary<string, string> IG::Lib::CommandLineApplicationInterpreter::_variables = new SortedDictionary<string, string>() [protected] |
SortedDictionary<string, ModuleDelegate> IG::Lib::CommandLineApplicationInterpreter::_modules = new SortedDictionary<string, ModuleDelegate>() [protected] |
List<String> IG::Lib::CommandLineApplicationInterpreter::_loadedModules = new List<string>() [protected] |
const string IG::Lib::CommandLineApplicationInterpreter::DefaultName = "ApplicationIntepreter" |
Default interpreter name.
const string IG::Lib::CommandLineApplicationInterpreter::AutoGlobalName = "AutomaticGlobalInterpreter" |
const string IG::Lib::CommandLineApplicationInterpreter::AutoGlobalDescription = "Automatically created global command-line interpreter." |
string IG::Lib::CommandLineApplicationInterpreter::_name = DefaultName [protected] |
string IG::Lib::CommandLineApplicationInterpreter::_sescription = "Application's command-line interpreter." [protected] |
string IG::Lib::CommandLineApplicationInterpreter::_description [protected] |
char IG::Lib::CommandLineApplicationInterpreter::variableStart = '$' [protected] |
bool IG::Lib::CommandLineApplicationInterpreter::_exit = false [protected] |
int IG::Lib::CommandLineApplicationInterpreter::DefaultOutputLevel = 1 [static] |
int IG::Lib::CommandLineApplicationInterpreter::_outputLevel = DefaultOutputLevel [protected] |
Default level of output for some of the interpreters' functionality (e.g. asynchronous command execution).
bool IG::Lib::CommandLineApplicationInterpreter::DefaultWarnCommandReplacement = true [static] |
bool IG::Lib::CommandLineApplicationInterpreter::_warnCommandReplacement = DefaultWarnCommandReplacement [private] |
bool IG::Lib::CommandLineApplicationInterpreter::_throwExceptions = false [private] |
List<CommandLineJobContainer> IG::Lib::CommandLineApplicationInterpreter::_parallelCommands [protected] |
ParallelJobDispatcherGen<CommandLineJobContainer, CommandLineJobContainer> IG::Lib::CommandLineApplicationInterpreter::_parallelDispatcher [private] |
ThreadPriority IG::Lib::CommandLineApplicationInterpreter::_threadPriority = UtilSystem.ThreadPriority [protected] |
bool IG::Lib::CommandLineApplicationInterpreter::_systemPriorityUpdatesRegistered = false [protected] |
Whether the "event" handler for system priprity changes has already been registered.
int IG::Lib::CommandLineApplicationInterpreter::_maxNumParallelServers = 0 [protected] |
List<IAsyncResult> IG::Lib::CommandLineApplicationInterpreter::_asyncCommandResults [private] |
List of asynchronous results objects from individual asynchronous executions.
bool IG::Lib::CommandLineApplicationInterpreter::_asyncEndInvokeInCallback = true [private] |
string IG::Lib::CommandLineApplicationInterpreter::_ModuleTestCommandPrefix = "TestModule_" [protected] |
LoadableScriptInterpreterBase IG::Lib::CommandLineApplicationInterpreter::_loadableScriptInterpreter [private] |
const string IG::Lib::CommandLineApplicationInterpreter::TestSpeedReferenceSystem = "Intel Core i7 2.8 GHz" [protected] |
Description of reference configuration.
const int IG::Lib::CommandLineApplicationInterpreter::TestSpeedNumEq = 500 [protected] |
Number of equations used to test speed of numerical computations.
const double IG::Lib::CommandLineApplicationInterpreter::TestSpeedReferenceTime = 0.640917 [protected] |
Reference execution time for speed test for numerical operations.
const int IG::Lib::CommandLineApplicationInterpreter::TestSpeedLongNumEq = 1000 [protected] |
Number of equations used to test speed of numerical computations.
const double IG::Lib::CommandLineApplicationInterpreter::TestSpeedLongReferenceTime = 63.9688 [protected] |
Reference execution time for speed test for numerical operations.
int IG::Lib::CommandLineApplicationInterpreter::DefaultNumEquations = 1000 [static, protected] |
object IG::Lib::CommandLineApplicationInterpreter::Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.
Implements IG::Lib::ILockable.
bool IG::Lib::CommandLineApplicationInterpreter::Exit [get, set] |
Whether the exit flag is set, usually causing interpreter to stop.
Implements IG::Lib::ICommandLineApplicationInterpreter.
List<CommandLineApplicationInterpreter> IG::Lib::CommandLineApplicationInterpreter::Interpreters [static, get] |
CommandLineApplicationInterpreter IG::Lib::CommandLineApplicationInterpreter::Global [static, get] |
Global command-line interpreter. This returns the first interpreter created in the application, or a new interpreter if no interpreters have been created yet.
string IG::Lib::CommandLineApplicationInterpreter::Name [get, set] |
Name of the current interpreter.
Implements IG::Lib::ICommandLineApplicationInterpreter.
string IG::Lib::CommandLineApplicationInterpreter::Description [get, set] |
Description of hte current interpreter.
Implements IG::Lib::ICommandLineApplicationInterpreter.
StopWatch IG::Lib::CommandLineApplicationInterpreter::Timer [get] |
Gets the stopwatch used for measuring time of commands. This property always returns an initialized stopwatch.
Implements IG::Lib::ICommandLineApplicationInterpreter.
int IG::Lib::CommandLineApplicationInterpreter::OutputLevel [get, set] |
Level of output for some of the interpreter's functionality (e.g. asynchronous command execution).
Implements IG::Lib::ICommandLineApplicationInterpreter.
bool IG::Lib::CommandLineApplicationInterpreter::WarnCommandReplacement [get, set] |
Specifies whether a wrning should be launched whenever an installed command is being replaced.
Implements IG::Lib::ICommandLineApplicationInterpreter.
virtual bool IG::Lib::CommandLineApplicationInterpreter::ThrowExceptions [get, set] |
Flag specifying whether exceptions are thrown in interactive mode or not. If false then only error messages are written to console, but exceptions are not rethrown.
In some modes of operation, exceptions thrown in commands executed by the interpreter are cought, user is notified about the exception (usually by writing the error message to the console), but exceptions are not re-thrown. Because of this behavior, much information about exceptions is lost (e.g. the stack trace).
ExpressionEvaluatorJs IG::Lib::CommandLineApplicationInterpreter::ExpressionEvaluator [get, set] |
Expression evaluator used by the current.
List<CommandLineJobContainer> IG::Lib::CommandLineApplicationInterpreter::ParallelCommands [get] |
List where parallel commands are stored.
internal ParallelJobDispatcherGen<CommandLineJobContainer, CommandLineJobContainer> IG::Lib::CommandLineApplicationInterpreter::ParallelDispatcher [get, protected] |
Parallel job dispatcher that is responsible for parallel execution of commands.
ThreadPriority IG::Lib::CommandLineApplicationInterpreter::ThreadPriority [get, set] |
Priority of the current interpreter main thread and threads for executing the parallel commands. Setting priority changes priority of the threads.
int IG::Lib::CommandLineApplicationInterpreter::MaxNumParallelServers [get, set] |
Maximal number of parallel servers allowed to be created for parallel command execution. If less than 1 then creation of unlimited number of servers is allowed. As long as the number is not exceeded, new servers will be created whenever a new parallel jobs are created and no servers are idle, in order to start execution of new parallel jobs immediately.
List<IAsyncResult> IG::Lib::CommandLineApplicationInterpreter::AsyncCommandResults [get, protected] |
List of IAsyncResult objects that were returned by asynchronous command invocations. Lazy evaluation, created when getter is invoked first time.
bool IG::Lib::CommandLineApplicationInterpreter::AsyncEndInvokeInCallback [get, set, protected] |
Flag indicating whether Endinvoke must be called in the callback of asynchronous command calls.
This flag is unset temporarily in methods where endinvoke is called explicitly.
virtual LoadableScriptInterpreterBase IG::Lib::CommandLineApplicationInterpreter::LoadableScriptInterpreter [get, set] |
Interpreter 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.
ArgumentNullException | When set to null reference. |
$A Igor Aug11;
Implements IG::Lib::ICommandLineApplicationInterpreter.
ScriptLoaderBase IG::Lib::CommandLineApplicationInterpreter::ScriptLoader [get] |
Gets the script loader that is used by the current command-line interpreter for dynamically loading commands from scripts.