Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
RTT::OutputPort< T > Class Template Reference

#include <OutputPort.hpp>

Inheritance diagram for RTT::OutputPort< T >:
Inheritance graph
[legend]

Public Member Functions

virtual base::PortInterfaceantiClone () const
 
void clear ()
 
virtual base::PortInterfaceclone () const
 
virtual bool createConnection (base::InputPortInterface &input_port, ConnPolicy const &policy)
 
virtual ServicecreatePortObject ()
 
virtual bool createStream (ConnPolicy const &policy)
 
virtual base::DataSourceBase::shared_ptr getDataSource () const
 
virtual internal::ConnInputEndpoint< T > * getEndpoint () const
 
getLastWrittenValue () const
 
bool getLastWrittenValue (T &sample) const
 
virtual base::ChannelElement< T >::shared_ptr getSharedBuffer () const
 
virtual const types::TypeInfogetTypeInfo () const
 
void keepLastWrittenValue (bool keep)
 
void keepNextWrittenValue (bool keep)
 
bool keepsLastWrittenValue () const
 
 OutputPort (std::string const &name="unnamed", bool keep_last_written_value=true)
 
void setDataSample (const T &sample)
 
WriteStatus write (const T &sample)
 
WriteStatus write (base::DataSourceBase::shared_ptr source)
 
virtual ~OutputPort ()
 
- Public Member Functions inherited from RTT::base::OutputPortInterface
virtual bool addConnection (internal::ConnID *port_id, ChannelElementBase::shared_ptr channel_input, ConnPolicy const &policy)
 
virtual bool connected () const
 
virtual bool connectTo (PortInterface *other, ConnPolicy const &policy)
 
virtual bool connectTo (PortInterface *other)
 
bool createBufferConnection (InputPortInterface &sink, int size, int lock_policy=ConnPolicy::LOCK_FREE)
 
bool createConnection (InputPortInterface &sink)
 
virtual bool createConnection (internal::SharedConnectionBase::shared_ptr shared_connection, ConnPolicy const &policy=ConnPolicy())
 
bool createDataConnection (InputPortInterface &sink, int lock_policy=ConnPolicy::LOCK_FREE)
 
virtual void disconnect ()
 
virtual bool disconnect (PortInterface *port)
 
 OutputPortInterface (std::string const &name)
 
void traceWrite ()
 
virtual ~OutputPortInterface ()
 
- Public Member Functions inherited from RTT::base::PortInterface
virtual bool connectedTo (PortInterface *port)
 
PortInterfacedoc (const std::string &desc)
 
const std::string & getDescription () const
 
const std::string & getFullName () const
 
DataFlowInterfacegetInterface () const
 
virtual internal::ConnectionManagergetManager ()
 
const std::string & getName () const
 
virtual internal::ConnIDgetPortID () const
 
virtual internal::SharedConnectionBase::shared_ptr getSharedConnection () const
 
virtual bool isLocal () const
 
virtual bool removeConnection (internal::ConnID *cid)
 
virtual int serverProtocol () const
 
void setInterface (DataFlowInterface *iface)
 
bool setName (const std::string &name)
 
virtual ~PortInterface ()
 

Private Member Functions

virtual bool connectionAdded (base::ChannelElementBase::shared_ptr channel_input, ConnPolicy const &policy)
 
OutputPortoperator= (OutputPort const &orig)
 
 OutputPort (OutputPort const &orig)
 

Private Attributes

internal::ConnInputEndpoint< T >::shared_ptr endpoint
 
bool has_initial_sample
 True if sample has been written at least once, either by calling. More...
 
bool has_last_written_value
 True if sample has been set at least once by a call to write() More...
 
bool keeps_last_written_value
 If true, all calls to write() will save the sample in sample. More...
 
bool keeps_next_written_value
 If true, the next call to write() will save the sample in sample. More...
 
base::DataObjectInterface< T >::shared_ptr sample
 

Friends

class internal::ConnInputEndpoint< T >
 

Additional Inherited Members

- Protected Member Functions inherited from RTT::base::OutputPortInterface
 OutputPortInterface (OutputPortInterface const &orig)
 
- Protected Member Functions inherited from RTT::base::PortInterface
 PortInterface (const std::string &name)
 
- Protected Attributes inherited from RTT::base::PortInterface
internal::ConnectionManager cmanager
 
os::MutexRecursive connection_lock
 
DataFlowInterfaceiface
 

Detailed Description

template<typename T>
class RTT::OutputPort< 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.

See also
RTT::types::TemplateTypeInfo for adding custom data classes to the RTT.

Definition at line 70 of file OutputPort.hpp.

Constructor & Destructor Documentation

template<typename T>
RTT::OutputPort< T >::OutputPort ( OutputPort< T > const &  orig)
private

You are not allowed to copy ports. In case you want to create a container of ports, use pointers to ports instead of the port object itself.

template<typename T>
RTT::OutputPort< T >::OutputPort ( std::string const &  name = "unnamed",
bool  keep_last_written_value = true 
)
inline

Creates a named Output port.

Parameters
nameThe name of this port, unique among the ports of a TaskContext.
keep_last_written_valueDefaults to true. You need keep_last_written_value == true in two cases:
  • You're sending dynamically sized objects through this port in real-time. In that case, you need to write() to this port such an object before a connection is created. That object will be used to allocate enough data storage in each there-after created connection. If you would set keep_last_written_value == false in this use case, several memory allocations will happen during the initial writes, after which none will happen anymore.
  • You want to have an input to have the last written data available from before its connection was created, such that it is immediately initialized. The keep_last_written_value incurs a space overhead of one thread-safe data storage container. This is about the same size as one extra connection.

Definition at line 141 of file OutputPort.hpp.

template<typename T>
virtual RTT::OutputPort< T >::~OutputPort ( )
inlinevirtual

Definition at line 154 of file OutputPort.hpp.

Member Function Documentation

template<typename T>
virtual base::PortInterface* RTT::OutputPort< T >::antiClone ( ) const
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 302 of file OutputPort.hpp.

template<typename T>
void RTT::OutputPort< T >::clear ( )
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.

template<typename T>
virtual base::PortInterface* RTT::OutputPort< T >::clone ( ) const
inlinevirtual

Create a clone of this port with the same name

Implements RTT::base::PortInterface.

Definition at line 294 of file OutputPort.hpp.

template<typename T>
virtual bool RTT::OutputPort< T >::connectionAdded ( base::ChannelElementBase::shared_ptr  channel_input,
ConnPolicy const &  policy 
)
inlineprivatevirtual

Upcall to OutputPort.

Implements RTT::base::OutputPortInterface.

Definition at line 76 of file OutputPort.hpp.

template<typename T>
virtual bool RTT::OutputPort< T >::createConnection ( base::InputPortInterface input_port,
ConnPolicy const &  policy 
)
inlinevirtual

Connects this write port to the given read port, using the given policy

Implements RTT::base::OutputPortInterface.

Definition at line 309 of file OutputPort.hpp.

template<typename T>
virtual Service* RTT::OutputPort< T >::createPortObject ( )
inlinevirtual

Create accessor Object for this Port, for addition to a TaskContext Object interface.

Reimplemented from RTT::base::PortInterface.

Definition at line 324 of file OutputPort.hpp.

template<typename T>
virtual bool RTT::OutputPort< T >::createStream ( ConnPolicy const &  policy)
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.

Parameters
policyThe connection policy describing how the stream must be set up.

Implements RTT::base::PortInterface.

Definition at line 314 of file OutputPort.hpp.

template<typename T>
virtual base::DataSourceBase::shared_ptr RTT::OutputPort< T >::getDataSource ( ) const
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.

template<typename T>
virtual internal::ConnInputEndpoint<T>* RTT::OutputPort< T >::getEndpoint ( ) const
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 338 of file OutputPort.hpp.

template<typename T>
T RTT::OutputPort< T >::getLastWrittenValue ( ) const
inline

Returns the last written value written to this port, in case it is kept by this port, otherwise, returns a default T().

Returns
The last written value or T().

Definition at line 173 of file OutputPort.hpp.

template<typename T>
bool RTT::OutputPort< T >::getLastWrittenValue ( T &  sample) const
inline

Reads the last written value written to this port, in case it is kept by this port, otherwise, returns false.

Parameters
sampleThe data sample to store the value into.
Returns
true if it could be retrieved, false otherwise.

Definition at line 184 of file OutputPort.hpp.

template<typename T>
virtual base::ChannelElement<T>::shared_ptr RTT::OutputPort< T >::getSharedBuffer ( ) const
inlinevirtual

Definition at line 344 of file OutputPort.hpp.

template<typename T>
virtual const types::TypeInfo* RTT::OutputPort< T >::getTypeInfo ( ) const
inlinevirtual

Returns the types::TypeInfo object for the port's type

Implements RTT::base::PortInterface.

Definition at line 288 of file OutputPort.hpp.

template<typename T>
void RTT::OutputPort< T >::keepLastWrittenValue ( bool  new_flag)
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.

See also
OutputPort::OutputPort.

Implements RTT::base::OutputPortInterface.

Definition at line 161 of file OutputPort.hpp.

template<typename T>
void RTT::OutputPort< T >::keepNextWrittenValue ( bool  keep)
inline

Definition at line 156 of file OutputPort.hpp.

template<typename T>
bool RTT::OutputPort< T >::keepsLastWrittenValue ( ) const
inlinevirtual

Returns true if this port records the last written value.

Implements RTT::base::OutputPortInterface.

Definition at line 166 of file OutputPort.hpp.

template<typename T>
OutputPort& RTT::OutputPort< T >::operator= ( OutputPort< T > const &  orig)
private
template<typename T>
void RTT::OutputPort< T >::setDataSample ( const T &  sample)
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.

Parameters
sample

Definition at line 209 of file OutputPort.hpp.

template<typename T>
WriteStatus RTT::OutputPort< T >::write ( const T &  sample)
inline

Writes a new sample to all receivers (if any).

Parameters
sampleThe new sample to send out.

Definition at line 243 of file OutputPort.hpp.

template<typename T>
WriteStatus RTT::OutputPort< T >::write ( base::DataSourceBase::shared_ptr  source)
inlinevirtual

Write this port using the value stored in source.

Reimplemented from RTT::base::OutputPortInterface.

Definition at line 265 of file OutputPort.hpp.

Friends And Related Function Documentation

template<typename T>
friend class internal::ConnInputEndpoint< T >
friend

Definition at line 73 of file OutputPort.hpp.

Member Data Documentation

template<typename T>
internal::ConnInputEndpoint<T>::shared_ptr RTT::OutputPort< T >::endpoint
private

Definition at line 74 of file OutputPort.hpp.

template<typename T>
bool RTT::OutputPort< T >::has_initial_sample
private

True if sample has been written at least once, either by calling.

Definition at line 106 of file OutputPort.hpp.

template<typename T>
bool RTT::OutputPort< T >::has_last_written_value
private

True if sample has been set at least once by a call to write()

Definition at line 102 of file OutputPort.hpp.

template<typename T>
bool RTT::OutputPort< T >::keeps_last_written_value
private

If true, all calls to write() will save the sample in sample.

Definition at line 112 of file OutputPort.hpp.

template<typename T>
bool RTT::OutputPort< T >::keeps_next_written_value
private

If true, the next call to write() will save the sample in sample.

Definition at line 109 of file OutputPort.hpp.

template<typename T>
base::DataObjectInterface<T>::shared_ptr RTT::OutputPort< T >::sample
private

Definition at line 113 of file OutputPort.hpp.


The documentation for this class was generated from the following file:


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:41