Orocos Real-Time Toolkit  2.9.0
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
RTT::internal::ConnFactory Class Referenceabstract

This class provides the basic tools to create channels that represent connections between two ports. More...

#include <rtt/internal/ConnFactory.hpp>

Public Member Functions

virtual ~ConnFactory ()
 
virtual base::InputPortInterfaceinputPort (std::string const &name) const =0
 Returns a new InputPort<T> object where T is the type represented by this TypeInfo object. More...
 
virtual base::OutputPortInterfaceoutputPort (std::string const &name) const =0
 Returns a new OutputPort<T> object where T is the type represented by this TypeInfo object. More...
 
virtual base::ChannelElementBase::shared_ptr buildDataStorage (ConnPolicy const &policy) const =0
 Creates single data or buffered storage for this type. More...
 
virtual base::ChannelElementBase::shared_ptr buildChannelOutput (base::InputPortInterface &port, ConnPolicy const &policy) const =0
 Creates the output endpoint of a communication channel and adds it to an InputPort. More...
 
virtual base::ChannelElementBase::shared_ptr buildChannelInput (base::OutputPortInterface &port, ConnPolicy const &policy) const =0
 Creates the input endpoint (starting point) of a communication channel and adds it to an OutputPort. More...
 
virtual internal::SharedConnectionBase::shared_ptr buildSharedConnection (base::OutputPortInterface *output_port, base::InputPortInterface *input_port, ConnPolicy const &policy) const =0
 Tries to find an existing or creates a new shared connection object for the given output port, input port and connection policy. More...
 

Static Public Member Functions

template<typename T >
static base::ChannelElement< T > * buildDataStorage (ConnPolicy const &policy, const T &initial_value=T())
 This method creates the connection element that will store data inside the connection, based on the given policy. More...
 
template<typename T >
static base::ChannelElementBase::shared_ptr buildChannelInput (OutputPort< T > &port, ConnPolicy const &policy, bool force_unbuffered=false)
 During the process of building a connection between two ports, this method builds the input half (starting from the OutputPort). More...
 
template<typename T >
static base::ChannelElementBase::shared_ptr buildChannelOutput (InputPort< T > &port, ConnPolicy const &policy, T const &initial_value=T())
 During the process of building a connection between two ports, this method builds the output part of the channel, that is the half that is connected to the input port. More...
 
static bool findSharedConnection (base::OutputPortInterface *output_port, base::InputPortInterface *input_port, ConnPolicy const &policy, SharedConnectionBase::shared_ptr &shared_connection)
 Tries to find an existing or creates a new shared connection object for the given output port, input port and connection policy. More...
 
template<typename T >
static SharedConnectionBase::shared_ptr buildSharedConnection (OutputPort< T > *output_port, base::InputPortInterface *input_port, ConnPolicy const &policy)
 Tries to find an existing or creates a new shared connection object for the given output port, input port and connection policy. More...
 
template<typename T >
static bool createConnection (OutputPort< T > &output_port, base::InputPortInterface &input_port, ConnPolicy const &policy)
 Creates a connection from a local output_port to a local or remote input_port. More...
 
template<class T >
static bool createStream (OutputPort< T > &output_port, ConnPolicy const &policy)
 Creates, attaches and checks an outbound stream to an Output port. More...
 
template<class T >
static bool createStream (InputPort< T > &input_port, ConnPolicy const &policy)
 Creates, attaches and checks an inbound stream to an Input port. More...
 
static bool createAndCheckSharedConnection (base::OutputPortInterface *output_port, base::InputPortInterface *input_port, SharedConnectionBase::shared_ptr shared_connection, ConnPolicy const &policy)
 

Static Protected Member Functions

static bool createAndCheckConnection (base::OutputPortInterface &output_port, base::InputPortInterface &input_port, base::ChannelElementBase::shared_ptr channel_input, base::ChannelElementBase::shared_ptr channel_output, ConnPolicy const &policy)
 
static base::ChannelElementBase::shared_ptr createAndCheckStream (base::OutputPortInterface &output_port, ConnPolicy const &policy, base::ChannelElementBase::shared_ptr channel_input, StreamConnID *conn_id)
 
static base::ChannelElementBase::shared_ptr createAndCheckStream (base::InputPortInterface &input_port, ConnPolicy const &policy, base::ChannelElementBase::shared_ptr channel_output, StreamConnID *conn_id)
 
static base::ChannelElementBase::shared_ptr buildRemoteChannelOutput (base::OutputPortInterface &output_port, base::InputPortInterface &input_port, ConnPolicy const &policy)
 
template<class T >
static bool createOutOfBandConnection (OutputPort< T > &output_port, InputPort< T > &input_port, ConnPolicy const &policy)
 This code is for setting up an in-process out-of-band connection. More...
 

Detailed Description

This class provides the basic tools to create channels that represent connections between two ports.

The ports and type transports use these functions to setup connections. The interface may change as the needs of these 'users' change.

Definition at line 94 of file ConnFactory.hpp.

Constructor & Destructor Documentation

virtual RTT::internal::ConnFactory::~ConnFactory ( )
inlinevirtual

Definition at line 97 of file ConnFactory.hpp.

Member Function Documentation

virtual base::ChannelElementBase::shared_ptr RTT::internal::ConnFactory::buildChannelInput ( base::OutputPortInterface port,
ConnPolicy const &  policy 
) const
pure virtual

Creates the input endpoint (starting point) of a communication channel and adds it to an OutputPort.

Parameters
portThe output port to connect the channel's input end to.
policyDescribes the kind of connection requested by the user
Returns
The created endpoint.

Referenced by RTT::types::TemplateConnFactory< bool >::buildChannelInput().

template<typename T >
static base::ChannelElementBase::shared_ptr RTT::internal::ConnFactory::buildChannelInput ( OutputPort< T > &  port,
ConnPolicy const &  policy,
bool  force_unbuffered = false 
)
inlinestatic

During the process of building a connection between two ports, this method builds the input half (starting from the OutputPort).

The ConnPolicy may require to install a buffer at the output side of the channel.

Parameters
portThe output port to which the connection is added.
policyThe policy dictating which kind of buffer must be installed. The transport and other parameters are ignored.
See also
buildChannelOutput

Definition at line 219 of file ConnFactory.hpp.

References RTT::ConnPolicy::buffer_policy, RTT::base::MultipleOutputsChannelElementBase::connected(), RTT::base::ChannelElementBase::connectTo(), RTT::Error, RTT::base::ChannelElementBase::getConnPolicy(), RTT::OutputPort< T >::getEndpoint(), RTT::OutputPort< T >::getLastWrittenValue(), RTT::base::PortInterface::getName(), RTT::OutputPort< T >::getSharedBuffer(), RTT::ConnPolicy::lock_policy, RTT::PerInputPort, RTT::PerOutputPort, RTT::ConnPolicy::PULL, RTT::ConnPolicy::pull, RTT::ConnPolicy::PUSH, RTT::ConnPolicy::size, and RTT::ConnPolicy::type.

virtual base::ChannelElementBase::shared_ptr RTT::internal::ConnFactory::buildChannelOutput ( base::InputPortInterface port,
ConnPolicy const &  policy 
) const
pure virtual

Creates the output endpoint of a communication channel and adds it to an InputPort.

Parameters
portThe input port to connect the channel's output end to.
policyDescribes the kind of connection requested by the user
Returns
The created endpoint.

Referenced by RTT::types::TemplateConnFactory< bool >::buildChannelOutput().

template<typename T >
static base::ChannelElementBase::shared_ptr RTT::internal::ConnFactory::buildChannelOutput ( InputPort< T > &  port,
ConnPolicy const &  policy,
T const &  initial_value = T() 
)
inlinestatic

During the process of building a connection between two ports, this method builds the output part of the channel, that is the half that is connected to the input port.

The returned value is the connection element that should be connected to the end of the input-half.

The ConnPolicy may require to install a buffer at the output side of the channel.

Parameters
portThe input port to which the connection is added.
policyThe policy dictating which kind of buffer must be installed. The transport and other parameters are ignored.
initial_valueThe value to use to initialize the connection's storage buffer.
See also
buildChannelInput

Definition at line 297 of file ConnFactory.hpp.

References RTT::ConnPolicy::buffer_policy, RTT::base::MultipleInputsChannelElementBase::connected(), RTT::base::ChannelElementBase::connectTo(), RTT::Error, RTT::base::ChannelElementBase::getConnPolicy(), RTT::InputPort< T >::getEndpoint(), RTT::base::PortInterface::getName(), RTT::InputPort< T >::getSharedBuffer(), RTT::ConnPolicy::lock_policy, RTT::PerInputPort, RTT::PerOutputPort, RTT::ConnPolicy::PULL, RTT::ConnPolicy::pull, RTT::ConnPolicy::PUSH, RTT::ConnPolicy::size, and RTT::ConnPolicy::type.

virtual base::ChannelElementBase::shared_ptr RTT::internal::ConnFactory::buildDataStorage ( ConnPolicy const &  policy) const
pure virtual

Creates single data or buffered storage for this type.

Parameters
policyDescribes the kind of storage requested by the user
Returns
a storage element.
template<typename T >
static base::ChannelElement<T>* RTT::internal::ConnFactory::buildDataStorage ( ConnPolicy const &  policy,
const T &  initial_value = T() 
)
inlinestatic

This method creates the connection element that will store data inside the connection, based on the given policy.

Todo:
: shouldn't this belong in the template type info ? This allows the type lib to choose which locked/lockfree algorithms are implemented and leaves out 4x code generation for each alternative in each compilation unit.

Contra: needs T in typelib.

Todo:
: since setDataSample, initial_value is no longer needed.

Definition at line 157 of file ConnFactory.hpp.

References RTT::ConnPolicy::BUFFER, RTT::ConnPolicy::CIRCULAR_BUFFER, RTT::ConnPolicy::DATA, RTT::ConnPolicy::LOCK_FREE, RTT::ConnPolicy::lock_policy, RTT::ConnPolicy::LOCKED, RTT::ConnPolicy::size, RTT::ConnPolicy::type, RTT::ConnPolicy::UNSYNC, and RTT::Warning.

base::ChannelElementBase::shared_ptr RTT::internal::ConnFactory::buildRemoteChannelOutput ( base::OutputPortInterface output_port,
base::InputPortInterface input_port,
ConnPolicy const &  policy 
)
staticprotected
virtual internal::SharedConnectionBase::shared_ptr RTT::internal::ConnFactory::buildSharedConnection ( base::OutputPortInterface output_port,
base::InputPortInterface input_port,
ConnPolicy const &  policy 
) const
pure virtual

Tries to find an existing or creates a new shared connection object for the given output port, input port and connection policy.

If an existing shared connection has been found, also checks if it matches the given policy and output an error otherwise. The input and output port arguments are optional and can be NULL pointers.

Parameters
output_portThe output port to connect the channel's input end to (optional).
input_portThe output port to connect the channel's output end to (optional).
policyDescribes the kind of storage requested by the user
Returns
a SharedConnectionBase element.

Referenced by RTT::types::TemplateConnFactory< bool >::buildSharedConnection().

template<typename T >
static SharedConnectionBase::shared_ptr RTT::internal::ConnFactory::buildSharedConnection ( OutputPort< T > *  output_port,
base::InputPortInterface input_port,
ConnPolicy const &  policy 
)
inlinestatic

Tries to find an existing or creates a new shared connection object for the given output port, input port and connection policy.

If an existing shared connection has been found, also checks if it matches the given policy and output an error otherwise. The input and output port arguments are optional and can be NULL pointers.

Parameters
output_portThe output port to connect the channel's input end to (optional).
input_portThe output port to connect the channel's output end to (optional).
policyDescribes the kind of storage requested by the user
Returns
a SharedConnectionBase element.

Definition at line 384 of file ConnFactory.hpp.

References RTT::base::ChannelElementBase::connectTo(), RTT::base::InputPortInterface::createConnection(), RTT::Error, RTT::OutputPort< T >::getLastWrittenValue(), RTT::base::PortInterface::getName(), RTT::base::PortInterface::isLocal(), and RTT::ConnPolicy::mandatory.

bool ConnFactory::createAndCheckConnection ( base::OutputPortInterface output_port,
base::InputPortInterface input_port,
base::ChannelElementBase::shared_ptr  channel_input,
base::ChannelElementBase::shared_ptr  channel_output,
ConnPolicy const &  policy 
)
staticprotected
bool ConnFactory::createAndCheckSharedConnection ( base::OutputPortInterface output_port,
base::InputPortInterface input_port,
SharedConnectionBase::shared_ptr  shared_connection,
ConnPolicy const &  policy 
)
static
base::ChannelElementBase::shared_ptr ConnFactory::createAndCheckStream ( base::OutputPortInterface output_port,
ConnPolicy const &  policy,
base::ChannelElementBase::shared_ptr  channel_input,
StreamConnID conn_id 
)
staticprotected
base::ChannelElementBase::shared_ptr ConnFactory::createAndCheckStream ( base::InputPortInterface input_port,
ConnPolicy const &  policy,
base::ChannelElementBase::shared_ptr  channel_output,
StreamConnID conn_id 
)
staticprotected
template<typename T >
static bool RTT::internal::ConnFactory::createConnection ( OutputPort< T > &  output_port,
base::InputPortInterface input_port,
ConnPolicy const &  policy 
)
inlinestatic

Creates a connection from a local output_port to a local or remote input_port.

This function contains all logic to decide on how connections must be created to local or remote input ports.

In order to set up out-of-band communication between input_port and output_port, use a different transport number in the policy parameter than the transport of the input port.

Definition at line 450 of file ConnFactory.hpp.

References RTT::ConnPolicy::buffer_policy, RTT::base::PortInterface::connectedTo(), RTT::Error, RTT::OutputPort< T >::getLastWrittenValue(), RTT::base::PortInterface::getName(), RTT::Info, RTT::base::PortInterface::isLocal(), RTT::Shared, and RTT::ConnPolicy::transport.

Referenced by RTT::OutputPort< T >::createConnection().

template<class T >
static bool RTT::internal::ConnFactory::createOutOfBandConnection ( OutputPort< T > &  output_port,
InputPort< T > &  input_port,
ConnPolicy const &  policy 
)
inlinestaticprotected

This code is for setting up an in-process out-of-band connection.

This means that both input and output port are present in the same process. This function is used when the policy dictates a transport protocol, but both ports are local.

Returns
true if the out-of-band connection was successfully setup.

Definition at line 568 of file ConnFactory.hpp.

References RTT::OutputPort< T >::getLastWrittenValue(), and RTT::ConnPolicy::name_id.

template<class T >
static bool RTT::internal::ConnFactory::createStream ( OutputPort< T > &  output_port,
ConnPolicy const &  policy 
)
inlinestatic

Creates, attaches and checks an outbound stream to an Output port.

Parameters
output_portThe port to connect the stream to.
policyThe policy dictating which transport to use.
Returns
true if the stream could be created and connected to output_port.

Definition at line 524 of file ConnFactory.hpp.

References RTT::ConnPolicy::name_id.

Referenced by RTT::InputPort< T >::createStream(), and RTT::OutputPort< T >::createStream().

template<class T >
static bool RTT::internal::ConnFactory::createStream ( InputPort< T > &  input_port,
ConnPolicy const &  policy 
)
inlinestatic

Creates, attaches and checks an inbound stream to an Input port.

Parameters
input_portThe port to connect the stream to.
policyThe policy dictating which transport to use.
Returns
true if the stream could be created and connected to input_port.

Definition at line 541 of file ConnFactory.hpp.

References RTT::ConnPolicy::name_id.

bool ConnFactory::findSharedConnection ( base::OutputPortInterface output_port,
base::InputPortInterface input_port,
ConnPolicy const &  policy,
SharedConnectionBase::shared_ptr shared_connection 
)
static

Tries to find an existing or creates a new shared connection object for the given output port, input port and connection policy.

If an existing shared connection has been found, also checks if it matches the given policy and output an error otherwise. The input and output port arguments are optional and can be NULL pointers.

Parameters
output_portThe output port to connect the channel's input end to (optional).
input_portThe output port to connect the channel's output end to (optional).
policyDescribes the kind of storage requested by the user
shared_connectionA reference to a SharedConnectionBase pointer that will point to the found instance or an empty pointer, if either no connection has been found or the found connection was invalid for the given ports and policy.
Returns
true if an exiting SharedConnectionBase instance could be found.

Definition at line 262 of file ConnFactory.cpp.

References RTT::Error, RTT::base::PortInterface::getName(), RTT::base::PortInterface::getSharedConnection(), RTT::Info, and RTT::ConnPolicy::name_id.

Referenced by RTT::corba::CDataFlowInterface_i::deregisterChannel().

virtual base::InputPortInterface* RTT::internal::ConnFactory::inputPort ( std::string const &  name) const
pure virtual

Returns a new InputPort<T> object where T is the type represented by this TypeInfo object.

virtual base::OutputPortInterface* RTT::internal::ConnFactory::outputPort ( std::string const &  name) const
pure virtual

Returns a new OutputPort<T> object where T is the type represented by this TypeInfo object.


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