- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Interfaces::ExecutionInterfaceBase Class Reference

`#include <ExecutionInterfaceBase.h>`

Inheritance diagram for Mers::Interfaces::ExecutionInterfaceBase:

[legend]
Collaboration diagram for Mers::Interfaces::ExecutionInterfaceBase:

[legend]
List of all members.

## Public Types
typedef ::Mers::Utils::Containers::SharedPointer< Task > | t_TaskSharedPointer
| This is the type of task shared pointer used in this class.
typedef ::Mers::Utils::Containers::SharedPointer< Task > | TaskIdentifier
## Public Member Functions
| ExecutionInterfaceBase (TaskFactory *pTaskFactory)
virtual | ~ExecutionInterfaceBase ()
virtual int | executeTask (TaskIdentifier task)
virtual bool | start (TaskIdentifier task)=0
virtual bool | stop ()=0
virtual bool | stop (TaskIdentifier task)=0
virtual int | step (bool block=true)=0
virtual std::set< TaskIdentifier > | getFailedTasks ()
virtual bool | isFailure ()
virtual bool | isDone ()=0
virtual bool | isDone (TaskIdentifier task)=0
virtual bool | isReady (TaskIdentifier task)
virtual Mers::Utils::Lang::String | getActiveTasksString () const
virtual TaskIdentifier | createTask (const Mers::Utils::Lang::String &taskName)
virtual TaskIdentifier | createTask (const Mers::Utils::Lang::String &taskName, std::vector< const Mers::Utils::Lang::String * > const &parameters)
virtual bool | isValid (TaskIdentifier task)
virtual void | deleteTask (TaskIdentifier task)
virtual TaskFactory * | getTaskFactory ()
virtual t_TaskSharedPointer | getFailedTask (TaskIdentifier task) const
virtual t_TaskSharedPointer | getTask (TaskIdentifier task) const
virtual std::set< TaskIdentifier > | getRecentlyFailedTasks ()=0
virtual std::set< TaskIdentifier > | getRecentlyCompletedTasks ()=0
Mers::Utils::Lang::String | PrintTasks (void)
## Protected Member Functions
virtual void | setTaskFactory (TaskFactory *tFactory)
virtual TaskIdentifier | getTaskID (t_TaskSharedPointer pTask)
## Protected Attributes
std::set< TaskIdentifier > | mTasks
| The set of all tasks that this object has allocated.
std::set< TaskIdentifier > | mFailedTasks
| The set of failed tasks.
TaskFactory * | mTaskFactory
| The current task factory.

## Detailed Description

This class represents the default interface between two engine layers for generic interaction. The interface supports arbitrarily parameterized task execution as well as task-queries.

A note on stopping and starting activities. The start and stop methods do not start or stop an activity, but schedule it to be started or stopped when we next call step. This scheme allows us to start and stop multiple activities simultaneously. Also, step may be required to advance the next layer down (eg titan).

A note on creating tasks. Repeated calls to TaskFactory::createTask with task names and parameter lists will create identical task objects, but the objects are unique, so have a unique task ID. We do not prune duplicated tasks because a task respresents a plan activity. If a plan includes repeated instances of a given activity, we need to reflect that in our task list. This allows us to track the progress of the execution, even if identical tasks are executed on multiple occasions. This means that each task should be executed exactly once.

Author:
  Paul H. Elliott

Definition at line 51 of file ExecutionInterfaceBase.h.

## Member Typedef Documentation

typedef ::Mers::Utils::Containers::SharedPointer< Task > Mers::Interfaces::ExecutionInterfaceBase::TaskIdentifier

This could be a different type from the t_TaskSharedPointer, so we should always convert between the two. We wanted a unique identifier and the pointer is a siple choice.

Definition at line 63 of file ExecutionInterfaceBase.h.

## Constructor & Destructor Documentation

ExecutionInterfaceBase::ExecutionInterfaceBase | ( | TaskFactory * | pTaskFactory | ) |

Creates a new execution interface.

Definition at line 36 of file ExecutionInterfaceBase.cpp.

References setTaskFactory().

Here is the call graph for this function:

ExecutionInterfaceBase::~ExecutionInterfaceBase | ( |  | ) | `[virtual]`

Destroys this object.

Definition at line 50 of file ExecutionInterfaceBase.cpp.

References mTaskFactory, and Mers::Utils::Lang::ReferencedObject::removeReference().

Here is the call graph for this function:

## Member Function Documentation

virtual bool Mers::Interfaces::ExecutionInterfaceBase::start | ( | TaskIdentifier | task | ) | `[pure virtual]`

Sets the task to be started when "step" is ran. The task will continue until it has either completed or is told to stop. The execution status of tasks can generally be queried, so the termination of the task can be determined. This routine should generally do as little work as possible.

Parameters:

  | task | The name of the task that should be started.

Returns:
  True if the task was found and set to start or if the task is already running, otherwise false. False may be returned for many reasons, including the inability of finding the task, the inability of starting the task (due to limitations in the conditions on the task, the number of times it can be run, the total number of tasks that can be run, etc), etc.

Implemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, Mers::Executives::DeductiveController::Command::CommandTranslator, Mers::Executives::DeductiveController::DCInterface, and Mers::Interfaces::ExecutionInterface.

Referenced by Mers::Executives::DeductiveController::Command::DispatcherPair::dispatch(), executeTask(), Mers::Executives::DeductiveController::DCInterface::process_next_control_cmd(), and Mers::Executives::DeductiveController::DCInterface::start().

virtual bool Mers::Interfaces::ExecutionInterfaceBase::stop | ( |  | ) | `[pure virtual]`

Sets all tasks to be stop when "step" is ran. Every command that was started will be stopped, if possible.

Implemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, Mers::Executives::DeductiveController::Command::CommandTranslator, Mers::Executives::DeductiveController::DCInterface, and Mers::Interfaces::ExecutionInterface.

Referenced by executeTask(), and Mers::Executives::DeductiveController::DCInterface::stop().

virtual bool Mers::Interfaces::ExecutionInterfaceBase::stop | ( | TaskIdentifier | task | ) | `[pure virtual]`

If the task is currently active, it will set the task to be stopped when "step" is ran. Has no effect if the task was already stopped or already complete.

Parameters:

  | task | The task that should be stopped. A task will be stopped if it is still running and the task can be stopped.

Returns:
  true If the task was successfully stopped or was already stopped, false otherwise.

Implemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, Mers::Executives::DeductiveController::Command::CommandTranslator, Mers::Executives::DeductiveController::DCInterface, and Mers::Interfaces::ExecutionInterface.

virtual int Mers::Interfaces::ExecutionInterfaceBase::step | ( | bool | block = `true` | ) | `[pure virtual]`

Takes a single processing step, i.e. starts and stops appropriate tasks and attempt to make progress for the started activites. If block is false, then this executive will only progress if it is ready to progress. If block is true, then this executive will wait until progress can be made before returning. Generally, block should be false for reactive systems, and should be true when running this task-step process on a separate thread.

Parameters:

  | block | If true, this procedure will always progress before returning. If false, this procedure will not block but will return an error if blocking is required to make progress.

Returns:
  the following values:
  * -1: no progress could be made w/o blocking
  * 0: successfully progressed
  * 1: execution failure
  * 2: exception (designers intent)

Implemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, Mers::Executives::DeductiveController::Command::CommandTranslator, Mers::Executives::DeductiveController::DCInterface, Mers::Executives::DeductiveController::Stub::DCStub, and Mers::Interfaces::ExecutionInterface.

Referenced by executeTask(), and Mers::Executives::DeductiveController::DCInterface::step().

set< ExecutionInterfaceBase::TaskIdentifier > ExecutionInterfaceBase::getFailedTasks | ( |  | ) | `[virtual]`

Returns the set of failed tasks if any. Typically called when step retuns with status 1 indicating that there was an execution failure

Definition at line 119 of file ExecutionInterfaceBase.cpp.

References mFailedTasks.

bool ExecutionInterfaceBase::isFailure | ( |  | ) | `[virtual]`

Returns true if there are any failed activities, otherwise false.

Definition at line 108 of file ExecutionInterfaceBase.cpp.

References mFailedTasks.

virtual bool Mers::Interfaces::ExecutionInterfaceBase::isDone | ( |  | ) | `[pure virtual]`

Returns true if all procedures have completed.

Returns:
  true if all procedures have completed.

Implemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, Mers::Executives::DeductiveController::Command::CommandTranslator, Mers::Executives::DeductiveController::DCInterface, and Mers::Interfaces::ExecutionInterface.

Referenced by executeTask(), and Mers::Executives::DeductiveController::DCInterface::isDone().

virtual bool Mers::Interfaces::ExecutionInterfaceBase::isDone | ( | TaskIdentifier | task | ) | `[pure virtual]`

Returns true if a specific task has completed.

Parameters:

  | task | The task whos status is desired

Returns:
  True if a specific procedure is done, false otherwise.

Implemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, Mers::Executives::DeductiveController::Command::CommandTranslator, Mers::Executives::DeductiveController::DCInterface, and Mers::Interfaces::ExecutionInterface.

bool ExecutionInterfaceBase::isReady | ( | TaskIdentifier | task | ) | `[virtual]`

Returns true if the task is capable of starting by default it returns true

Definition at line 129 of file ExecutionInterfaceBase.cpp.

References isValid().

Here is the call graph for this function:

String ExecutionInterfaceBase::getActiveTasksString | ( |  | ) | const`[virtual]`

Returns a string representing all of the active tasks, where each task is seperated by a return character.

Returns:
  a printable list of all active tasks, one per line.

Note that this function does nothing by default.

Reimplemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, Mers::Executives::DeductiveController::Command::CommandTranslator, and Mers::Executives::DeductiveController::DCInterface.

Definition at line 137 of file ExecutionInterfaceBase.cpp.

ExecutionInterfaceBase::TaskIdentifier ExecutionInterfaceBase::createTask | ( | const Mers::Utils::Lang::String & | taskName | ) | `[virtual]`

Creates a new Task that can be later referenced.

Parameters:

  | taskName | The name of the task that should be created.

Returns:
  a new TaskIdentifier of the created task, or an invalid identifier if the task could not be created. Use isValid() to verify the validity of this task.

Reimplemented in Mers::Executives::DeductiveController::Command::CommandTranslator, and Mers::Executives::DeductiveController::DCInterface.

Definition at line 146 of file ExecutionInterfaceBase.cpp.

References Mers::Interfaces::TaskFactory::createTask(), getTaskID(), mTaskFactory, and mTasks.

Referenced by Mers::Executives::DeductiveController::Command::CommandDispatcher::addConnection(), Mers::Executives::DeductiveController::DCInterface::createTask(), and Mers::Executives::DeductiveController::DCInterface::setExecutionInterface().

Here is the call graph for this function:

virtual TaskIdentifier Mers::Interfaces::ExecutionInterfaceBase::createTask | ( | const Mers::Utils::Lang::String & | taskName,
|  | std::vector< const Mers::Utils::Lang::String * > const & | parameters |
| ) |  |  | `[virtual]`

Creates a new Task that can be later referenced.

Parameters:

  | taskName | The name of the task that should be created.
  | parameters | The parameters of this task.

Returns:
  a new TaskIdentifier of the created task, or an invalid identifier if the task could not be created. Use isValid() to verify the validity of this task.

Reimplemented in Mers::Executives::DeductiveController::Command::CommandTranslator, and Mers::Executives::DeductiveController::DCInterface.

bool ExecutionInterfaceBase::isValid | ( | TaskIdentifier | task | ) | `[virtual]`

Returns true if this is a valid task.

Parameters:

  | task | The task identifier that is being verified.

Returns:
  True if the TaskIdentifier reflects a valid task.

Reimplemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, and Mers::Executives::DeductiveController::Command::CommandTranslator.

Definition at line 175 of file ExecutionInterfaceBase.cpp.

References getTask().

Referenced by isReady().

Here is the call graph for this function:

void ExecutionInterfaceBase::deleteTask | ( | TaskIdentifier | task | ) | `[virtual]`

Frees a task that was previously created. Note that this function just dereferences the object, so other classes that have also taken a reference to the class will still have a valid object.

Parameters:

  | task | The task that should be freed.

Reimplemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, Mers::Executives::DeductiveController::Command::CommandTranslator, and Mers::Interfaces::TimedExecutionInterface.

Definition at line 184 of file ExecutionInterfaceBase.cpp.

References mTasks.

Referenced by Mers::Executives::DeductiveController::DCInterface::setExecutionInterface(), Mers::Executives::DeductiveController::DCInterface::~DCInterface(), and Mers::Executives::DeductiveController::Command::DispatcherPair::~DispatcherPair().

TaskFactory * ExecutionInterfaceBase::getTaskFactory | ( |  | ) | `[virtual]`

Returns the current factory.

Returns:
  The factory currently being used to create tasks.

Reimplemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, Mers::Executives::DeductiveController::Command::CommandTranslator, and Mers::Interfaces::TimedExecutionInterface.

Definition at line 196 of file ExecutionInterfaceBase.cpp.

References mTaskFactory.

ExecutionInterfaceBase::t_TaskSharedPointer ExecutionInterfaceBase::getFailedTask | ( | TaskIdentifier | task | ) | const`[virtual]`

Retuns a failed Task object form an identifier, if the identifier is valid. Otherwise, retuns NULL.

Parameters:

  | task | The identifier of the failed task being sought

Returns:
  A handle to the task that corresponds to the task identifier

Definition at line 203 of file ExecutionInterfaceBase.cpp.

References mFailedTasks.

ExecutionInterfaceBase::t_TaskSharedPointer ExecutionInterfaceBase::getTask | ( | TaskIdentifier | task | ) | const`[virtual]`

Returns a Task object from an identifier, if the identifier is valid. Otherwise, returns NULL.

Parameters:

  | task | The identifier of the task being sought.

Returns:
  A handle to the task that corresponds to the task identifier.

Reimplemented in Mers::Executives::DeductiveController::Command::CommandDispatcher, Mers::Executives::DeductiveController::Command::CommandTranslator, and Mers::Executives::DeductiveController::DCInterface.

Definition at line 216 of file ExecutionInterfaceBase.cpp.

References mTasks.

Referenced by Mers::Executives::DeductiveController::DCInterface::getTask(), Mers::Interfaces::ExecutionInterface::isDone(), isValid(), Mers::Interfaces::ExecutionInterface::start(), Mers::Interfaces::ExecutionInterface::step(), and Mers::Interfaces::ExecutionInterface::stop().

virtual std::set<TaskIdentifier> Mers::Interfaces::ExecutionInterfaceBase::getRecentlyFailedTasks | ( |  | ) | `[pure virtual]`

Returns the set of tasks that were determined to have failed by the last call to step. Typically called when step retuns with status 1 indicating that there was an execution failure

Implemented in Mers::Executives::DeductiveController::Command::CommandTranslator, Mers::Executives::DeductiveController::DCInterface, and Mers::Interfaces::ExecutionInterface.

Referenced by Mers::Executives::DeductiveController::DCInterface::getRecentlyFailedTasks().

virtual std::set<TaskIdentifier> Mers::Interfaces::ExecutionInterfaceBase::getRecentlyCompletedTasks | ( |  | ) | `[pure virtual]`

Returns the set of tasks that were determined to have completed by the last call to step.

Implemented in Mers::Executives::DeductiveController::Command::CommandTranslator, Mers::Executives::DeductiveController::DCInterface, and Mers::Interfaces::ExecutionInterface.

Referenced by Mers::Executives::DeductiveController::DCInterface::getRecentlyCompletedTasks().

void ExecutionInterfaceBase::setTaskFactory | ( | TaskFactory * | tFactory | ) | `[protected, virtual]`

Sets a new Task Factory.

Parameters:

  | tFactory | The factory that will be used to create tasks.

Definition at line 229 of file ExecutionInterfaceBase.cpp.

References Mers::Utils::Lang::ReferencedObject::addReference(), mTaskFactory, and Mers::Utils::Lang::ReferencedObject::removeReference().

Referenced by ExecutionInterfaceBase(), Mers::Executives::DeductiveController::DCInterface::init(), and Mers::Interfaces::TimedExecutionInterface::setTaskFactory().

Here is the call graph for this function:

ExecutionInterfaceBase::TaskIdentifier ExecutionInterfaceBase::getTaskID | ( | t_TaskSharedPointer | pTask | ) | `[protected, virtual]`

Gets the ID for a task. The ID must be unique for each task

Definition at line 246 of file ExecutionInterfaceBase.cpp.

Referenced by createTask().

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

- /Users/fpy/titan-1-5-MBARI/Mers/Interfaces/ExecutionInterfaceBase.h
- /Users/fpy/titan-1-5-MBARI/Mers/Interfaces/ExecutionInterfaceBase.cpp