fipa_services
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
fipa::services::transports::Transport Class Reference

Connection management base class. More...

#include <Transport.hpp>

Inheritance diagram for fipa::services::transports::Transport:
fipa::services::transports::tcp::TCPTransport fipa::services::transports::udt::UDTTransport

Public Types

enum  Type { UNKNOWN = 0x00, UDT = 0x01, TCP = 0x02, ALL = 0xFF }
 Builtin transport types that can be activated. More...
 
typedef boost::shared_ptr< TransportPtr
 

Public Member Functions

virtual ~Transport ()
 
void registerObserver (TransportObserver observer)
 
Type getType () const
 
std::string getName () const
 
void send (const std::string &receiverName, const Address &address, const std::string &data)
 
std::set< AddressgetAddresses () const
 
virtual Address getAddress (const std::string &interface="eth0") const
 
virtual OutgoingConnection::Ptr establishOutgoingConnection (const Address &address)
 
virtual void start ()
 
virtual void update (bool readAllMessages=true)
 
OutgoingConnection::Ptr getCachedOutgoingConnection (const std::string &receiverName, const Address &address)
 
void cleanup (const std::string &receiver)
 
void notify (const std::string &message)
 
void setConfiguration (const Configuration &configuration)
 
const ConfigurationgetConfiguration () const
 

Static Public Member Functions

static Transport::Ptr create (Type type)
 
static Type getTypeFromTxt (const std::string &typeTxt)
 
static std::string getLocalIPv4Address (const std::string &interfaceName="eth0")
 

Static Public Attributes

static std::map< Type, std::string > TypeTxt
 

Protected Member Functions

 Transport (Type type)
 
 Transport (const Configuration &configuration)
 

Protected Attributes

Configuration mConfiguration
 

Detailed Description

Connection management base class.

Member Typedef Documentation

Member Enumeration Documentation

Builtin transport types that can be activated.

Enumerator
UNKNOWN 
UDT 
TCP 
ALL 

Constructor & Destructor Documentation

fipa::services::transports::Transport::Transport ( Type  type)
protected
fipa::services::transports::Transport::Transport ( const Configuration configuration)
protected
virtual fipa::services::transports::Transport::~Transport ( )
inlinevirtual

Member Function Documentation

void fipa::services::transports::Transport::cleanup ( const std::string &  receiver)

Cleanup the receiver from the outgoing connection list

Transport::Ptr fipa::services::transports::Transport::create ( Type  type)
static

Create a transport of the given type

Returns
TransportType
virtual OutgoingConnection::Ptr fipa::services::transports::Transport::establishOutgoingConnection ( const Address address)
inlinevirtual

Establish outgoing connection This has to be implement by specific transport

Reimplemented in fipa::services::transports::udt::UDTTransport, and fipa::services::transports::tcp::TCPTransport.

virtual Address fipa::services::transports::Transport::getAddress ( const std::string &  interface = "eth0") const
inlinevirtual

Get address for this transport and for the given interface

Returns
address of this transport for a given interface

Reimplemented in fipa::services::transports::udt::UDTTransport, and fipa::services::transports::tcp::TCPTransport.

std::set< Address > fipa::services::transports::Transport::getAddresses ( ) const

Get addresses for this transport for all available interfaces

Returns
addresses of this transport for all available interfaces
OutgoingConnection::Ptr fipa::services::transports::Transport::getCachedOutgoingConnection ( const std::string &  receiverName,
const Address address 
)

Retrieve and outgoing connection from cache

Parameters
receiverNameName of the receiver
addressAddress that should correspond to the receiver
Returns
NULL if connection does not exist or is invalid (e.g. when addresses are different)
const Configuration& fipa::services::transports::Transport::getConfiguration ( ) const
inline

Return the transport configuration

std::string fipa::services::transports::Transport::getLocalIPv4Address ( const std::string &  interfaceName = "eth0")
static

Get local IPv4 address for a given interface

Parameters
interfaceNamename of the interface, default is eth0
Returns
address as a string
std::string fipa::services::transports::Transport::getName ( ) const
inline

Get transport name

Type fipa::services::transports::Transport::getType ( ) const
inline

Get the type of this transport

Returns
type of this transport
Transport::Type fipa::services::transports::Transport::getTypeFromTxt ( const std::string &  typeTxt)
static

Retrieve the type for a given string

void fipa::services::transports::Transport::notify ( const std::string &  message)

Trigger callbacks upon a newly arrived message

void fipa::services::transports::Transport::registerObserver ( TransportObserver  observer)

Register a callback function that is called via notify when new data arrives

void fipa::services::transports::Transport::send ( const std::string &  receiverName,
const Address address,
const std::string &  data 
)

Send the encoded data

Parameters
receiverNamename of the receiver to which the data should be sent
addressAddress to which the data should be sent
dataData that should be send to the receiver
Exceptions
std::runtime_errorif sending failed

Send letter according to this transport

void fipa::services::transports::Transport::setConfiguration ( const Configuration configuration)
inline

Set the transport configuration

virtual void fipa::services::transports::Transport::start ( )
inlinevirtual

Start transport functionality, e.g. listen socket etc.

Reimplemented in fipa::services::transports::udt::UDTTransport, and fipa::services::transports::tcp::TCPTransport.

virtual void fipa::services::transports::Transport::update ( bool  readAllMessages = true)
inlinevirtual

Update transport, e.g. accept new connections and read existing

Reimplemented in fipa::services::transports::udt::UDTTransport, and fipa::services::transports::tcp::TCPTransport.

Member Data Documentation

Configuration fipa::services::transports::Transport::mConfiguration
protected
std::map< Transport::Type, std::string > fipa::services::transports::Transport::TypeTxt
static
Initial value:
= boost::assign::map_list_of
(Transport::UNKNOWN, "UNKNOWN")
(Transport::UDT, "UDT")
(Transport::TCP, "TCP")
(Transport::ALL, "ALL")

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