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

# /Users/fpy/titan-1-5-MBARI/Mers/Interfaces/ExecutionInterface.h

    00001
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00009 // Organization:        Model-based Embedded and Robotic Systems Group
    00010 //                                      Massachusetts Institute of Technology
    00011 //
    00013
    00014 #ifndef MERS_INTERFACES_EXECUTION_INTERFACE_HEADERFILE
    00015 #define MERS_INTERFACES_EXECUTION_INTERFACE_HEADERFILE
    00016
    00017 #include "ExecutionInterfaceBase.h"
    00018
    00019 #include <Mers/Utils/Lang/Mutex.h>
    00020 #include <Mers/Utils/Logging/logger.h>
    00021
    00022 namespace Mers {
    00023         namespace Interfaces {
    00024                 class Task;
    00025         }
    00026 }
    00027
    00028 namespace Mers {
    00029         namespace Interfaces {
    00030
    00031                 class ExecutionInterface : public ExecutionInterfaceBase, public Mers::Utils::Lang::Mutex
    00032                 {
    00033
    00034                         // This class provides a useful execution interface for common situations.
    00035                         // It is not as generic as ExecutionInterfaceBase, but provides implementations for
    00036                         // all methods, which are suitable for common use.
    00037                         //
    00038                         // Notes
    00039                         // We check that the parameter to start(...) and stop(...) is a vaild ID before it is added to the corresponding list
    00040                         // This means that further checking in step(...) is not required.
    00041                         //
    00042                         // A single execution interface may be used simultaneously by several executives, so the class must be threadsafe
    00043                         // We need mutex locking for currentTasks, completedTasks, recentlyFailedTasks, recentlyCompletedTasks, tasksToStart, tasksToStop
    00044                         // The easiest solution is to put locks around start(...), stop(), stop(...), step(...)
    00045
    00046                 public:
    00050                         ExecutionInterface( TaskFactory *pTaskFactory );
    00051
    00055                         virtual ~ExecutionInterface();
    00056
    00057                         // Pure virtual over-riders
    00058                         virtual bool start( TaskIdentifier taskID );
    00059                         virtual bool stop();
    00060                         virtual bool stop( TaskIdentifier taskID );
    00061                         virtual int step( bool block = true );
    00062                         virtual bool isDone();
    00063                         virtual bool isDone( TaskIdentifier taskID );
    00064                         virtual std::set<TaskIdentifier> getRecentlyFailedTasks();
    00065                         virtual std::set<TaskIdentifier> getRecentlyCompletedTasks();
    00066
    00067                         // New methods
    00068                         virtual Mers::Utils::Lang::String getActiveTasksString();
    00069                         Mers::Utils::Lang::String getTasksString();
    00070
    00071
    00072                 protected:
    00073
    00075                         std::set<TaskIdentifier> currentTasks;
    00076
    00078                         std::set<TaskIdentifier> completedTasks;
    00079
    00080                         // Set of tasks determined to have failed by the last call to step.
    00081                         std::set<TaskIdentifier> recentlyFailedTasks;
    00082
    00083                         // Set of tasks determined to have completed by the last call to step.
    00084                         std::set<TaskIdentifier> recentlyCompletedTasks;
    00085
    00086                         // Set of tasks to start in the next call to step.
    00087                         std::set<TaskIdentifier> tasksToStart;
    00088
    00089                         // Set of tasks to stop in the next call to step.
    00090                         std::set<TaskIdentifier> tasksToStop;
    00091
    00092                 private:
    00094                         static log4cplus::Logger mLogger;
    00095
    00096                 };
    00097
    00098         }
    00099 }
    00100
    00101 #endif  // MERS_INTERFACES_EXECUTION_INTERFACE_HEADERFILE