IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.
|
Base class for classes that can be dynamically loadeded from scripts and run, which provides functionality of dynamic scripting. It is recommendable to derive all such classes that implement the ILoadableScript interface from this base class. More...
Classes | |
class | Script_CommandAdapter |
Adapts that converts internal script commands (delegate of type Script_CommandDelegate) to interpreter commands. This adapter enables definition of script internal commands in a simple form and installation of them on internal interpreter, which requires command delegate of type . More... | |
class | StoredScriptSettings |
In methods of this class you will find all the settings that apply to this script. More... | |
Public Member Functions | |
LoadableScriptBase () | |
Argument-less constructor. If argument-less constructor is called then initialization is not performed and will be performed later. | |
string | Run (string[] arguments) |
Performs the action of this object. Override this in derived classes! | |
void | Initialize (string[] arguments) |
Initializes the object. If not called explicitly, this method is automatically called at the first call to the Run method. | |
virtual string | Script_DefaultInitialize (string[] arguments) |
Default initialization method for scripts. | |
virtual string | Script_DefaultRun (string[] arguments) |
Default run method for the script. Can be used when only installed commands are run by hte script. | |
virtual ICommandLineApplicationInterpreter | Script_CreateInterpreterWithoutCommands () |
Creates and returns an interpreter that can be used as script's internal interpreter for running script's commands. Commands installed on this interpreter recieve the same command arguments as the Run command. | |
virtual void | Script_AddCommands (ICommandLineApplicationInterpreter interpreter, SortedList< string, string > helpStrings) |
Add wscript's internal commands to the specified interpreter. | |
delegate string | Script_CommandDelegate (string[] args) |
Delegate for commands that are installed on script's internal interpreter (property Interpreter). These methods only take command arguments as parameters, and the first argument is usually name under which command is installed. | |
void | Script_AddCommand (string commandName, Script_CommandDelegate command, string helpString) |
Adds a new internal script command under specified name to the internal interpreter of the current script object. | |
virtual void | Script_AddCommand (ICommandLineApplicationInterpreter interpreter, SortedList< string, string > helpStrings, string commandName, Script_CommandDelegate command, string helpString) |
Adds a new internal script command under specified name to the internal interpreter of the current script object. | |
string | Script_GetHelpString (string scriptCommandName) |
Returns help string for internal script command with specified name, or null if help string is not installed for such a command. | |
void | Script_PrintCommandsHelp () |
Prits help for the installed internal commands of the script. | |
virtual bool | Script_ContainsCommand (string commandName) |
Returns true if the internal script's interpreter contains a command with specified name, false otherwise. | |
virtual bool | Script_ContainsScriptCommand (string commandName) |
Returns true if the specified command is script command (i.e. its first argument is command-name and it is run through the Script_CommandAdapter object). | |
string | Script_Run (string[] arguments) |
Runs internal script command. | |
string | Script_Run (string commandName, params string[] otherArguments) |
Runs internal script command. | |
virtual void | Script_PrintArguments (string messageString, string[] arguments) |
Prints the specified array of string arguments (usually passed as command-line arguments). | |
Public Attributes | |
const string | ConstDefaultHelp = "Help" |
Default command name for help. | |
const string | ConstHelpDefaultUniversal = "?" |
Universal name of the help command. | |
const string | ConstDefaultTestScrip = "TestScript" |
Default command name for test method. | |
Static Public Attributes | |
static int | DefaultOutputLevel = 1 |
Default output level for loadable scripts (mainly affects methods related to internal interpreter). | |
Protected Member Functions | |
delegate string | CommandMethod (string commandName, string[] args) |
Delegate for internal command methods. | |
abstract string | RunThis (string[] arguments) |
Performs the action of this object. Override this in derived classes! | |
abstract void | InitializeThis (string[] arguments) |
Performs all the necessary initializations of the object. Override this method in derived classes (if extra initialization is needed) and call the base class' method in it. | |
ICommandLineApplicationInterpreter | Script_CreateInterpreter () |
Creates and returns an interpreter that can be used as script's internal interpreter for running script's commands. Script's internal commands are added by the Script_AddCommands method before the created interpreter is returned.In order to create another interpreter, override the Script_CreateInterpreterWithoutCommands method. In order to add another set of script internal commands, override the Script_AddCommands method.Commands installed on this interpreter recieve the same command arguments as the Run command. | |
virtual string | Script_CommandHelp (string[] arguments) |
Prints help. | |
virtual string | Script_CommandTestScript (string[] arguments) |
Prints help. | |
Protected Attributes | |
int | _outputLevel = DefaultOutputLevel |
ICommandLineApplicationInterpreter | _script_interpreter |
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. | |
string[] | InitializationArguments [get, set] |
Arguments used by the initialization method. WARNING: arguments can only be set before initialization is performed. Initialization is performed either implicitly at the first call to the Run method or explicitly by calling the Initialize method. | |
virtual bool | IsInitialized [get, set] |
Whether the object has been initialized or not. | |
int | OutputLevel [get, set] |
Level of output to console produced by some operations of the current object. | |
virtual ICommandLineApplicationInterpreter | Script_Interpreter [get, set] |
Script's internal interpreter that takes care for execution of installed internal commands. This interpreter is created when first needed (lazy evaluation). | |
SortedList< string, string > | Script_CommandHelpStrings [get] |
Contains help strings associated with script commands installed on interpreter. | |
Private Attributes | |
object | _mainLock = new object() |
string[] | _initializationArguments |
bool | _isInitialized = false |
SortedList< string, string > | _script_CommandHelpStrings |
Base class for classes that can be dynamically loadeded from scripts and run, which provides functionality of dynamic scripting. It is recommendable to derive all such classes that implement the ILoadableScript interface from this base class.
Initialization of objects of this class can be performed by the Initialize method. If not performed explicitly, initialization is perform automatically at the first call to teh Run() method. $A Igor Jul09 May10;
IG::Lib::LoadableScriptBase::LoadableScriptBase | ( | ) | [inline] |
Argument-less constructor. If argument-less constructor is called then initialization is not performed and will be performed later.
delegate string IG::Lib::LoadableScriptBase::CommandMethod | ( | string | commandName, |
string[] | args | ||
) | [protected] |
Delegate for internal command methods.
commandName | Name of the internal command. |
args | Arguments to the command. |
abstract string IG::Lib::LoadableScriptBase::RunThis | ( | string[] | arguments | ) | [protected, pure virtual] |
Performs the action of this object. Override this in derived classes!
arguments | Arguments through which different information can be passed. |
Implemented in IG::Script::LoadableScriptExample, IG::Lib::LoadableScriptRealFunctionBase, IG::Lib::LoadableScriptScalarFunctionBase, IG::Script::ScriptAppBase, IG::Script::LoadableScriptSpecialFunctionBase, IG::Lib::LoadableScriptOptTest::LoadableScriptOptDerived, IG::Script::ScriptGraphics2dBase, IG::Script::ScriptGraphics3DBase, and IG::Script::TestIglibExt_ToDelete.
abstract void IG::Lib::LoadableScriptBase::InitializeThis | ( | string[] | arguments | ) | [protected, pure virtual] |
Performs all the necessary initializations of the object. Override this method in derived classes (if extra initialization is needed) and call the base class' method in it.
Implemented in IG::Script::LoadableScriptExample, IG::Lib::LoadableScriptRealFunctionBase, IG::Lib::LoadableScriptScalarFunctionBase, IG::Script::ScriptAppBase, IG::Script::LoadableScriptSpecialFunctionBase, IG::Lib::LoadableScriptOptBase, IG::Lib::LoadableScriptOptTest::LoadableScriptOptDerived, IG::Script::ScriptGraphics2dBase, IG::Script::ScriptGraphics3DBase, and IG::Script::TestIglibExt_ToDelete.
string IG::Lib::LoadableScriptBase::Run | ( | string[] | arguments | ) | [inline] |
Performs the action of this object. Override this in derived classes!
arguments | Arguments through which different information can be passed. |
Implements IG::Lib::ILoadableScript.
void IG::Lib::LoadableScriptBase::Initialize | ( | string[] | arguments | ) | [inline] |
Initializes the object. If not called explicitly, this method is automatically called at the first call to the Run method.
Implements IG::Lib::ILoadableScript.
virtual string IG::Lib::LoadableScriptBase::Script_DefaultInitialize | ( | string[] | arguments | ) | [inline, virtual] |
Default initialization method for scripts.
arguments | Initialization arguments. |
virtual string IG::Lib::LoadableScriptBase::Script_DefaultRun | ( | string[] | arguments | ) | [inline, virtual] |
Default run method for the script. Can be used when only installed commands are run by hte script.
arguments | Command arguments. The first argument must be name of the command that is run. |
virtual ICommandLineApplicationInterpreter IG::Lib::LoadableScriptBase::Script_CreateInterpreterWithoutCommands | ( | ) | [inline, virtual] |
Creates and returns an interpreter that can be used as script's internal interpreter for running script's commands. Commands installed on this interpreter recieve the same command arguments as the Run command.
ICommandLineApplicationInterpreter IG::Lib::LoadableScriptBase::Script_CreateInterpreter | ( | ) | [inline, protected] |
Creates and returns an interpreter that can be used as script's internal interpreter for running script's commands. Script's internal commands are added by the Script_AddCommands method before the created interpreter is returned.In order to create another interpreter, override the Script_CreateInterpreterWithoutCommands method. In order to add another set of script internal commands, override the Script_AddCommands method.Commands installed on this interpreter recieve the same command arguments as the Run command.
virtual void IG::Lib::LoadableScriptBase::Script_AddCommands | ( | ICommandLineApplicationInterpreter | interpreter, |
SortedList< string, string > | helpStrings | ||
) | [inline, virtual] |
Add wscript's internal commands to the specified interpreter.
interpreter | Interpreter to which commands are added. |
helpStrings | List where help strings for corresponding commands are stored (optional). |
Reimplemented in IG::Script::AppBase, IG::Script::ScriptAppBase, IG::Script::LoadableScriptSpecialFunctionBase, IG::Script::AppExtBase, IG::Script::ScriptGraphics2dBase, and IG::Script::ScriptGraphics3DBase.
virtual string IG::Lib::LoadableScriptBase::Script_CommandHelp | ( | string[] | arguments | ) | [inline, protected, virtual] |
Prints help.
commands | Arguments. |
virtual string IG::Lib::LoadableScriptBase::Script_CommandTestScript | ( | string[] | arguments | ) | [inline, protected, virtual] |
Prints help.
commands | Arguments. |
delegate string IG::Lib::LoadableScriptBase::Script_CommandDelegate | ( | string[] | args | ) |
Delegate for commands that are installed on script's internal interpreter (property Interpreter). These methods only take command arguments as parameters, and the first argument is usually name under which command is installed.
interpreter | Interpreter on which commad is run.
|
void IG::Lib::LoadableScriptBase::Script_AddCommand | ( | string | commandName, |
Script_CommandDelegate | command, | ||
string | helpString | ||
) | [inline] |
Adds a new internal script command under specified name to the internal interpreter of the current script object.
commandName | Name of the command. |
Must not be null or empty string.
command | Method that executes the command. |
Must not be null.
helpString | Help string associated with command, optionsl (can be null). |
virtual void IG::Lib::LoadableScriptBase::Script_AddCommand | ( | ICommandLineApplicationInterpreter | interpreter, |
SortedList< string, string > | helpStrings, | ||
string | commandName, | ||
Script_CommandDelegate | command, | ||
string | helpString | ||
) | [inline, virtual] |
Adds a new internal script command under specified name to the internal interpreter of the current script object.
interpreter | Interpreter on which the command is added. |
commandName | Name of the command. |
Must not be null or empty string.
command | Method that executes the command. |
Must not be null.
helpString | Help string associated with command, optionsl (can be null). |
Reimplemented in IG::Script::LoadableScriptSpecialFunctionBase.
string IG::Lib::LoadableScriptBase::Script_GetHelpString | ( | string | scriptCommandName | ) | [inline] |
Returns help string for internal script command with specified name, or null if help string is not installed for such a command.
scriptCommandName | Name of the csript command. |
void IG::Lib::LoadableScriptBase::Script_PrintCommandsHelp | ( | ) | [inline] |
Prits help for the installed internal commands of the script.
virtual bool IG::Lib::LoadableScriptBase::Script_ContainsCommand | ( | string | commandName | ) | [inline, virtual] |
Returns true if the internal script's interpreter contains a command with specified name, false otherwise.
commandName | Name of the command whose existence is queried. |
virtual bool IG::Lib::LoadableScriptBase::Script_ContainsScriptCommand | ( | string | commandName | ) | [inline, virtual] |
Returns true if the specified command is script command (i.e. its first argument is command-name and it is run through the Script_CommandAdapter object).
commandName | Name of the command that is queried. |
string IG::Lib::LoadableScriptBase::Script_Run | ( | string[] | arguments | ) | [inline] |
Runs internal script command.
arguments | Arguments of the command. The first argument must be command name. |
ArgumentException | When argumens or command are not specified or command is not known. |
string IG::Lib::LoadableScriptBase::Script_Run | ( | string | commandName, |
params string[] | otherArguments | ||
) | [inline] |
Runs internal script command.
commandName | Name of the command |
otherArguments | The remainind command arguments (without a name). |
Name is prepended to arguments before the script is run.
ArgumentException | When argumens or command are not specified or command is not known. |
virtual void IG::Lib::LoadableScriptBase::Script_PrintArguments | ( | string | messageString, |
string[] | arguments | ||
) | [inline, virtual] |
Prints the specified array of string arguments (usually passed as command-line arguments).
arguments | Arguments to be printed. |
messageString | Message to be printed first (optional, can be null). |
object IG::Lib::LoadableScriptBase::_mainLock = new object() [private] |
string [] IG::Lib::LoadableScriptBase::_initializationArguments [private] |
bool IG::Lib::LoadableScriptBase::_isInitialized = false [private] |
int IG::Lib::LoadableScriptBase::DefaultOutputLevel = 1 [static] |
Default output level for loadable scripts (mainly affects methods related to internal interpreter).
int IG::Lib::LoadableScriptBase::_outputLevel = DefaultOutputLevel [protected] |
const string IG::Lib::LoadableScriptBase::ConstDefaultHelp = "Help" |
Default command name for help.
const string IG::Lib::LoadableScriptBase::ConstHelpDefaultUniversal = "?" |
Universal name of the help command.
const string IG::Lib::LoadableScriptBase::ConstDefaultTestScrip = "TestScript" |
Default command name for test method.
SortedList<string, string> IG::Lib::LoadableScriptBase::_script_CommandHelpStrings [private] |
object IG::Lib::LoadableScriptBase::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.
string [] IG::Lib::LoadableScriptBase::InitializationArguments [get, set] |
Arguments used by the initialization method. WARNING: arguments can only be set before initialization is performed. Initialization is performed either implicitly at the first call to the Run method or explicitly by calling the Initialize method.
Implements IG::Lib::ILoadableScript.
virtual bool IG::Lib::LoadableScriptBase::IsInitialized [get, set] |
Whether the object has been initialized or not.
Implements IG::Lib::ILoadableScript.
int IG::Lib::LoadableScriptBase::OutputLevel [get, set] |
Level of output to console produced by some operations of the current object.
virtual ICommandLineApplicationInterpreter IG::Lib::LoadableScriptBase::Script_Interpreter [get, set] |
Script's internal interpreter that takes care for execution of installed internal commands. This interpreter is created when first needed (lazy evaluation).
Although this property is market virtual, you will normally not need to override it. Instead, override the Script_CreateInterpreter method, whch should do all the initializations of the interpreter.
SortedList<string, string> IG::Lib::LoadableScriptBase::Script_CommandHelpStrings [get, protected] |
Contains help strings associated with script commands installed on interpreter.