Orocos Real-Time Toolkit
2.9.0
|
A component's data output port. More...
#include <rtt/OutputPort.hpp>
Public Member Functions | |
OutputPort (std::string const &name="unnamed", bool keep_last_written_value=true) | |
Creates a named Output port. More... | |
virtual | ~OutputPort () |
void | keepNextWrittenValue (bool keep) |
void | keepLastWrittenValue (bool keep) |
Change the setting for keeping the last written value. More... | |
bool | keepsLastWrittenValue () const |
Returns true if this port records the last written value. More... | |
T | getLastWrittenValue () const |
Returns the last written value written to this port, in case it is kept by this port, otherwise, returns a default T(). More... | |
bool | getLastWrittenValue (T &sample) const |
Reads the last written value written to this port, in case it is kept by this port, otherwise, returns false. More... | |
virtual base::DataSourceBase::shared_ptr | getDataSource () const |
Returns a Data source that stores the last written value, or a null pointer if this port does not keep its last written value. More... | |
void | setDataSample (const T &sample) |
Provides this port a data sample that is representative for the samples being used in write(). More... | |
void | clear () |
Clears the last written value and all data stored in shared connection buffers. More... | |
WriteStatus | write (const T &sample) |
Writes a new sample to all receivers (if any). More... | |
WriteStatus | write (base::DataSourceBase::shared_ptr source) |
Write this port using the value stored in source. More... | |
virtual const types::TypeInfo * | getTypeInfo () const |
Returns the types::TypeInfo object for the port's type. More... | |
virtual base::PortInterface * | clone () const |
Create a clone of this port with the same name. More... | |
virtual base::PortInterface * | antiClone () const |
Create the anti-clone (inverse port) of this port with the same name A port for reading will return a new port for writing and vice versa. More... | |
virtual bool | createConnection (base::InputPortInterface &input_port, ConnPolicy const &policy) |
Connects this write port to the given read port, using the given policy. More... | |
virtual bool | createStream (ConnPolicy const &policy) |
Creates a data stream from or to this port using connection-less transports. More... | |
virtual Service * | createPortObject () |
Create accessor Object for this Port, for addition to a TaskContext Object interface. More... | |
virtual internal::ConnInputEndpoint< T > * | getEndpoint () const |
Returns the input or output endpoint of this port (if any). More... | |
virtual base::ChannelElement< T >::shared_ptr | getSharedBuffer () const |
virtual bool | addConnection (internal::ConnID *port_id, ChannelElementBase::shared_ptr channel_input, ConnPolicy const &policy) |
Adds a new connection to this output port and initializes the connection if required by policy. More... | |
virtual void | disconnect () |
Removes any connection that either go to or come from this port. More... | |
virtual bool | disconnect (PortInterface *port) |
Removes the channel that connects this port to port . More... | |
virtual bool | connected () const |
Returns true if there is at least one channel registered in this port's list of outputs. More... | |
bool | createDataConnection (InputPortInterface &sink, int lock_policy=ConnPolicy::LOCK_FREE) |
Connects this write port to the given read port, using a single-data policy with the given locking mechanism. More... | |
bool | createBufferConnection (InputPortInterface &sink, int size, int lock_policy=ConnPolicy::LOCK_FREE) |
Connects this write port to the given read port, using a buffered policy, with the buffer of the given size and the given locking mechanism. More... | |
bool | createConnection (InputPortInterface &sink) |
Connects this write port to the given read port, using as policy the default policy of the sink port. More... | |
virtual bool | createConnection (internal::SharedConnectionBase::shared_ptr shared_connection, ConnPolicy const &policy=ConnPolicy()) |
Connects the port to an existing shared connection instance. More... | |
virtual bool | connectTo (PortInterface *other, ConnPolicy const &policy) |
Connects this port with other, using the given policy. More... | |
virtual bool | connectTo (PortInterface *other) |
Connects this port with other, using the default policy of the input. More... | |
virtual internal::ConnID * | getPortID () const |
Returns the identity of this port in a ConnID object. More... | |
const std::string & | getName () const |
Get the name of this Port. More... | |
bool | setName (const std::string &name) |
Change the name of this unconnected Port. More... | |
const std::string & | getDescription () const |
Get the documentation of this port. More... | |
PortInterface & | doc (const std::string &desc) |
Set the documentation of this port. More... | |
virtual bool | connectedTo (PortInterface *port) |
Returns true if this port is connected to the given port. More... | |
virtual bool | isLocal () const |
Returns true if this port is located on this process, and false otherwise. More... | |
virtual int | serverProtocol () const |
Returns the protocol over which this port can be accessed. More... | |
virtual bool | removeConnection (internal::ConnID *cid) |
Removes a user created connection from this port. More... | |
void | setInterface (DataFlowInterface *iface) |
Once a port is added to a DataFlowInterface, it gets a pointer to that interface. More... | |
DataFlowInterface * | getInterface () const |
Returns the DataFlowInterface this port belongs to or null if it was not added to such an interface. More... | |
virtual internal::ConnectionManager * | getManager () |
Returns the connection manager of this port (if any). More... | |
virtual internal::SharedConnectionBase::shared_ptr | getSharedConnection () const |
Returns a pointer to the shared connection element this port may be connected to. More... | |
Protected Attributes | |
DataFlowInterface * | iface |
internal::ConnectionManager | cmanager |
Friends | |
class | internal::ConnInputEndpoint< T > |
A component's data output port.
An Orocos OutputPort is a send-and-forget mechanism. The publisher writes data samples into the OutputPort and the underlying middleware will communicate it to all subscribers. An output port without subscribers is not an error on the component level (it may be at the system level, which can inspect the status with calling connected() ).
The data written into an OutputPort should be copyable and should provide a copy constructor in case it's not plain old data. If you want the RTT to transport your data over the network, or use it in scripting, you need to register your data class with the RTT type system.
Definition at line 70 of file OutputPort.hpp.
|
inline |
Creates a named Output port.
name | The name of this port, unique among the ports of a TaskContext. |
keep_last_written_value | Defaults to true. You need keep_last_written_value == true in two cases:
|
Definition at line 141 of file OutputPort.hpp.
References RTT::OutputPort< T >::keepLastWrittenValue().
|
inlinevirtual |
Definition at line 154 of file OutputPort.hpp.
References RTT::base::OutputPortInterface::disconnect().
|
virtualinherited |
Adds a new connection to this output port and initializes the connection if required by policy.
Use with care. Allows you to add any arbitrary connection to this output port. It is your responsibility to do any further bookkeeping, such as informing the input that a new output has been added.
Implements RTT::base::PortInterface.
Reimplemented in RTT::corba::RemotePort< base::OutputPortInterface >.
Definition at line 73 of file OutputPortInterface.cpp.
References RTT::internal::ConnectionManager::addConnection(), RTT::base::PortInterface::cmanager, and RTT::base::OutputPortInterface::connectionAdded().
Referenced by RTT::internal::ConnFactory::createAndCheckConnection(), RTT::internal::ConnFactory::createAndCheckSharedConnection(), RTT::internal::ConnFactory::createAndCheckStream(), and RTT::corba::CDataFlowInterface_i::deregisterChannel().
|
inlinevirtual |
Create the anti-clone (inverse port) of this port with the same name A port for reading will return a new port for writing and vice versa.
Implements RTT::base::PortInterface.
Definition at line 297 of file OutputPort.hpp.
References RTT::base::OutputPortInterface::createConnection(), and RTT::base::PortInterface::getName().
|
inline |
Clears the last written value and all data stored in shared connection buffers.
The clear() call on an OutputPort has no effect on private connections.
Definition at line 227 of file OutputPort.hpp.
References RTT::base::PortInterface::cmanager, RTT::OutputPort< T >::getEndpoint(), and RTT::internal::ConnectionManager::getSharedConnection().
|
inlinevirtual |
Create a clone of this port with the same name.
Implements RTT::base::PortInterface.
Definition at line 289 of file OutputPort.hpp.
References RTT::base::PortInterface::getName().
|
virtualinherited |
Returns true if there is at least one channel registered in this port's list of outputs.
Returns true if this port is connected.
Implements RTT::base::PortInterface.
Reimplemented in RTT::corba::RemotePort< base::OutputPortInterface >.
Definition at line 60 of file OutputPortInterface.cpp.
References RTT::base::PortInterface::cmanager, and RTT::internal::ConnectionManager::connected().
Referenced by RTT::OutputPort< T >::setDataSample(), and RTT::OutputPort< T >::write().
|
virtualinherited |
Returns true if this port is connected to the given port.
Definition at line 67 of file PortInterface.cpp.
References RTT::base::PortInterface::cmanager, and RTT::internal::ConnectionManager::connectedTo().
Referenced by RTT::internal::ConnFactory::createConnection().
|
virtualinherited |
Connects this port with other, using the given policy.
Unlike OutputPortInterface::createConnection, other can be the write port and this
the read port.
Implements RTT::base::PortInterface.
Definition at line 98 of file OutputPortInterface.cpp.
References RTT::base::OutputPortInterface::createConnection().
|
virtualinherited |
Connects this port with other, using the default policy of the input.
Unlike OutputPortInterface::createConnection, other can be the write port and this
the read port.
Implements RTT::base::PortInterface.
Definition at line 106 of file OutputPortInterface.cpp.
References RTT::base::OutputPortInterface::createConnection().
|
inherited |
Connects this write port to the given read port, using a buffered policy, with the buffer of the given size and the given locking mechanism.
Definition at line 87 of file OutputPortInterface.cpp.
References RTT::ConnPolicy::buffer(), RTT::internal::ConnFactory::createAndCheckSharedConnection(), RTT::base::OutputPortInterface::createConnection(), and RTT::base::InputPortInterface::getDefaultPolicy().
|
inherited |
Connects this write port to the given read port, using as policy the default policy of the sink port.
Referenced by RTT::OutputPort< T >::antiClone(), RTT::base::InputPortInterface::connectTo(), RTT::base::OutputPortInterface::connectTo(), RTT::base::OutputPortInterface::createBufferConnection(), RTT::base::OutputPortInterface::createDataConnection(), and RTT::corba::CDataFlowInterface_i::deregisterChannel().
|
virtualinherited |
Connects the port to an existing shared connection instance.
Implements RTT::base::PortInterface.
|
inlinevirtual |
Connects this write port to the given read port, using the given policy.
Implements RTT::base::OutputPortInterface.
Definition at line 304 of file OutputPort.hpp.
References RTT::internal::ConnFactory::createConnection().
|
inherited |
Connects this write port to the given read port, using a single-data policy with the given locking mechanism.
Definition at line 84 of file OutputPortInterface.cpp.
References RTT::base::OutputPortInterface::createConnection(), and RTT::ConnPolicy::data().
|
inlinevirtual |
Create accessor Object for this Port, for addition to a TaskContext Object interface.
Reimplemented from RTT::base::PortInterface.
Definition at line 319 of file OutputPort.hpp.
References RTT::base::PortInterface::createPortObject(), RTT::OutputPort< T >::getLastWrittenValue(), and RTT::OutputPort< T >::write().
|
inlinevirtual |
Creates a data stream from or to this port using connection-less transports.
Typically, policy.transport and policy.name_id must be properly filled in such that the data stream can be set up and input and output port can find each other. You need to call this method on two ports (input and output) using the same transport and (probably) same name_id.
policy | The connection policy describing how the stream must be set up. |
Implements RTT::base::PortInterface.
Definition at line 309 of file OutputPort.hpp.
References RTT::internal::ConnFactory::createStream().
|
virtualinherited |
Removes any connection that either go to or come from this port.
Implements RTT::base::PortInterface.
Reimplemented in RTT::corba::RemotePort< base::OutputPortInterface >.
Definition at line 68 of file OutputPortInterface.cpp.
References RTT::base::PortInterface::cmanager, and RTT::internal::ConnectionManager::disconnect().
Referenced by RTT::internal::ConnFactory::createAndCheckConnection(), and RTT::OutputPort< T >::~OutputPort().
|
virtualinherited |
Removes the channel that connects this port to port
.
Implements RTT::base::PortInterface.
Reimplemented in RTT::corba::RemoteOutputPort.
Definition at line 63 of file OutputPortInterface.cpp.
References RTT::base::PortInterface::cmanager, and RTT::internal::ConnectionManager::disconnect().
|
inherited |
Set the documentation of this port.
desc | The description of the port |
Definition at line 60 of file PortInterface.cpp.
References RTT::base::PortInterface::iface, and RTT::DataFlowInterface::setPortDescription().
Referenced by RTT::InputPort< T >::createPortObject(), and RTT::corba::TaskContextProxy::synchronizePorts().
|
inlinevirtual |
Returns a Data source that stores the last written value, or a null pointer if this port does not keep its last written value.
Implements RTT::base::OutputPortInterface.
Definition at line 194 of file OutputPort.hpp.
|
inlineinherited |
Get the documentation of this port.
Definition at line 93 of file PortInterface.hpp.
Referenced by RTT::corba::CDataFlowInterface_i::_default_POA().
|
inlinevirtual |
Returns the input or output endpoint of this port (if any).
This method provides access to the internals of this port in order to access connected channel objects directly.
Implements RTT::base::PortInterface.
Definition at line 333 of file OutputPort.hpp.
Referenced by RTT::internal::ConnFactory::buildChannelInput(), RTT::OutputPort< T >::clear(), RTT::OutputPort< T >::getSharedBuffer(), RTT::OutputPort< T >::setDataSample(), and RTT::OutputPort< T >::write().
|
inherited |
Returns the DataFlowInterface this port belongs to or null if it was not added to such an interface.
Definition at line 104 of file PortInterface.cpp.
References RTT::base::PortInterface::iface.
Referenced by RTT::corba::RemoteInputPort::buildRemoteChannelOutput(), RTT::corba::RemoteOutputPort::createConnection(), and RTT::mqueue::MQSendRecv::setupStream().
|
inline |
Returns the last written value written to this port, in case it is kept by this port, otherwise, returns a default T().
Definition at line 173 of file OutputPort.hpp.
References RTT::base::DataObjectInterface< T >::Get().
Referenced by RTT::internal::ConnFactory::buildChannelInput(), RTT::internal::ConnFactory::buildSharedConnection(), RTT::internal::ConnFactory::createConnection(), RTT::internal::ConnFactory::createOutOfBandConnection(), and RTT::OutputPort< T >::createPortObject().
|
inline |
Reads the last written value written to this port, in case it is kept by this port, otherwise, returns false.
sample | The data sample to store the value into. |
Definition at line 184 of file OutputPort.hpp.
|
inlinevirtualinherited |
Returns the connection manager of this port (if any).
This method provides access to the internals of this port in order to allow connection introspection.
Definition at line 222 of file PortInterface.hpp.
Referenced by RTT::internal::ConnInputEndpoint< T >::disconnect(), and RTT::internal::ConnOutputEndpoint< T >::disconnect().
|
inlineinherited |
Get the name of this Port.
Definition at line 79 of file PortInterface.hpp.
Referenced by RTT::DataFlowInterface::addEventPort(), RTT::DataFlowInterface::addLocalEventPort(), RTT::DataFlowInterface::addLocalPort(), RTT::DataFlowInterface::addPort(), RTT::corba::RemoteOutputPort::antiClone(), RTT::corba::RemoteInputPort::antiClone(), RTT::InputPort< T >::antiClone(), RTT::OutputPort< T >::antiClone(), RTT::corba::CorbaFallBackProtocol::buildChannelInput(), RTT::internal::ConnFactory::buildChannelInput(), RTT::corba::CorbaFallBackProtocol::buildChannelOutput(), RTT::internal::ConnFactory::buildChannelOutput(), RTT::corba::RemoteInputPort::buildRemoteChannelOutput(), RTT::internal::ConnFactory::buildRemoteChannelOutput(), RTT::internal::ConnFactory::buildSharedConnection(), RTT::corba::RemoteOutputPort::clone(), RTT::corba::RemoteInputPort::clone(), RTT::InputPort< T >::clone(), RTT::OutputPort< T >::clone(), RTT::TaskContext::connectPorts(), RTT::base::InputPortInterface::connectTo(), RTT::internal::ConnFactory::createAndCheckConnection(), RTT::internal::ConnFactory::createAndCheckSharedConnection(), RTT::internal::ConnFactory::createAndCheckStream(), RTT::corba::RemoteOutputPort::createConnection(), RTT::corba::RemoteInputPort::createConnection(), RTT::internal::ConnFactory::createConnection(), RTT::base::PortInterface::createPortObject(), RTT::corba::CorbaFallBackProtocol::createStream(), RTT::corba::CDataFlowInterface_i::deregisterChannel(), RTT::corba::RemoteOutputPort::disconnect(), RTT::internal::ConnectionManager::eraseConnection(), RTT::internal::ConnFactory::findSharedConnection(), RTT::OutputPort< T >::setDataSample(), RTT::mqueue::MQSendRecv::setupStream(), and RTT::OutputPort< T >::write().
|
virtualinherited |
Returns the identity of this port in a ConnID object.
Reimplemented in RTT::corba::RemotePort< base::InputPortInterface >, and RTT::corba::RemotePort< base::OutputPortInterface >.
Definition at line 76 of file PortInterface.cpp.
Referenced by RTT::internal::ConnectionManager::connectedTo(), RTT::internal::ConnFactory::createAndCheckConnection(), and RTT::internal::ConnectionManager::disconnect().
|
inlinevirtual |
Definition at line 339 of file OutputPort.hpp.
References RTT::OutputPort< T >::getEndpoint().
Referenced by RTT::internal::ConnFactory::buildChannelInput().
|
virtualinherited |
Returns a pointer to the shared connection element this port may be connected to.
Definition at line 109 of file PortInterface.cpp.
References RTT::base::PortInterface::cmanager, and RTT::internal::ConnectionManager::getSharedConnection().
Referenced by RTT::internal::ConnFactory::createAndCheckSharedConnection(), and RTT::internal::ConnFactory::findSharedConnection().
|
inlinevirtual |
Returns the types::TypeInfo object for the port's type.
Implements RTT::base::PortInterface.
Definition at line 283 of file OutputPort.hpp.
References RTT::internal::DataSourceTypeInfo< T >::getTypeInfo().
|
virtualinherited |
Returns true if this port is located on this process, and false otherwise.
Definition at line 71 of file PortInterface.cpp.
References RTT::base::PortInterface::serverProtocol().
Referenced by RTT::internal::ConnFactory::buildSharedConnection(), RTT::internal::ConnFactory::createAndCheckSharedConnection(), and RTT::internal::ConnFactory::createConnection().
|
inlinevirtual |
Change the setting for keeping the last written value.
Setting this to false will clear up any unneeded storage. If set, this port can initialize new connections with a data sample and allows real-time data transport of dynamically sized objects over its newly created connections.
Implements RTT::base::OutputPortInterface.
Definition at line 161 of file OutputPort.hpp.
Referenced by RTT::OutputPort< T >::OutputPort().
|
inline |
Definition at line 156 of file OutputPort.hpp.
|
inlinevirtual |
Returns true if this port records the last written value.
Implements RTT::base::OutputPortInterface.
Definition at line 166 of file OutputPort.hpp.
|
virtualinherited |
Removes a user created connection from this port.
This is an advanced method, prefer to use disconnect() or a method from a subclass of PortInterface.
Definition at line 95 of file PortInterface.cpp.
References RTT::base::PortInterface::cmanager, and RTT::internal::ConnectionManager::removeConnection().
Referenced by RTT::corba::CDataFlowInterface_i::deregisterChannel().
|
virtualinherited |
Returns the protocol over which this port can be accessed.
Reimplemented in RTT::corba::RemotePort< base::InputPortInterface >, and RTT::corba::RemotePort< base::OutputPortInterface >.
Definition at line 73 of file PortInterface.cpp.
Referenced by RTT::internal::ConnFactory::buildRemoteChannelOutput(), and RTT::base::PortInterface::isLocal().
|
inline |
Provides this port a data sample that is representative for the samples being used in write().
The sample will not be delivered to receivers, and only passed on to the underlying communication channel to allow it to allocate enough memory to hold the sample. You only need to call this in case you want to transfer dynamically sized objects in real-time over this OutputPort.
sample |
Definition at line 209 of file OutputPort.hpp.
References RTT::base::OutputPortInterface::connected(), RTT::Error, RTT::OutputPort< T >::getEndpoint(), RTT::base::PortInterface::getName(), and RTT::NotConnected.
|
inherited |
Once a port is added to a DataFlowInterface, it gets a pointer to that interface.
This allows advanced ports to track back to which component they belong.
Definition at line 100 of file PortInterface.cpp.
References RTT::base::PortInterface::iface.
Referenced by RTT::DataFlowInterface::addLocalPort(), and RTT::corba::CDataFlowInterface_i::deregisterChannel().
|
inherited |
Change the name of this unconnected Port.
One can only change the name when it is not yet connected.
true | if !this->connected(), the name has changed. |
false | if this->connected(), the name has not been changed. |
Definition at line 51 of file PortInterface.cpp.
References RTT::base::PortInterface::connected().
Referenced by RTT::DataFlowInterface::addEventPort(), RTT::TaskContext::addEventPort(), RTT::DataFlowInterface::addPort(), and RTT::TaskContext::addPort().
|
inline |
Writes a new sample to all receivers (if any).
sample | The new sample to send out. |
Definition at line 243 of file OutputPort.hpp.
References RTT::base::OutputPortInterface::connected(), RTT::Error, RTT::OutputPort< T >::getEndpoint(), RTT::base::PortInterface::getName(), and RTT::NotConnected.
Referenced by RTT::OutputPort< T >::createPortObject(), and RTT::OutputPort< T >::write().
|
inlinevirtual |
Write this port using the value stored in source.
Reimplemented from RTT::base::OutputPortInterface.
Definition at line 264 of file OutputPort.hpp.
References RTT::Error, RTT::internal::DataSource< T >::get(), RTT::internal::DataSource< T >::rvalue(), RTT::OutputPort< T >::write(), and RTT::WriteFailure.
|
friend |
Definition at line 73 of file OutputPort.hpp.
|
protectedinherited |
Definition at line 64 of file PortInterface.hpp.
Referenced by RTT::base::OutputPortInterface::addConnection(), RTT::OutputPort< T >::clear(), RTT::base::OutputPortInterface::connected(), RTT::base::PortInterface::connectedTo(), RTT::base::OutputPortInterface::disconnect(), RTT::base::PortInterface::getSharedConnection(), RTT::base::PortInterface::removeConnection(), and RTT::base::OutputPortInterface::~OutputPortInterface().
|
protectedinherited |
Definition at line 63 of file PortInterface.hpp.
Referenced by RTT::base::PortInterface::createPortObject(), RTT::base::PortInterface::doc(), RTT::base::PortInterface::getInterface(), and RTT::base::PortInterface::setInterface().