Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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