Package OpenCAGE.Controller.Command

This package contains the commands.

Class Abstract_Command

extends OpenCAGE.Controller.Command.Command

Implementation of all operations and attributes Command subclasses have in common.

Attributes

private OpenCAGE.Controller.Command.Command_State State 

Stores the current state of the Command object.

private FET.Parameter_Pot Param_Pot 

The Param_Pot stores the parameter necessary for the execution of the Command.

private OpenCAGE.Data.Data Oc_Data 

This object holds all data for one instance of OpenCAGE (actual model, lists of command factories, ...)

private OpenCAGE.Controller.Command.Command_Observers_Lists.List Observer_List 

This object holds all observers attached to the command

public FET.Data_Gate Data_Gate 

The Data_Gate where the Command registers its Parameter Pot to.

Operations

public Execute(void);

Executes the Command. May raise Illegal_State_Exception if precondition is not met, i.e. if the state is not "Collect_Data, Done". [This description is adopted from 'OpenCAGE.Controller.Command.Command'.]

Precondition: Collect_Data has been performed before and Execute is called the first time. [This precondition is adopted from 'OpenCAGE.Controller.Command.Command'.]

public Collect_Data(void);

Collects the data. It simply calls Start_Collect_Data, Do_Collect_Data and End_Collect_Data.

Precondition: Initialization completed and Collect_Data was not called before. [This precondition is adopted from 'OpenCAGE.Controller.Command.Command'.]

Postcondition: The Command knows the data necessary for its execution. [This postcondition is adopted from 'OpenCAGE.Controller.Command.Command'.]

public Attach( OpenCAGE.Controller.Command.Command_Observer Observer);

Registers a Command_Observer at a the Command. The register observer will be notified whenever the state of the Command object changes. [This description is adopted from 'OpenCAGE.Controller.Command.Command'.]

Postcondition: The Command_Observer is registered. [This postcondition is adopted from 'OpenCAGE.Controller.Command.Command'.]

public Ada.Strings.Unbounded.Unbounded_String To_String(void);

Returns a string that tells what the Command does in a human readable format. This operation is used for debugging. [This description is adopted from 'OpenCAGE.Controller.Command.Command'.]

public Ada.Strings.Unbounded.Unbounded_String Get_Name(void);

Returns the name of the Command. This operation is used for writing the script. [This description is adopted from 'OpenCAGE.Controller.Command.Command'.]

public Set_Oc_Data( OpenCAGE.Data.Data To);

Sets the attribute Oc_Data to the given value.

private Set_Param_Pot( FET.Parameter_Pot To);

Sets the attribute Param_Pot to the given value.

private End_Initialization(void);

Ends the initialization.

private Start_Collect_Data(void);

Starts collecting data.

private End_Collect_Data( OpenCAGE.Controller.Command.Command_State_State Error_State := Done);

Ends collecting data. If there was an error, specify this as parameter.

private Do_Collect_Data(void);

Does the data collection by sending the gate a distribute message.

private Start_Execution(void);

Starts the execution.

private End_Execution( OpenCAGE.Controller.Command.Command_State_State Error_State := Done);

Ends the execution. If there was an error, specify this as parameter.

private Notify_Observers(void);

Notifies the observers.

public Boolean Is_Cancelled_By_User(void);

True, when the state is Cancelled_By_User, False, else.

public Boolean Is_Cancelled_By_Error(void);

True, when the state is Cancelled_By_Error, False, else.

Class Abstract_Command_Factory

extends OpenCAGE.Controller.Command.Command_Factory

Attributes

private OpenCAGE.Data.Data Oc_Data 

This object holds all data for one instance of OpenCAGE (actual model, lists of command factories, ...)

Operations

public OpenCAGE.Controller.Command.Command Create_Command( FET.Data_Source Data);

Creates a new command object and initializes it with the given data source. The factory may add other data sources (e.g. dialogs) to the command. The factory may (but is not required to) check if the given data source contains all data required. It is recommanded to first check with Can_Excecute if the created command will get all data required. [This description is adopted from 'OpenCAGE.Controller.Command.Command_Factory'.]

public Ada.Strings.Unbounded.Unbounded_String Get_Name(void);

Returns the name of the command this factory creates. [This description is adopted from 'OpenCAGE.Controller.Command.Command_Factory'.]

Postcondition: Nothing is changed. [This postcondition is adopted from 'OpenCAGE.Controller.Command.Command_Factory'.]

public Set_Oc_Data( OpenCAGE.Data.Data To);

Sets the attribute Oc_Data to the given value.

public Boolean Can_Execute( FET.Data_Source Data);

Computes all necessary conditions and tells whether the Command is executable or not. Probably the Command_Factory needs a data_source first. [This description is adopted from 'OpenCAGE.Controller.Command.Command_Factory'.]

public FET.Data_Gate Build_Data_Gate( FET.Data_Source Data);

Builds the Data Gate from the given Data Source and returns it.

Class Command

throws Illegal_State_Exception .

This is the interface all Commands have to implement. A Command is used to execute a certain operation. Thus, basically the operations Collect_Data and Execute are used in this order. The Command has different status represented by th Command_State class. The status can be asked for by the Get_Status operation. It is possible to register Command_Observer at a Command Object. They are notified whenever the state of the CommandObject changes. Finally, the operation Get_Param_Pot hands the object that stores the parameters necessary for the execution of the Command, the To_String operation returns a string that tells what the Command does in a human readable format and the Get_Name operation returns the name of the Command.

Operations

public Execute(void);

Executes the Command. May raise Illegal_State_Exception if precondition is not met, i.e. if the state is not "Collect_Data, Done".

Precondition: Collect_Data has been performed before and Execute is called the first time.

public Collect_Data(void);

This operation collects the data necessary for the execution of this Command. May raise Illegal_State_Exception if precondition is not met, i.e. if the state is not "Initialization, Done".

Precondition: Initialization completed and Collect_Data was not called before.

Postcondition: The Command knows the data necessary for its execution.

public Attach( OpenCAGE.Controller.Command.Command_Observer Observer);

Registers a Command_Observer at a the Command. The register observer will be notified whenever the state of the Command object changes.

Postcondition: The Command_Observer is registered.

public Ada.Strings.Unbounded.Unbounded_String To_String(void);

Returns a string that tells what the Command does in a human readable format. This operation is used for debugging.

public Ada.Strings.Unbounded.Unbounded_String Get_Name(void);

Returns the name of the Command. This operation is used for writing the script.

public OpenCAGE.Controller.Command.Command_State Get_State(void);

Returns the current state of the command.

Class Command_Factory

This is the interface for command factories which is useed to create commands. This follows the abstract factory pattern.

Operations

public OpenCAGE.Controller.Command.Command Create_Command( FET.Data_Source Data);

Creates a new command object and initializes it with the given data source. The factory may add other data sources (e.g. dialogs) to the command. The factory may (but is not required to) check if the given data source contains all data required. It is recommanded to first check with Can_Excecute if the created command will get all data required.

public Ada.Strings.Unbounded.Unbounded_String Get_Name(void);

Returns the name of the command this factory creates.

Postcondition: Nothing is changed.

public Boolean Can_Execute( FET.Data_Source Data);

Computes all necessary conditions and tells whether the Command is executable or not. Probably the Command_Factory needs a data_source first.

Class Command_Observer

This is the abstract super class of all classes that observe Commands. If a Command Object changes its state, it notifies all registered Command Observers.

Operations

public Changed( OpenCAGE.Controller.Command.Command Cmd);

Tells the Command_Observer that the state of a Command Object changed.

Class Command_State

This class stores the state of a command. This state consists of two values: the current action and the state of this action. It is really really REALLY important to use the atomar Get() and Set() functions if both Action and Status are to be read or written to. Otherwise a parallel running task might get really confused.

Attributes

private OpenCAGE.Controller.Command.Command_State_P S 

The protected state.

Operations

public Ada.Strings.Unbounded.Unbounded_String To_String(void);

Returns a human readable string telling the state consisting of action and its state.

public Boolean Is_Finished(void);

Returns true if the command is finished, i.e. the command completed the execute method or it aborted in any stage with an error or by user request, else false.

private Set_State( OpenCAGE.Controller.Command.Command_State_State To);

Setter method for attribute Command_State_State

private Set_Action( OpenCAGE.Controller.Command.Command_State_Action To);

Setter method for attribute Command_State_Action

private Set( OpenCAGE.Controller.Command.Command_State_Action Action, OpenCAGE.Controller.Command.Command_State_State State);

Setter method for attribute Command_State_Action and Command_State_State

private Get( OpenCAGE.Controller.Command.Command_State_Action Action, OpenCAGE.Controller.Command.Command_State_State State);

Getter method for attribute Command_State_Action and Command_State_State

Class Command_State_Action

This is an Enumeration. Possible values: Initalization, Collect_Data and Execution.

Class Command_State_P

A protected object that encapsulates the state of a command. It is used internally in Command_State.

Class Command_State_State

This is an Enumeration. Possible values: Running, Done, Cancelled_By_User and Cancelled_By_Error.