TaskCore.hpp
Go to the documentation of this file.
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 <string>
00043 #include "../rtt-fwd.hpp"
00044 #include "../rtt-config.h"
00045 #include "../Time.hpp"
00046 
00047 namespace RTT
00048 { namespace base {
00049 
00054     class RTT_API TaskCore
00055     {
00056     public:
00099         enum TaskState {
00100                          Init            
00101                          ,PreOperational 
00102                          ,FatalError     
00103                          ,Exception      
00104                          ,Stopped        
00105                          ,Running        
00106                          ,RunTimeError   
00107         };
00108 
00116         TaskCore( TaskState initial_state = Stopped  );
00117 
00126         TaskCore( ExecutionEngine* parent, TaskState initial_state = Stopped );
00127 
00128         virtual ~TaskCore();
00129 
00138         virtual TaskState getTaskState() const;
00139 
00153         virtual TaskState getTargetState() const;
00154 
00168         virtual bool configure();
00169 
00177         virtual bool activate();
00178 
00188         virtual bool start();
00189 
00196         virtual bool stop();
00197 
00203         virtual bool cleanup();
00204 
00209         virtual bool isConfigured() const;
00210 
00216         virtual bool isActive() const;
00217 
00224         virtual bool isRunning() const;
00225 
00236         virtual Seconds getPeriod() const;
00237 
00244         virtual bool setPeriod(Seconds s);
00245 
00250         virtual unsigned getCpuAffinity() const;
00251 
00257         virtual bool setCpuAffinity(unsigned cpu);
00258 
00264         virtual bool inFatalError() const;
00265 
00269         virtual bool inException() const;
00270 
00274         virtual bool inRunTimeError() const;
00275 
00282         virtual bool update();
00283 
00290         virtual bool trigger();
00291 
00298         virtual void error();
00299 
00307         virtual bool recover();
00308 
00322         void setExecutionEngine(ExecutionEngine* engine);
00323 
00327         const ExecutionEngine* engine() const
00328         {
00329             return ee;
00330         }
00331 
00335         ExecutionEngine* engine()
00336         {
00337             return ee;
00338         }
00339 
00340     protected:
00351         virtual bool configureHook();
00352 
00358         virtual void cleanupHook();
00359 
00369         virtual bool startHook();
00370 
00382         virtual void updateHook();
00383 
00392         virtual bool breakUpdateHook();
00393 
00401         virtual void errorHook();
00402 
00410         virtual void exceptionHook();
00411 
00412 
00418         virtual void stopHook();
00419 
00426         virtual void fatal();
00427 
00436         virtual void exception();
00437 
00438         // Required to set mTaskState to Running, Stopped or Exception.
00439         // As an alternative, one could query the EE.
00440         friend class ::RTT::ExecutionEngine;
00441 
00446         ExecutionEngine* ee;
00447 
00448         TaskState mTaskState;
00449 
00450     private:
00455         TaskState const mInitialState;
00460         TaskState mTargetState;
00461         // non copyable
00462         TaskCore( TaskCore& );
00463 
00464         friend class TaskContext;
00471         virtual void prepareUpdateHook();
00472     };
00473 }}
00474 
00475 #endif


rtt
Author(s): RTT Developers
autogenerated on Mon Oct 6 2014 03:13:54