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

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

# Mers::Executives::DeductiveController::Command::CommandTranslator Class Reference

`#include <CommandTranslator.h>`

Inheritance diagram for Mers::Executives::DeductiveController::Command::CommandTranslator:

[legend]
Collaboration diagram for Mers::Executives::DeductiveController::Command::CommandTranslator:

[legend]
List of all members.

## Public Member Functions
| CommandTranslator (Mers::Interfaces::ExecutionInterfaceBase *execInt, Mers::Utils::Containers::DynamicArrayTemplate< CommandDispatcherEntry > &entries)
| ~CommandTranslator ()
virtual bool | start (TaskIdentifier task)
virtual bool | stop ()
virtual bool | stop (TaskIdentifier task)
virtual int | step (bool block=true)
virtual bool | isDone ()
virtual bool | isDone (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 Mers::Interfaces::TaskFactory * | getTaskFactory ()
virtual t_TaskSharedPointer | getTask (TaskIdentifier task) const
virtual std::set< TaskIdentifier > | getRecentlyFailedTasks ()
virtual std::set< TaskIdentifier > | getRecentlyCompletedTasks ()
virtual void | print (std::ostream &out) const
## Protected Attributes
ExecutionInterfaceBase * | m_execInt
Mers::Utils::Containers::DynamicArrayTemplate< const CommandDispatcherEntry > | m_DispatcherEntries
## Static Protected Attributes
static log4cplus::Logger | logger
| Logging information goes to this class.

## Detailed Description

This objects takes tasks issued to any generic ExecutionInterfaceBase and translates them to a different set of tasks that a different ExecutionInterfaceBase can understand.

Definition at line 36 of file CommandTranslator.h.

## Constructor & Destructor Documentation

Mers::Executives::DeductiveController::Command::CommandTranslator::CommandTranslator | ( | Mers::Interfaces::ExecutionInterfaceBase * | execInt,
|  | Mers::Utils::Containers::DynamicArrayTemplate< CommandDispatcherEntry > & | entries |
| ) |  |  |

Creates a new command dispatcher.

Parameters:

  | execInt | The execution interface to which all translated commands will be issued.
  | entries | The list of entries used to translate tasks. This class assumes ownership of these objects.

CommandTranslator::~CommandTranslator | ( |  | ) |

Destroys this object.

Definition at line 50 of file CommandTranslator.cpp.

## Member Function Documentation

virtual bool Mers::Executives::DeductiveController::Command::CommandTranslator::start | ( | TaskIdentifier | task | ) | `[virtual]`

Starts an additional task. 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 started, 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.

Implements Mers::Interfaces::ExecutionInterfaceBase.

bool CommandTranslator::stop | ( |  | ) | `[virtual]`

Stops all current activities. Every command that was started will be stopped, if possible.

Implements Mers::Interfaces::ExecutionInterfaceBase.

Definition at line 63 of file CommandTranslator.cpp.

References m_execInt.

virtual bool Mers::Executives::DeductiveController::Command::CommandTranslator::stop | ( | TaskIdentifier | task | ) | `[virtual]`

Stops the task, if currently active. 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 if it could not be stopped.

Implements Mers::Interfaces::ExecutionInterfaceBase.

int CommandTranslator::step | ( | bool | block = `true` | ) | `[virtual]`

Takes a single processing step. 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 seperate 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)

Implements Mers::Interfaces::ExecutionInterfaceBase.

Definition at line 77 of file CommandTranslator.cpp.

References m_execInt.

bool CommandTranslator::isDone | ( |  | ) | `[virtual]`

Returns true if all procedures have completed.

Returns:
  true if all procedures have completed.

Implements Mers::Interfaces::ExecutionInterfaceBase.

Definition at line 86 of file CommandTranslator.cpp.

References m_execInt.

virtual bool Mers::Executives::DeductiveController::Command::CommandTranslator::isDone | ( | TaskIdentifier | task | ) | `[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.

Implements Mers::Interfaces::ExecutionInterfaceBase.

String CommandTranslator::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 from Mers::Interfaces::ExecutionInterfaceBase.

Definition at line 100 of file CommandTranslator.cpp.

References m_execInt.

CommandTranslator::TaskIdentifier CommandTranslator::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 from Mers::Interfaces::ExecutionInterfaceBase.

Definition at line 110 of file CommandTranslator.cpp.

virtual TaskIdentifier Mers::Executives::DeductiveController::Command::CommandTranslator::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 from Mers::Interfaces::ExecutionInterfaceBase.

virtual bool Mers::Executives::DeductiveController::Command::CommandTranslator::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 from Mers::Interfaces::ExecutionInterfaceBase.

virtual void Mers::Executives::DeductiveController::Command::CommandTranslator::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 from Mers::Interfaces::ExecutionInterfaceBase.

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

Returns the current factory.

Returns:
  The factory currently being used to create tasks.

Reimplemented from Mers::Interfaces::ExecutionInterfaceBase.

Definition at line 173 of file CommandTranslator.cpp.

References m_execInt.

virtual t_TaskSharedPointer Mers::Executives::DeductiveController::Command::CommandTranslator::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 from Mers::Interfaces::ExecutionInterfaceBase.

virtual std::set<TaskIdentifier> Mers::Executives::DeductiveController::Command::CommandTranslator::getRecentlyFailedTasks | ( |  | ) | `[inline, 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

Implements Mers::Interfaces::ExecutionInterfaceBase.

Definition at line 203 of file CommandTranslator.h.

virtual std::set<TaskIdentifier> Mers::Executives::DeductiveController::Command::CommandTranslator::getRecentlyCompletedTasks | ( |  | ) | `[inline, virtual]`

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

Implements Mers::Interfaces::ExecutionInterfaceBase.

Definition at line 204 of file CommandTranslator.h.

void CommandTranslator::print | ( | std::ostream & | out | ) | const`[virtual]`

Called to print this object to the specified ostream. Derived classes must define this.

Parameters:

  | out | the ostream to print this object information to.

Definition at line 201 of file CommandTranslator.cpp.

References m_DispatcherEntries.

## Member Data Documentation

ExecutionInterfaceBase* Mers::Executives::DeductiveController::Command::CommandTranslator::m_execInt`[protected]`

The execution interface to which we send all of our translated requests.

Definition at line 219 of file CommandTranslator.h.

Referenced by getActiveTasksString(), getTaskFactory(), isDone(), step(), and stop().

Mers::Utils::Containers::DynamicArrayTemplate< const CommandDispatcherEntry > Mers::Executives::DeductiveController::Command::CommandTranslator::m_DispatcherEntries`[protected]`

An array of dispatcher entries. Each entry contains a rule for translating a particular task from the calling object to the target execution interface.

Definition at line 225 of file CommandTranslator.h.

Referenced by print().

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

- /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Command/CommandTranslator.h
- /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Command/CommandTranslator.cpp