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
00140 void removePort(const std::string& name);
00141
00146 Ports getPorts() const;
00147
00153 PortNames getPortNames() const;
00154
00160 base::PortInterface* getPort(const std::string& name) const;
00161
00169 std::string getPortDescription(const std::string& name) const;
00170
00181 bool setPortDescription(const std::string& name, const std::string description);
00182
00186 TaskContext* getOwner() const;
00187
00193 Service* getService() const { return mservice; }
00194
00201 base::PortInterface& addLocalPort(base::PortInterface& port);
00202
00215 base::InputPortInterface& addLocalEventPort(base::InputPortInterface& port,
00216 SlotFunction callback = SlotFunction() );
00217
00221 template< class Type>
00222 Type* getPortType(const std::string& name) {
00223 return dynamic_cast<Type*>( this->getPort(name) );
00224 }
00225
00230 void clear();
00231
00232 #ifdef ORO_SIGNALLING_PORTS
00233
00236 void setupHandles();
00240 void cleanupHandles();
00241 #else
00242
00245 void dataOnPort(base::PortInterface* port);
00246 #endif
00247 protected:
00252 Service* createPortObject(const std::string& name);
00253
00254 bool chkPtr(const std::string &where, const std::string& name, const void* ptr);
00258 Ports mports;
00262 Service* mservice;
00263 #ifdef ORO_SIGNALLING_PORTS
00264
00268 typedef std::vector< Handle > Handles;
00269 Handles handles;
00270 #endif
00271
00272 };
00273
00274 }
00275
00276 #endif