DataFlowInterface.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Peter Soetens  Thu Mar 2 08:30:18 CET 2006  DataFlowInterface.hpp
00003 
00004                         DataFlowInterface.hpp -  description
00005                            -------------------
00006     begin                : Thu March 02 2006
00007     copyright            : (C) 2006 Peter Soetens
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_EXECUTION_DATA_FLOW_INTERFACE_HPP
00040 #define ORO_EXECUTION_DATA_FLOW_INTERFACE_HPP
00041 
00042 #include <vector>
00043 #include <map>
00044 #include <string>
00045 #include "base/InputPortInterface.hpp"
00046 #include "base/OutputPortInterface.hpp"
00047 #include "rtt-fwd.hpp"
00048 #include <boost/function.hpp>
00049 
00050 namespace RTT
00051 {
00052 
00059     class RTT_API DataFlowInterface
00060     {
00061     public:
00065         typedef std::vector<base::PortInterface*> Ports;
00066 
00070         typedef std::vector<std::string> PortNames;
00071 
00072         typedef boost::function<void(base::PortInterface*)> SlotFunction;
00073 
00079         DataFlowInterface(Service* parent = 0 );
00080 
00081         ~DataFlowInterface();
00082 
00089         base::PortInterface& addPort(const std::string& name, base::PortInterface& port) {
00090             if ( !chkPtr("addPort", name, &port) ) return port;
00091             port.setName(name);
00092             return addPort(port);
00093         }
00094 
00103         base::PortInterface& addPort(base::PortInterface& port);
00104 
00114         base::InputPortInterface& addEventPort(const std::string& name, base::InputPortInterface& port, SlotFunction callback = SlotFunction() ) {
00115             if ( !chkPtr("addEventPort", name, &port) ) return port;
00116             port.setName(name);
00117             return addEventPort(port,callback);
00118         }
00119 
00132         base::InputPortInterface& addEventPort(base::InputPortInterface& port, SlotFunction callback = SlotFunction() );
00133 
00145         void removePort(const std::string& name);
00146 
00151         Ports getPorts() const;
00152 
00158         PortNames getPortNames() const;
00159 
00165         base::PortInterface* getPort(const std::string& name) const;
00166 
00174         std::string getPortDescription(const std::string& name) const;
00175 
00186         bool setPortDescription(const std::string& name, const std::string description);
00187 
00191         TaskContext* getOwner() const;
00192 
00198         Service* getService() const { return mservice; }
00199 
00206         base::PortInterface& addLocalPort(base::PortInterface& port);
00207 
00220         base::InputPortInterface& addLocalEventPort(base::InputPortInterface& port,
00221                 SlotFunction callback = SlotFunction() );
00222 
00232         void removeLocalPort(const std::string& name);
00233 
00234 
00238         template< class Type>
00239         Type* getPortType(const std::string& name) {
00240             return dynamic_cast<Type*>( this->getPort(name) );
00241         }
00242 
00247         void clear();
00248 
00249 #ifdef ORO_SIGNALLING_PORTS
00250 
00253         void setupHandles();
00257         void cleanupHandles();
00258 #else
00259 
00262         void dataOnPort(base::PortInterface* port);
00263 #endif
00264     protected:
00269         Service* createPortObject(const std::string& name);
00270 
00271         bool chkPtr(const std::string &where, const std::string& name, const void* ptr);
00275         Ports mports;
00279         Service* mservice;
00280 #ifdef ORO_SIGNALLING_PORTS
00281 
00285         typedef std::vector< Handle > Handles;
00286         Handles handles;
00287 #endif
00288 
00289     };
00290 
00291 }
00292 
00293 #endif


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