Orocos Real-Time Toolkit
2.5.0
|
A component's data input port. More...
#include <rtt/InputPort.hpp>
Public Member Functions | |
InputPort (std::string const &name="unnamed", ConnPolicy const &default_policy=ConnPolicy()) | |
FlowStatus | read (base::DataSourceBase::shared_ptr source) |
FlowStatus | read (base::DataSourceBase::shared_ptr source, bool copy_old_data) |
Reads the port and updates the value hold by the given data source. | |
FlowStatus | readNewest (base::DataSourceBase::shared_ptr source, bool copy_old_data=true) |
Read all new samples that are available on this port, and returns the last one. | |
FlowStatus | read (typename base::ChannelElement< T >::reference_t sample) |
FlowStatus | read (typename base::ChannelElement< T >::reference_t sample, bool copy_old_data) |
Reads a sample from the connection. | |
FlowStatus | readNewest (typename base::ChannelElement< T >::reference_t sample, bool copy_old_data=true) |
Read all new samples that are available on this port, and returns the last one. | |
virtual const types::TypeInfo * | getTypeInfo () const |
Returns the types::TypeInfo object for the port's type. | |
virtual base::PortInterface * | clone () const |
Create a clone of this port with the same name. | |
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. | |
base::DataSourceBase * | getDataSource () |
Returns a base::DataSourceBase interface to read this port. | |
virtual bool | createStream (ConnPolicy const &policy) |
Creates a data stream from or to this port using connection-less transports. | |
virtual Service * | createPortObject () |
Create accessor Object for this Port, for addition to a TaskContext Object interface. | |
void | clear () |
Clears the connection. | |
ConnPolicy | getDefaultPolicy () const |
virtual bool | addConnection (internal::ConnID *port_id, ChannelElementBase::shared_ptr channel_input, ConnPolicy const &policy=ConnPolicy()) |
Adds a user created connection to this port. | |
virtual bool | removeConnection (internal::ConnID *cid) |
Removes the input channel. | |
virtual void | disconnect () |
Removes any connection that either go to or come from this port *and* removes all callbacks and cleans up the NewDataOnPortEvent. | |
virtual bool | disconnect (PortInterface *port) |
Removes the channel that connects this port to port . | |
virtual bool | connected () const |
Returns true if this port is connected. | |
virtual bool | channelReady (base::ChannelElementBase::shared_ptr channel) |
Call this to indicate that the connection leading to this port is ready to use. | |
void | signalInterface (bool true_false) |
When called with true, will signal the DataFlowInterface when new data is available. | |
virtual bool | connectTo (PortInterface *other, ConnPolicy const &policy) |
Connects this port with other, using the given policy. | |
virtual bool | connectTo (PortInterface *other) |
Connects this port with other, using the default policy of the input. | |
virtual const internal::ConnectionManager * | getManager () const |
Returns the connection manager of this port (if any). | |
virtual internal::ConnID * | getPortID () const |
Returns the identity of this port in a ConnID object. | |
const std::string & | getName () const |
Get the name of this Port. | |
bool | setName (const std::string &name) |
Change the name of this unconnected Port. | |
const std::string & | getDescription () const |
Get the documentation of this port. | |
PortInterface & | doc (const std::string &desc) |
Set the documentation of this port. | |
virtual internal::ConnFactory * | getConnFactory () |
The ChannelFactory object that allows to build the ChannelElement chain needed to build connections to or from this port. | |
virtual bool | isLocal () const |
Returns true if this port is located on this process, and false otherwise. | |
virtual int | serverProtocol () const |
Returns the protocol over which this port can be accessed. | |
void | setInterface (DataFlowInterface *iface) |
Once a port is added to a DataFlowInterface, it gets a pointer to that interface. | |
DataFlowInterface * | getInterface () const |
Returns the DataFlowInterface this port belongs to or null if it was not added to such an interface. | |
Protected Member Functions | |
void | signal () |
The ConnOutputEndpoint signals that new data is available. | |
Protected Attributes | |
internal::ConnectionManager | cmanager |
ConnPolicy | default_policy |
bool | msignal_interface |
DataFlowInterface * | iface |
Friends | |
class | internal::ConnOutputEndpoint< T > |
A component's data input port.
An Orocos input port is used to receive data samples from a distant publisher. The InputPort is read() and returns true if a sample is available.
Ideally, your algorithm should not assume a certain connection policy being used from output to input. So it should work on data connections and buffer connections.
Definition at line 63 of file InputPort.hpp.
bool InputPortInterface::addConnection | ( | internal::ConnID * | cid, |
ChannelElementBase::shared_ptr | channel_input, | ||
ConnPolicy const & | policy = ConnPolicy() |
||
) | [virtual, inherited] |
Adds a user created connection to this port.
This is an advanced method, prefer to use connectTo and createStream.
Implements RTT::base::PortInterface.
Reimplemented in RTT::corba::RemoteInputPort.
Definition at line 99 of file InputPortInterface.cpp.
References RTT::internal::ConnectionManager::addConnection().
bool InputPortInterface::channelReady | ( | base::ChannelElementBase::shared_ptr | channel | ) | [virtual, inherited] |
Call this to indicate that the connection leading to this port is ready to use.
The input port will check its channel elements by sending an inputReady() message. If this succeeds, this function returns true and the input port is ready to use (this->connected() == true). If sending inputReady() returns failure, this method returns false and the connection is aborted (this->connected() == false).
Reimplemented in RTT::corba::RemoteInputPort.
Definition at line 106 of file InputPortInterface.cpp.
void InputPortInterface::clear | ( | ) | [inherited] |
Clears the connection.
After call to read() will return false after clear() has been called
Definition at line 145 of file InputPortInterface.cpp.
References RTT::internal::ConnectionManager::clear().
bool InputPortInterface::connectTo | ( | PortInterface * | other, |
ConnPolicy const & | policy | ||
) | [virtual, inherited] |
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 84 of file InputPortInterface.cpp.
References RTT::base::OutputPortInterface::createConnection(), and RTT::base::PortInterface::getName().
Referenced by RTT::base::InputPortInterface::connectTo().
bool InputPortInterface::connectTo | ( | PortInterface * | other | ) | [virtual, inherited] |
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 94 of file InputPortInterface.cpp.
References RTT::base::InputPortInterface::connectTo().
virtual bool RTT::InputPort< T >::createStream | ( | ConnPolicy const & | policy | ) | [inline, virtual] |
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 206 of file InputPort.hpp.
bool InputPortInterface::disconnect | ( | PortInterface * | port | ) | [virtual, inherited] |
Removes the channel that connects this port to port
.
All other ports or callbacks remain unaffected.
Implements RTT::base::PortInterface.
Definition at line 155 of file InputPortInterface.cpp.
References RTT::internal::ConnectionManager::disconnect().
PortInterface & PortInterface::doc | ( | const std::string & | desc | ) | [inherited] |
Set the documentation of this port.
desc | The description of the port |
Definition at line 60 of file PortInterface.cpp.
References RTT::DataFlowInterface::setPortDescription().
Referenced by RTT::InputPort< T >::createPortObject().
base::DataSourceBase* RTT::InputPort< T >::getDataSource | ( | ) | [inline, virtual] |
Returns a base::DataSourceBase interface to read this port.
The returned data source is always the same object and will be destroyed when the port is destroyed.
Implements RTT::base::InputPortInterface.
Definition at line 199 of file InputPort.hpp.
const std::string& RTT::base::PortInterface::getDescription | ( | ) | const [inline, inherited] |
Get the documentation of this port.
Definition at line 91 of file PortInterface.hpp.
virtual const internal::ConnectionManager* RTT::base::InputPortInterface::getManager | ( | ) | const [inline, virtual, inherited] |
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.
Implements RTT::base::PortInterface.
Definition at line 160 of file InputPortInterface.hpp.
FlowStatus RTT::InputPort< T >::read | ( | base::DataSourceBase::shared_ptr | source | ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 104 of file InputPort.hpp.
References RTT::InputPort< T >::read().
Referenced by RTT::InputPort< T >::read(), and RTT::InputPort< T >::readNewest().
FlowStatus RTT::InputPort< T >::read | ( | base::DataSourceBase::shared_ptr | source, |
bool | copy_old_data | ||
) | [inline, virtual] |
Reads the port and updates the value hold by the given data source.
This is only valid for local ports.
source has to be an assignable data source
Reimplemented from RTT::base::InputPortInterface.
Definition at line 107 of file InputPort.hpp.
References RTT::InputPort< T >::read(), and RTT::internal::AssignableDataSource< T >::set().
FlowStatus RTT::InputPort< T >::read | ( | typename base::ChannelElement< T >::reference_t | sample | ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 138 of file InputPort.hpp.
References RTT::InputPort< T >::read().
Referenced by RTT::InputPort< T >::read().
FlowStatus RTT::InputPort< T >::read | ( | typename base::ChannelElement< T >::reference_t | sample, |
bool | copy_old_data | ||
) | [inline] |
Reads a sample from the connection.
sample is a reference which will get updated if a new sample is available.
The method returns an enum FlowStatus, which describes what type of sample (old or new data) or if a sample was returned (no data)
With the argument
Definition at line 152 of file InputPort.hpp.
References RTT::internal::ConnectionManager::select_reader_channel().
FlowStatus RTT::InputPort< T >::readNewest | ( | base::DataSourceBase::shared_ptr | source, |
bool | copy_old_data = true |
||
) | [inline] |
Read all new samples that are available on this port, and returns the last one.
Returns RTT::NewSample if at least one new sample was available, and either RTT::OldSample or RTT::NoSample otherwise.
Definition at line 125 of file InputPort.hpp.
References RTT::internal::AssignableDataSource< T >::set().
FlowStatus RTT::InputPort< T >::readNewest | ( | typename base::ChannelElement< T >::reference_t | sample, |
bool | copy_old_data = true |
||
) | [inline] |
Read all new samples that are available on this port, and returns the last one.
Returns RTT::NewSample if at least one new sample was available, and either RTT::OldSample or RTT::NoSample otherwise.
Definition at line 167 of file InputPort.hpp.
References RTT::InputPort< T >::read().
bool InputPortInterface::removeConnection | ( | internal::ConnID * | cid | ) | [virtual, inherited] |
Removes the input channel.
Returns true if the provided channel was actually a channel of this port, and false otherwise.
You should usually not use this directly. Use disconnect() instead.
Implements RTT::base::PortInterface.
Definition at line 123 of file InputPortInterface.cpp.
Referenced by RTT::internal::ConnFactory::createStream(), and RTT::internal::ConnOutputEndpoint< T >::disconnect().
void PortInterface::setInterface | ( | DataFlowInterface * | iface | ) | [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 92 of file PortInterface.cpp.
Referenced by RTT::DataFlowInterface::addLocalPort().
bool PortInterface::setName | ( | const std::string & | name | ) | [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().