TaskCore.hpp

00001 /***************************************************************************
00002   tag: FMTC  do nov 2 13:06:07 CET 2006  TaskCore.hpp
00003 
00004                         TaskCore.hpp -  description
00005                            -------------------
00006     begin                : do november 02 2006
00007     copyright            : (C) 2006 FMTC
00008     email                : peter.soetens@fmtc.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 
00039 #ifndef ORO_TASK_CORE_HPP
00040 #define ORO_TASK_CORE_HPP
00041 
00042 #include "OperationInterface.hpp"
00043 #include <string>
00044 
00045 namespace RTT
00046 {
00047     class ExecutionEngine;
00048 
00056     class RTT_API TaskCore
00057     {
00058     public:
00131         enum TaskState { Init,           
00132                          PreOperational, 
00133                          FatalError,     
00134                          Stopped,        
00135                          Active,         
00136                          Running,        
00137                          RunTimeWarning, 
00138                          RunTimeError    
00139         };
00140 
00149         TaskCore( const std::string& name, TaskState initial_state = Stopped  );
00150 
00160         TaskCore(const std::string& name, ExecutionEngine* parent, TaskState initial_state = Stopped );
00161 
00162         virtual ~TaskCore();
00163 
00167         virtual TaskState getTaskState() const;
00168 
00173         virtual int getWarningCount() const;
00174 
00179         virtual int getErrorCount() const;
00180 
00194         virtual bool configure();
00195 
00208         virtual bool activate();
00209 
00221         virtual bool start();
00222 
00229         virtual bool stop();
00230 
00237         virtual bool cleanup();
00238 
00249         virtual bool resetError();
00250 
00255         virtual bool isConfigured() const;
00256 
00261         virtual bool isActive() const;
00262 
00270         virtual bool isRunning() const;
00271 
00282         virtual double getPeriod() const;
00283 
00287         virtual bool inFatalError() const;
00288 
00292         virtual bool inRunTimeWarning() const;
00293 
00297         virtual bool inRunTimeError() const;
00298 
00306         virtual bool doUpdate();
00307 
00315         virtual bool doTrigger();
00323         virtual const std::string& getName() const
00324         {
00325             return mtask_name;
00326         }
00327 
00331         virtual void setName(const std::string& n)
00332         {
00333             mtask_name = n;
00334         }
00335 
00345         void setExecutionEngine(ExecutionEngine* engine);
00346 
00350         const ExecutionEngine* engine() const
00351         {
00352             return ee;
00353         }
00354 
00358         ExecutionEngine* engine()
00359         {
00360             return ee;
00361         }
00362 
00363     protected:
00374         virtual bool configureHook();
00375 
00381         virtual void cleanupHook();
00382 
00388         virtual bool activateHook();
00389 
00399         virtual bool startHook();
00400 
00409         virtual bool startup();
00410 
00422         virtual void updateHook();
00423 
00432         virtual bool breakUpdateHook();
00433 
00441         virtual void errorHook();
00442 
00455         virtual void update();
00456 
00462         virtual void stopHook();
00463 
00471         virtual void shutdown();
00472 
00479         virtual bool resetHook();
00480 
00486         virtual void warning();
00487 
00494         virtual void error();
00495 
00502         virtual void fatal();
00503 
00510         virtual void recovered();
00511 
00512         // Required to set mTaskState to Running or Stopped.
00513         // As an alternative, one could query the EE.
00514         friend class ExecutionEngine;
00515 
00516         std::string    mtask_name;
00517 
00522         ExecutionEngine* ee;
00523 
00524         TaskState mTaskState;
00525 
00526         int runtime_warnings;
00527         int runtime_errors;
00528     private:
00529         // non copyable
00530         TaskCore( TaskCore& );
00531     };
00532 }
00533 
00534 #endif
Generated on Thu Dec 23 13:22:38 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3