3 #include <rtt/FlowStatus.hpp> 4 #include <rtt/InputPort.hpp> 5 #include <rtt/OutputPort.hpp> 7 #include <rtt/TaskContext.hpp> 8 #include <rtt/extras/ReadOnlyPointer.hpp> 10 #define FW_DECLARE_TYPE(type) \ 11 extern template class RTT::InputPort<type>; \ 12 extern template class RTT::OutputPort<type>; \ 13 extern template class OutputProxyPort<type>; \ 14 extern template class InputProxyPort<type>; \ 15 extern template class RTT::base::ChannelElement<type>; 17 #define INSTANCIATE_TYPE(type) \ 18 template class OutputProxyPort<type>; \ 19 template class InputProxyPort<type>; 30 std::string
getFreePortName(RTT::TaskContext *clientTask, RTT::base::PortInterface *portIf);
38 RTT::base::InputPortInterface *port;
39 RTT::OutputPort<T> *writer;
41 InputProxyPort(RTT::base::PortInterface *iface): port(dynamic_cast<RTT::base::InputPortInterface *>(iface)), writer(NULL)
44 throw std::runtime_error(
"Flow interface of wrong type given");
47 InputProxyPort(RTT::TaskContext *task,
const std::string &portName): port(NULL), writer(NULL)
49 RTT::base::PortInterface *iface = task->getPort(portName);
51 throw std::runtime_error(
"InputProxyPort: Error, task " + task->getName() +
" has no port with the name " + portName);
53 port =
dynamic_cast<RTT::base::InputPortInterface *
>(iface);
55 throw std::runtime_error(
"InputProxyPort: Error, port '" + portName +
"' of task '" + task->getName() +
"' hast an unexpected type");
65 return getWriter(port->getDefaultPolicy());
68 RTT::OutputPort<T> &
getWriter(RTT::ConnPolicy
const& policy)
72 writer =
dynamic_cast<RTT::OutputPort<T> *
>(port->antiClone());
74 throw std::runtime_error(
"Error, could not get writer for port " + port->getName());
78 clientTask->addPort(*writer);
79 if(!port->connectTo(writer, policy))
80 throw std::runtime_error(
"InputProxyPort::getWriter(): Error could not connect writer to port " + port->getName() +
" of task " + port->getInterface()->getOwner()->getName());
92 clientTask->ports()->removePort(writer->getName());
121 RTT::base::OutputPortInterface *port;
122 RTT::InputPort<T> *reader;
124 OutputProxyPort(RTT::base::PortInterface *iface): port(dynamic_cast<RTT::base::OutputPortInterface *>(iface)), reader(NULL)
127 throw std::runtime_error(
"Flow interface of wrong type given");
130 OutputProxyPort(RTT::TaskContext *task,
const std::string &portName): port(NULL), reader(NULL)
132 RTT::base::PortInterface *iface = task->getPort(portName);
134 throw std::runtime_error(
"OutputProxyPort: Error, task " + task->getName() +
" has no port with the name " + portName);
136 port =
dynamic_cast<RTT::base::OutputPortInterface *
>(iface);
138 throw std::runtime_error(
"OutputProxyPort: Error, port '" + portName +
"' of task '" + task->getName() +
"' hast an unexpected type");
148 return getReader(RTT::ConnPolicy());
151 RTT::InputPort<T> &
getReader(RTT::ConnPolicy
const& policy)
155 reader =
dynamic_cast<RTT::InputPort<T> *
>(port->antiClone());
157 throw std::runtime_error(
"Error, could not get reader for port " + port->getName());
160 clientTask->addPort(*reader);
161 if(!reader->connectTo(port, policy))
162 throw std::runtime_error(
"InputProxyPort::getReader(): Error could not connect reader to port " + port->getName() +
" of task " + port->getInterface()->getOwner()->getName());
171 reader->disconnect();
174 clientTask->ports()->removePort(reader->getName());
186 return port->connectTo(inputPort.getPortInterface(), policy);
195 template<
typename T2>
204 return port->connectTo(inputPort.getPortInterface());
bool disconnect(InputProxyPort< T > &inputPort)
Definition: ProxyPort.hpp:213
~OutputProxyPort()
Definition: ProxyPort.hpp:219
OutputProxyPort(RTT::TaskContext *task, const std::string &portName)
Definition: ProxyPort.hpp:130
bool connectTo(InputProxyPort< T2 > &inputPort)
Definition: ProxyPort.hpp:196
bool disconnect()
Definition: ProxyPort.hpp:207
bool connectTo(InputProxyPort< RTT::extras::ReadOnlyPointer< T > > &inputPort, RTT::ConnPolicy const &policy)
Definition: ProxyPort.hpp:184
static RTT::TaskContext * getClientTask()
Definition: OrocosHelpers.cpp:34
void deleteReader()
Definition: ProxyPort.hpp:167
Definition: ProxyPort.hpp:22
RTT::InputPort< T > & getReader()
Definition: ProxyPort.hpp:146
bool connectTo(InputProxyPort< RTT::extras::ReadOnlyPointer< T > > &inputPort)
Definition: ProxyPort.hpp:202
RTT::InputPort< T > & getReader(RTT::ConnPolicy const &policy)
Definition: ProxyPort.hpp:151
bool connectTo(InputProxyPort< T > &inputPort, RTT::ConnPolicy const &policy)
Definition: ProxyPort.hpp:179
Definition: OrocosHelpers.hpp:6
bool connectTo(InputProxyPort< T > &inputPort)
Definition: ProxyPort.hpp:189
Definition: ProxyPort.hpp:27
RTT::base::OutputPortInterface * getPortInterface()
Definition: ProxyPort.hpp:141
std::string getFreePortName(RTT::TaskContext *clientTask, RTT::base::PortInterface *portIf)
Definition: ProxyPort.cpp:4