RTT::BufferPort< T > Class Template Reference
[Data Transfer PortsTask Context Interface]

A Port to a read-write Buffer. More...

#include <rtt/BufferPort.hpp>

Inherits RTT::BufferPortBase< T >.

List of all members.

Public Types

typedef PortInterface::PortType PortType
 This enum classifies if a port is inbound outbound or both.
typedef
PortInterface::ConnectionModel 
ConnectionModel
 This enum classifies the kind of data connections that are available through ports: buffered or data.
typedef Event< void(PortInterface *) NewDataOnPortEvent )

Public Member Functions

 BufferPort (const std::string &name, size_t prefered_size, const T &initial_value=T())
 Construct an unconnected Port to a writeable buffer.
void setBufferSize (size_t b_size)
 Set the prefered buffersize before this port is connected.
bool Pop (T &data)
 Pop a value from the buffer of this Port's connection.
front () const
 Get the next value to be Pop()'ed, or the default value if empty.
bool Push (const T &data)
 Push a value into the buffer of this Port's connection.
void Set (const T &data)
 Set the initial value of the port's connection.
virtual PortInterface::PortType getPortType () const
 Get the PortType of this port.
virtual PortInterfaceclone () const
 Create a clone of this port with the same name.
virtual PortInterfaceantiClone () 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.
virtual TaskObjectcreatePortObject ()
 Create accessor Object for this Port, for addition to a TaskContext Object interface.
ConnectionInterface::shared_ptr createConnection (ConnectionTypes::ConnectionType con_type)
 Create a new connection object to which this port is subscribed.
void clear ()
 Clears all contents of this buffer.
BufferBase::size_type size () const
 Returns the actual number of items that are stored in the buffer.
BufferBase::size_type capacity () const
 Returns the maximum number of items that can be stored in the buffer.
bool empty () const
 Check if this buffer is empty.
bool full () const
 Check if this buffer is full.
virtual ConnectionModel getConnectionModel () const
virtual const TypeInfogetTypeInfo () const
bool connected () const
void disconnect ()
bool connectTo (ConnectionInterface::shared_ptr other)
virtual bool connectTo (PortInterface *other)
 Connect to another Port and create a new connection if necessary.
virtual BufferInterface< T > * buffer ()
 Get the buffer to read from or write to.
virtual const BufferInterface
< T > * 
buffer () const
virtual
ConnectionInterface::shared_ptr 
connection () const
ConnectionInterface::shared_ptr createConnection (BufferBase::shared_ptr impl)
virtual
ConnectionInterface::shared_ptr 
createConnection (DataSourceBase::shared_ptr data)
 Create a new connection object using a data connection implementation.
const std::string & getName () const
 Get the name of this Port.
bool setName (const std::string &name)
 Change the name of this unconnected Port.
bool ready () const
 Returns true if this Port is ready to be used.
void signal ()
 Call this method to signal that new data is available on this port.
NewDataOnPortEvent * getNewDataOnPortEvent ()
 Returns an Event object which is triggered every time new data is made available on this port.
virtual int serverProtocol () const
 Returns the protocol over which this port can be accessed.

Protected Member Functions

virtual bool connect (typename ConnectionInterface::shared_ptr conn)
 Connect a readable buffer to this Port.

Protected Attributes

size_t buf_size
minitial_value
BufferConnection< T >::shared_ptr mconn
std::string portname
NewDataOnPortEvent * new_data_on_port_event

Friends

class ConnectionInterface

Detailed Description

template<class T>
class RTT::BufferPort< T >

A Port to a read-write Buffer.

Use connection() to access the buffer. If the port is not connected, connection() returns null.

Parameters:
T The type of the data of the buffer.

Definition at line 420 of file BufferPort.hpp.


Constructor & Destructor Documentation

template<class T >
RTT::BufferPort< T >::BufferPort ( const std::string &  name,
size_t  prefered_size,
const T &  initial_value = T() 
) [inline]

Construct an unconnected Port to a writeable buffer.

Parameters:
name The name of this port.

Definition at line 438 of file BufferPort.hpp.


Member Function Documentation

template<class T >
virtual BufferInterface<T>* RTT::BufferPortBase< T >::buffer (  )  [inline, virtual, inherited]

Get the buffer to read from or write to.

Returns:
0 if !connected(), the buffer otherwise.

Definition at line 189 of file BufferPort.hpp.

template<class T >
BufferBase::size_type RTT::BufferPortBase< T >::capacity (  )  const [inline, inherited]

Returns the maximum number of items that can be stored in the buffer.

Returns:
maximum number of items.

Definition at line 114 of file BufferPort.hpp.

virtual bool RTT::PortInterface::connectTo ( PortInterface other  )  [virtual, inherited]

Connect to another Port and create a new connection if necessary.

  • If this port is already connected, this method returns false.
  • If the other port has a connection, this method is equivalent to 'this->connectTo( other->connection() )'.
  • If the other port is not connected, a new connection is created and both ports are connected.
    Returns:
    true upon success, false otherwise.

Referenced by RTT::ReadBufferPort< T >::antiClone().

virtual ConnectionInterface::shared_ptr RTT::PortInterface::createConnection ( DataSourceBase::shared_ptr  data  )  [virtual, inherited]

Create a new connection object using a data connection implementation.

Returns:
null if this->connected() or this->getConnectionModel() != Data else a valid connection object is returned.

Reimplemented in RTT::Corba::CorbaPort.

template<class T >
bool RTT::BufferPortBase< T >::empty (  )  const [inline, inherited]

Check if this buffer is empty.

Returns:
true if size() == 0

Definition at line 132 of file BufferPort.hpp.

template<class T >
bool RTT::BufferPortBase< T >::full (  )  const [inline, inherited]

Check if this buffer is full.

Returns:
true if size() == capacity()

Definition at line 150 of file BufferPort.hpp.

template<class T >
bool RTT::BufferPort< T >::Pop ( T &  data  )  [inline]

Pop a value from the buffer of this Port's connection.

Parameters:
data The location where to store the popped value.
Return values:
this->buffer()->Pop(data) if this->connected()
false if !this->connected()

Definition at line 455 of file BufferPort.hpp.

template<class T >
bool RTT::BufferPort< T >::Push ( const T &  data  )  [inline]

Push a value into the buffer of this Port's connection.

Parameters:
data The data to push.
Return values:
this->buffer()->Push(data) if this->connected()
false if !this->connected()

Definition at line 494 of file BufferPort.hpp.

template<class T >
void RTT::BufferPort< T >::Set ( const T &  data  )  [inline]

Set the initial value of the port's connection.

This value is only used when the connection is created. If this port is connected to an existing connection, the value is ignored.

Definition at line 517 of file BufferPort.hpp.

template<class T >
void RTT::BufferPort< T >::setBufferSize ( size_t  b_size  )  [inline]

Set the prefered buffersize before this port is connected.

If this->connected(), this value has no effect.

Definition at line 447 of file BufferPort.hpp.

bool RTT::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.

Return values:
true if !this->connected(), the name has changed.
false if this->connected(), the name has not been changed.
template<class T >
BufferBase::size_type RTT::BufferPortBase< T >::size (  )  const [inline, inherited]

Returns the actual number of items that are stored in the buffer.

Returns:
number of items.

Definition at line 95 of file BufferPort.hpp.


The documentation for this class was generated from the following file:
Generated on Thu Dec 23 13:22:39 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3