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

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | Private Attributes | Static Private Attributes | List of all members
IG.Lib.LoadableScriptBase Class Referenceabstract

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...

Inheritance diagram for IG.Lib.LoadableScriptBase:
[legend]
Collaboration diagram for IG.Lib.LoadableScriptBase:
[legend]

## Classes
class | Script_CommandAdapter
| Adapts that converts internal script commands (delegate of type Script_CommandDelegate) to interpreter commands. 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. More...
string | Run (string[] arguments)
| Performs the action of this object. Override this in derived classes! More...
void | Initialize (string[] arguments)
| Initializes the object. If not called explicitly, this method is automatically called at the first call to the Run method. More...
virtual string | Script_DefaultInitialize (string[] arguments)
| Default initialization method for scripts. More...
virtual string | Script_DefaultRun (string[] arguments)
| Default run method for the script. Can be used when only installed commands are run by hte script. More...
virtual ICommandLineApplicationInterpreter | Script_CreateInterpreterWithoutCommands ()
| Creates and returns an interpreter that can be used as script's internal interpreter for running script's commands. More...
virtual void | Script_AddCommands (ICommandLineApplicationInterpreter interpreter, SortedList< string, string > helpStrings)
| Add wscript's internal commands to the specified interpreter. More...
delegate string | Script_CommandDelegate (string[] args)
| Delegate for commands that are installed on script's internal interpreter (property Interpreter). More...
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. More...
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. More...
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. More...
void | Script_PrintCommandsHelp ()
| Prits help for the installed internal commands of the script. More...
virtual bool | Script_ContainsCommand (string commandName)
| Returns true if the internal script's interpreter contains a command with specified name, false otherwise. More...
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). More...
virtual void | Script_RemoveCommand (string commandName)
| Removes the specified internal script command from the internal interpreter of the current scripting object. More...
virtual void | Script_RemoveAllCommands ()
| Removes ALL internal script commands from the internal interpreter of the current scripting object. More...
string | Script_Run (string[] arguments)
| Runs internal script command. More...
string | Script_Run (string commandName, params string[] otherArguments)
| Runs internal script command. More...
virtual void | Script_PrintArguments (string messageString, string[] arguments)
| Prints the specified array of string arguments (usually passed as command-line arguments). More...

## Public Attributes
const string | ConstDefaultHelp = "Help"
| Default command name for help. More...
const string | ConstHelpDefaultUniversal = "?"
| Universal name of the help command. More...
const string | ConstDefaultTestScrip = "TestScript"
| Default command name for test method. More...

## Protected Member Functions
delegate string | CommandMethod (string commandName, string[] args)
| Delegate for internal command methods. More...
abstract string | RunThis (string[] arguments)
| Performs the action of this object. Override this in derived classes! More...
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. More...
ICommandLineApplicationInterpreter | Script_CreateInterpreter ()
| Creates and returns an interpreter that can be used as script's internal interpreter for running script's commands. More...
virtual string | Script_CommandHelp (string[] arguments)
| Prints help. More...
virtual string | Script_CommandTestScript (string[] arguments)
| Prints help. More...

## Protected Attributes
string | _embeddedCommandName = null
int | _outputLevel = DefaultOutputLevel
ICommandLineApplicationInterpreter | _script_interpreter

## Properties
string | EmbeddedCommandName`[get, set]`
| Command that was used to launch the current embedded application script. More...
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. More...
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. More...
virtual bool | IsInitialized`[get, protected set]`
| Whether the object has been initialized or not. More...
static int | DefaultOutputLevel`[get, set]`
int | OutputLevel`[get, set]`
| Level of output to console produced by some operations of the current object. More...
virtual ICommandLineApplicationInterpreter | Script_Interpreter`[get, protected set]`
| Script's internal interpreter that takes care for execution of installed internal commands. More...
SortedList< string, string > | Script_CommandHelpStrings`[get]`
| Contains help strings associated with script commands installed on interpreter. More...
Properties inherited from IG.Lib.ILoadableScript
string | EmbeddedCommandName`[get, set]`
| Command that was used to launch the current embedded application script. More...
string[] | InitializationArguments`[get, set]`
| Arguments used by the initialization method. More...
bool | IsInitialized`[get]`
| Whether the object has been initialized or not. More...
Properties inherited from IG.Lib.ILockable
object | Lock`[get]`

## Private Attributes
object | _mainLock = new object()
string[] | _initializationArguments
bool | _isInitialized = false
SortedList< string, string > | _script_CommandHelpStrings

## Static Private Attributes
static int | _defaultOutputLevel = -1

## Detailed Description

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;

## Constructor & Destructor Documentation

IG.Lib.LoadableScriptBase.LoadableScriptBase | ( |  | ) |
| inline

Argument-less constructor. If argument-less constructor is called then initialization is not performed and will be performed later.

## Member Function Documentation

delegate string IG.Lib.LoadableScriptBase.CommandMethod | ( | string | commandName,
|  | string[] | args
| ) |  |
| protected

Delegate for internal command methods.

Parameters

  commandName | Name of the internal command.
  args | Arguments to the command.

Returns

abstract string IG.Lib.LoadableScriptBase.RunThis | ( | string[] | arguments | ) |
| protected pure virtual

Performs the action of this object. Override this in derived classes!

Parameters

  arguments | Arguments through which different information can be passed.

Returns
  String that represents result of the action.

Implemented in IG.Script.LoadableScriptSpecialFunctionBase, IG.Lib.LoadableScriptOptTest.LoadableScriptOptDerived, IG.Script.ScriptAppBase, IG.Script.LoadableScriptExample, IG.Lib.LoadableScriptRealFunctionBase, IG.Script.ScriptGraphics3DBase, IG.Lib.LoadableScriptScalarFunctionBase, IG.Script.ScriptGraphics2dBase, 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.LoadableScriptSpecialFunctionBase, IG.Lib.LoadableScriptOptTest.LoadableScriptOptDerived, IG.Script.ScriptAppBase, IG.Lib.LoadableScriptOptShellBaseControllable, IG.Script.LoadableScriptExample, IG.Lib.LoadableScriptRealFunctionBase, IG.Lib.LoadableScriptOptBase, IG.Lib.LoadableScriptScalarFunctionBase, IG.Script.ScriptGraphics3DBase, IG.Script.ScriptGraphics2dBase, and IG.Script.TestIglibExt_ToDelete.

string IG.Lib.LoadableScriptBase.Run | ( | string[] | arguments | ) |
| inline

Performs the action of this object. Override this in derived classes!

Parameters

  arguments | Arguments through which different information can be passed.

Returns
  String that represents result of the action.

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.

Parameters

  arguments | Initialization arguments.

Returns
  null string.

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.

Parameters

  arguments | Command arguments. The first argument must be name of the command that is run.

Returns
  Return value of the script 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.

References IG.Lib.CommandLineApplicationScriptInterpreter.Script_CommandHelpStrings, and IG.Lib.CommandLineApplicationInterpreter.WarnCommandReplacement.

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.

Parameters

  interpreter | Interpreter to which commands are added.
  helpStrings | List where help strings for corresponding commands are stored (optional).

Reimplemented in IG.Script.LoadableScriptSpecialFunctionBase, IG.Script.ScriptAppBase, IG.Script.ScriptGraphics3DBase, IG.Script.ScriptGraphics2dBase, IG.Script.AppExtBase, and IG.Script.AppBase.

virtual string IG.Lib.LoadableScriptBase.Script_CommandHelp | ( | string[] | arguments | ) |
| inline protected virtual

Prints help.

Parameters

  commands | Arguments.

Returns
  null.

virtual string IG.Lib.LoadableScriptBase.Script_CommandTestScript | ( | string[] | arguments | ) |
| inline protected virtual

Prints help.

Parameters

  commands | Arguments.

Returns
  null.

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.

Parameters

    interpreter | Interpreter on which commad is run. Parameters
    args | Command arguments. The first argument is internal script's command name.
  Returns Command's return value.

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.

Parameters

  commandName | Name of the command.

Must not be null or empty string.

Parameters

  command | Method that executes the command.

Must not be null.

Parameters

  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.

Parameters

  interpreter | Interpreter on which the command is added.
  commandName | Name of the command.

Must not be null or empty string.

Parameters

  command | Method that executes the command.

Must not be null.

Parameters

  helpString | Help string associated with command, optionsl (can be null).

Reimplemented in IG.Script.LoadableScriptSpecialFunctionBase.

References IG.Lib.ICommandLineApplicationInterpreter.AddCommand(), IG.Lib.ICommandLineApplicationInterpreter.ContainsCommand(), IG.Lib.LoadableScriptBase.Script_CommandAdapter.InterpreterCommand(), and IG.Lib.ICommandLineApplicationInterpreter.RemoveCommand().

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.

Parameters

  scriptCommandName | Name of the csript command.

Referenced by IG.Lib.LoadableScriptBase.Script_CommandAdapter.InterpreterCommand().

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.

Parameters

  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).

Parameters

  commandName | Name of the command that is queried.

virtual void IG.Lib.LoadableScriptBase.Script_RemoveCommand | ( | string | commandName | ) |
| inline virtual

Removes the specified internal script command from the internal interpreter of the current scripting object.

Parameters

  interpreter | Interpreter on which the command is removed.
  commandName | Name of the command.

Must not be null or empty string.

virtual void IG.Lib.LoadableScriptBase.Script_RemoveAllCommands | ( |  | ) |
| inline virtual

Removes ALL internal script commands from the internal interpreter of the current scripting object.

Parameters

  interpreter | Interpreter on which the command is removed.
  commandName | Name of the command.

Must not be null or empty string.

References IG.Lib.ICommandLineApplicationInterpreter.RemoveAllCommands().

string IG.Lib.LoadableScriptBase.Script_Run | ( | string[] | arguments | ) |
| inline

Runs internal script command.

Parameters

  arguments | Arguments of the command. The first argument must be command name.

Returns
  The return valu of executed command.

Exceptions

  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.

Parameters

  commandName | Name of the command
  otherArguments | The remainind command arguments (without a name).

Name is prepended to arguments before the script is run.

Exceptions

  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).

Parameters

  arguments | Arguments to be printed.
  messageString | Message to be printed first (optional, can be null).

## Member Data Documentation

string IG.Lib.LoadableScriptBase._embeddedCommandName = null
| protected

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 private

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.

ICommandLineApplicationInterpreter IG.Lib.LoadableScriptBase._script_interpreter
| protected

SortedList<string, string> IG.Lib.LoadableScriptBase._script_CommandHelpStrings
| private

## Property Documentation

string IG.Lib.LoadableScriptBase.EmbeddedCommandName
| get set

Command that was used to launch the current embedded application script.

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.

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.

virtual bool IG.Lib.LoadableScriptBase.IsInitialized
| get protected set

Whether the object has been initialized or not.

int IG.Lib.LoadableScriptBase.DefaultOutputLevel
| static get set

Referenced by IG.Lib.ShellApplication< InterpreterType >.TestMain().

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 protected 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.

The documentation for this class was generated from the following file:

- igbase/interpreters/scriptloader/LoadableScriptBase.cs