ExecutionEngine.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Peter Soetens  Wed Jan 18 14:11:40 CET 2006  ExecutionEngine.hpp
00003 
00004                         ExecutionEngine.hpp -  description
00005                            -------------------
00006     begin                : Wed January 18 2006
00007     copyright            : (C) 2006 Peter Soetens
00008     email                : peter.soetens@mech.kuleuven.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_EXECUTION_ENGINE_HPP
00040 #define ORO_EXECUTION_ENGINE_HPP
00041 
00042 #include "os/Mutex.hpp"
00043 #include "os/MutexLock.hpp"
00044 #include "os/Condition.hpp"
00045 #include "base/RunnableInterface.hpp"
00046 #include "base/ActivityInterface.hpp"
00047 #include "base/DisposableInterface.hpp"
00048 #include "base/ExecutableInterface.hpp"
00049 #include "internal/List.hpp"
00050 #include <vector>
00051 #include <boost/function.hpp>
00052 
00053 #include "rtt-config.h"
00054 #include "internal/rtt-internal-fwd.hpp"
00055 
00056 namespace RTT
00057 {
00058 
00077     class RTT_API ExecutionEngine
00078         : public base::RunnableInterface
00079     {
00080     public:
00087         ExecutionEngine( base::TaskCore* owner = 0);
00088 
00089         ~ExecutionEngine();
00090 
00094         base::TaskCore* getParent();
00095 
00099         virtual void addChild(base::TaskCore* tc);
00100 
00104         virtual void removeChild(base::TaskCore* tc);
00105 
00109         base::TaskCore* getTaskCore() const { return taskc; }
00110 
00122         virtual bool process(base::DisposableInterface* c);
00123 
00132         virtual bool runFunction(base::ExecutableInterface* f);
00133 
00139         virtual bool removeFunction(base::ExecutableInterface* f);
00140 
00146         virtual bool removeSelfFunction(base::ExecutableInterface* f);
00147 
00157         void waitForMessages(const boost::function<bool(void)>& pred);
00158 
00168         void waitForFunctions(const boost::function<bool(void)>& pred);
00169 
00178         bool stopTask(base::TaskCore* task);
00179 
00180 
00184         void setExceptionTask();
00185 
00192         void setMaster(ExecutionEngine *master);
00193 
00200         virtual void setActivity( base::ActivityInterface* task );
00201 
00202     protected:
00216         void waitForMessagesInternal( boost::function<bool(void)> const& pred);
00217 
00230         void waitAndProcessMessages(boost::function<bool(void)> const& pred);
00231 
00244         void waitAndProcessFunctions(boost::function<bool(void)> const& pred);
00245 
00249         base::TaskCore*     taskc;
00250 
00254         internal::MWSRQueue<base::DisposableInterface*>* mqueue;
00255 
00256         std::vector<base::TaskCore*> children;
00257 
00261         internal::MWSRQueue<base::ExecutableInterface*>* f_queue;
00262 
00263         os::Mutex msg_lock;
00264         os::Condition msg_cond;
00265 
00270         ExecutionEngine *mmaster;
00271 
00272         void processMessages();
00273         void processFunctions();
00274         void processChildren();
00275 
00276         virtual bool initialize();
00277 
00282         virtual void step();
00283 
00284         virtual bool breakLoop();
00285 
00286         virtual void finalize();
00287 
00288         virtual bool hasWork();
00289 
00290     };
00291 
00292 }
00293 #endif


rtt
Author(s): RTT Developers
autogenerated on Sat Jun 8 2019 18:46:09