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

IG::Lib::CommandLine Class Reference

Represents a single command-line that can be executed. $A Igor Feb09;. More...

Inheritance diagram for IG::Lib::CommandLine:
Collaboration diagram for IG::Lib::CommandLine:

List of all members.

Public Member Functions

 CommandLine ()
 Creates a new command that can be used in command-line interpreters.
void Register ()
 Registers the current object. Subsequent calls (after the first one) have no effect.
bool IsRegistered ()
 Returns true if the current object is registered, false if not.
void Unregister ()
 Unregisters the current object if it is currently registered. Can be performed several times, in this case only the first call may have effect.
void AddCommandReference (int interpreterId, string commandName, string description)
 Adds a new command use reference for this command. This method should be called whenever the command in installed on some interpreter. An internal list is used to store all references to this command on various interpreters. Stored references are unique (i.e. pairs {InterpreterId, CommandName}).
void RemoveCommandReference (int interpreterId, string commandName)
 Removes command uage reference. This method should be called whenever a command is uninstalled form interpreter.
abstract void Dispose ()
 Clean up after the reference is not used any more.

Protected Member Functions

abstract void Execute (CommandLineInterpreter interpreter, string command, string[] arguments)
 Executes the current command. Warning: whenever the data on command object (i.e. this) or interpreter object is accessed, these objects must be locked! If such data is not accessed then locking is not necessary.

Protected Attributes

string _command
 Temporary storage of command name for execution in a new thread.
string[] _arguments
 Temporary storage of command arguments for execution in a new thread.
bool _threadStarted
 Flag used to signal that command data has been picked by the executing thread and so object access can be unlocked.

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.
virtual int Id [get]
 Returns unique Id (in the scope of a given type) of the current object. Method is defined as virtual so that derived class can have its own IDs by defining its own static IdentifiableGenerator object.
ObjectRegister< CommandLineObjectRegister [get]
 Gets object register where the current object is registered.

Private Member Functions

 ~CommandLine ()

Private Attributes

object _mainLock = new object()
IdProxy _idPproxy
 Proxy object that implements the IIdentifiable interface for this object.
SortedDictionary
< CommandUseReference, string > 
_commandReferences

Static Private Attributes

static ObjectRegister
< CommandLine
_register
 Static object that providees object register and generates IDs for this class:

Detailed Description

Represents a single command-line that can be executed. $A Igor Feb09;.


Constructor & Destructor Documentation

IG::Lib::CommandLine::CommandLine ( ) [inline]

Creates a new command that can be used in command-line interpreters.

IG::Lib::CommandLine::~CommandLine ( ) [inline, private]

Member Function Documentation

void IG::Lib::CommandLine::Register ( ) [inline]

Registers the current object. Subsequent calls (after the first one) have no effect.

Implements IG::Lib::IRegisterable< T >.

bool IG::Lib::CommandLine::IsRegistered ( ) [inline]

Returns true if the current object is registered, false if not.

Returns:

Implements IG::Lib::IRegisterable< T >.

void IG::Lib::CommandLine::Unregister ( ) [inline]

Unregisters the current object if it is currently registered. Can be performed several times, in this case only the first call may have effect.

Implements IG::Lib::IRegisterable< T >.

void IG::Lib::CommandLine::AddCommandReference ( int  interpreterId,
string  commandName,
string  description 
) [inline]

Adds a new command use reference for this command. This method should be called whenever the command in installed on some interpreter. An internal list is used to store all references to this command on various interpreters. Stored references are unique (i.e. pairs {InterpreterId, CommandName}).

Parameters:
interpreterIdID of the interpreter where command is installed.
commandNameCommand name under which the command is installed on this interpreter.
descriptionCustom description of the specified reference, can be null.
void IG::Lib::CommandLine::RemoveCommandReference ( int  interpreterId,
string  commandName 
) [inline]

Removes command uage reference. This method should be called whenever a command is uninstalled form interpreter.

abstract void IG::Lib::CommandLine::Execute ( CommandLineInterpreter  interpreter,
string  command,
string[]  arguments 
) [protected, pure virtual]

Executes the current command. Warning: whenever the data on command object (i.e. this) or interpreter object is accessed, these objects must be locked! If such data is not accessed then locking is not necessary.

Parameters:
interpreterInterpreter that executed the command.
commandCommand name under which the command is executed. A single command instance can be installed under several names on the interpreter.
argumentsArguments of the command.
abstract void IG::Lib::CommandLine::Dispose ( ) [pure virtual]

Clean up after the reference is not used any more.


Member Data Documentation

object IG::Lib::CommandLine::_mainLock = new object() [private]
ObjectRegister<CommandLine> IG::Lib::CommandLine::_register [static, private]
Initial value:
            new ObjectRegister<CommandLine>(1 )

Static object that providees object register and generates IDs for this class:

Initial value:
            new IdProxy(_register)

Proxy object that implements the IIdentifiable interface for this object.

Initial value:
                new SortedDictionary<CommandUseReference, string>()
string IG::Lib::CommandLine::_command [protected]

Temporary storage of command name for execution in a new thread.

string [] IG::Lib::CommandLine::_arguments [protected]

Temporary storage of command arguments for execution in a new thread.

Flag used to signal that command data has been picked by the executing thread and so object access can be unlocked.


Property Documentation

object IG::Lib::CommandLine::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.

virtual int IG::Lib::CommandLine::Id [get]

Returns unique Id (in the scope of a given type) of the current object. Method is defined as virtual so that derived class can have its own IDs by defining its own static IdentifiableGenerator object.

Implements IG::Lib::IIdentifiable.

ObjectRegister<CommandLine> IG::Lib::CommandLine::ObjectRegister [get]

Gets object register where the current object is registered.

Implements IG::Lib::IRegisterable< T >.


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