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

# /Users/fpy/titan-1-5-MBARI/Mers/Interfaces/ProceduralEI.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
    00015 #ifndef MERS_INTERFACES_PROCEDURAL_E_I_HEADERFILE
    00016 #define MERS_INTERFACES_PROCEDURAL_E_I_HEADERFILE
    00017
    00018 #include "ExecutionInterfaceBase.h"
    00019
    00020 namespace Mers {
    00021         namespace Interfaces {
    00022
    00027                 template <class EI>
    00028                 class ProceduralEI
    00029                 {
    00030                 public:
    00034                         ProceduralEI(EI * ei) : mEI(*ei) {
    00035                                 mEI.addReference();
    00036                         }
    00037
    00041                         virtual ~ProceduralEI() {
    00042                                 mEI.removeReference();
    00043                         }
    00044
    00050                         EI & getExecutionInterface() {
    00051                                 return mEI;
    00052                         }
    00053
    00061                         virtual int executeTask( ExecutionInterfaceBase::TaskIdentifier task ) {
    00062                                 int ret;
    00063
    00064                                 if(!mEI.start(task))
    00065                                         return 1;
    00066
    00067                                 while(!mEI.isDone(task)) {
    00068                                         ret = mEI.step(true);
    00069                                         if(ret > 0)
    00070                                                 return ret;
    00071                                 }
    00072                                 return 0;
    00073                         }
    00074
    00075                 protected:
    00077                         EI & mEI;
    00078                 };
    00079         }
    00080 }
    00081
    00082 #endif // MERS_INTERFACES_PROCEDURAL_E_I_HEADERFILE
    00083