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

# /Users/fpy/titan-1-5-MBARI/Mers/Interfaces/ExecutionInterfaceBase.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_BASE_HEADERFILE
    00015 #define MERS_INTERFACES_EXECUTION_INTERFACE_BASE_HEADERFILE
    00016
    00017 #include <Mers/Utils/Lang/String.h>
    00018 #include <Mers/Utils/Containers/SharedPointer.h>
    00019 #include <vector>
    00020 #include <set>
    00021
    00022 namespace log4cplus {
    00023         class Logger;
    00024 }
    00025
    00026 namespace Mers {
    00027   namespace Interfaces {
    00028
    00029     class Task;
    00030     class TaskFactory;
    00031
    00051     class ExecutionInterfaceBase
    00052     {
    00053                 public:
    00055                         typedef ::Mers::Utils::Containers::SharedPointer< Task >
    00056                                 t_TaskSharedPointer;
    00057
    00058       public:
    00063       typedef ::Mers::Utils::Containers::SharedPointer< Task > TaskIdentifier;
    00064
    00068       ExecutionInterfaceBase( TaskFactory *pTaskFactory );
    00069
    00073       virtual ~ExecutionInterfaceBase();
    00074
    00075       /***
    00076        * Runs the specified task until it completes or fails.  This is
    00077        * only a test procedure - it can be used for testing purposes
    00078        * but probably isn't what's desired since it can take an
    00079        * indeterminant amount of time to complete.  If one cares about
    00080        * the amount of time the procedure will take, wishes to run
    00081        * multiple procedures simultaneously or one desires to do other
    00082        * activities in between each execution step, then this loop
    00083        * should be added to said object and, in the case of the last
    00084        * option, the step routine should be called with block = false.
    00085        *
    00086        * @param task The identifier of the task that should be
    00087        * executed.
    00088        *
    00089        * @return the following values: \n
    00090        *       * -1: no progress could be made w/o blocking \n
    00091        *       *  0: successfully progressed \n
    00092        *       *  1: execution failure \n
    00093        *       *  2: exception (designers intent)
    00094        */
    00095       virtual int executeTask( TaskIdentifier task );
    00096
    00097
    00116       virtual bool start( TaskIdentifier task ) = 0;
    00117
    00123       virtual bool stop() = 0;
    00124
    00136       virtual bool stop( TaskIdentifier task ) = 0;
    00137
    00159       virtual int step( bool block = true ) = 0;
    00160
    00161
    00167                 virtual std::set<TaskIdentifier> getFailedTasks();
    00168
    00169
    00174                 virtual bool isFailure();
    00175
    00181       virtual bool isDone() = 0;
    00182
    00190       virtual bool isDone( TaskIdentifier task ) = 0;
    00191
    00192
    00195       virtual bool isReady( TaskIdentifier task);
    00196
    00197
    00206       virtual Mers::Utils::Lang::String getActiveTasksString() const;
    00207
    00217       virtual TaskIdentifier createTask( const Mers::Utils::Lang::String &taskName );
    00218
    00230       virtual TaskIdentifier createTask( const Mers::Utils::Lang::String &taskName,
    00231                                          std::vector<const Mers::Utils::Lang::String *> const &parameters );
    00232
    00240       virtual bool isValid( TaskIdentifier task );
    00241
    00250       virtual void deleteTask( TaskIdentifier task );
    00251
    00257       virtual TaskFactory * getTaskFactory();
    00258
    00259
    00266       virtual t_TaskSharedPointer getFailedTask( TaskIdentifier task ) const;
    00267
    00268
    00278       virtual t_TaskSharedPointer getTask( TaskIdentifier task ) const;
    00279
    00285                         virtual std::set<TaskIdentifier> getRecentlyFailedTasks() = 0;
    00286
    00290                         virtual std::set<TaskIdentifier> getRecentlyCompletedTasks() = 0;
    00291
    00292                         Mers::Utils::Lang::String PrintTasks( void );
    00293
    00294                 protected:
    00300       virtual void setTaskFactory( TaskFactory * tFactory );
    00301
    00306                         virtual TaskIdentifier getTaskID( t_TaskSharedPointer pTask );
    00307
    00308     protected:
    00310       std::set<TaskIdentifier> mTasks;
    00311
    00313       std::set<TaskIdentifier> mFailedTasks;
    00314
    00316       TaskFactory * mTaskFactory;
    00317
    00318                 private:
    00320                         static log4cplus::Logger m_Logger;
    00321     };
    00322   };
    00323 };
    00324
    00325 #endif  // MERS_INTERFACES_EXECUTION_INTERFACE_BASE_HEADERFILE