RSB  0.15.1
rsb::transport::socket::Bus Class Reference

Instances of this class provide access to a socket-based bus. More...

#include <Bus.h>

Inheritance diagram for rsb::transport::socket::Bus:
Inheritance graph
Collaboration diagram for rsb::transport::socket::Bus:
Collaboration graph

Public Member Functions

 Bus (AsioServiceContextPtr asioService, bool tcpnodelay=false)
 
virtual ~Bus ()
 
virtual void addSink (InConnectorPtr sink)
 
virtual void removeSink (InConnector *sink)
 
virtual void addConnection (BusConnectionPtr connection)
 Adds connection to the list of connections of the bus. More...
 
virtual void removeConnection (BusConnectionPtr connection)
 Removes connection from the list of connections of this bus. More...
 
virtual bool isTcpnodelay () const
 
virtual void handle (EventPtr event)
 Handle event. More...
 
virtual AsioServiceContextPtr getService () const
 
virtual void printContents (std::ostream &stream) const
 
virtual const std::string getTransportURL () const
 
- Public Member Functions inherited from rsb::eventprocessing::Handler
virtual ~Handler ()
 

Protected Types

typedef std::list< BusConnectionPtrConnectionList
 

Protected Member Functions

ConnectionList getConnections () const
 
boost::recursive_mutex & getConnectionLock ()
 
virtual void handleIncoming (EventPtr event, BusConnectionPtr connection)
 

Private Types

typedef std::list< boost::weak_ptr< InConnector > > SinkList
 
typedef std::map< Scope, SinkListSinkMap
 

Private Attributes

rsc::logging::LoggerPtr logger
 
AsioServiceContextPtr asioService
 
ConnectionList connections
 
boost::recursive_mutex connectionLock
 
SinkMap sinks
 
boost::recursive_mutex connectorLock
 
bool tcpnodelay
 

Friends

class BusConnection
 

Detailed Description

Instances of this class provide access to a socket-based bus.

It is transparent for clients (connectors) of this class whether is accessed by running the bus server or by connecting to the bus server as a client.

In-direction connectors add themselves as event sinks using the addSink method.

Out-direction connectors submit events to the bus using the handle method.

Author
jmoringe

Definition at line 75 of file Bus.h.

Member Typedef Documentation

Definition at line 113 of file Bus.h.

typedef std::list<boost::weak_ptr<InConnector> > rsb::transport::socket::Bus::SinkList
private

Definition at line 122 of file Bus.h.

Definition at line 123 of file Bus.h.

Constructor & Destructor Documentation

rsb::transport::socket::Bus::Bus ( AsioServiceContextPtr  asioService,
bool  tcpnodelay = false 
)

Definition at line 52 of file Bus.cpp.

rsb::transport::socket::Bus::~Bus ( )
virtual

Definition at line 57 of file Bus.cpp.

References connections, logger, and sinks.

Member Function Documentation

void rsb::transport::socket::Bus::addConnection ( BusConnectionPtr  connection)
virtual

Adds connection to the list of connections of the bus.

connection should start receiving events, only after being added to the bus.

Parameters
connectionThe connection that should be added.

Reimplemented in rsb::transport::socket::LifecycledBusServer.

Definition at line 134 of file Bus.cpp.

References connectionLock, connections, and logger.

Referenced by rsb::transport::socket::BusServerImpl::handleAccept().

Here is the caller graph for this function:

void rsb::transport::socket::Bus::addSink ( InConnectorPtr  sink)
virtual

Reimplemented in rsb::transport::socket::LifecycledBusServer.

Definition at line 96 of file Bus.cpp.

References connectorLock, logger, and sinks.

boost::recursive_mutex & rsb::transport::socket::Bus::getConnectionLock ( )
protected

Definition at line 92 of file Bus.cpp.

References connectionLock.

Referenced by rsb::transport::socket::BusServerImpl::handleIncoming().

Here is the caller graph for this function:

Bus::ConnectionList rsb::transport::socket::Bus::getConnections ( ) const
protected

Definition at line 88 of file Bus.cpp.

References connections.

Referenced by rsb::transport::socket::BusServerImpl::handleIncoming().

Here is the caller graph for this function:

AsioServiceContextPtr rsb::transport::socket::Bus::getService ( ) const
virtual

Reimplemented in rsb::transport::socket::LifecycledBusServer.

Definition at line 80 of file Bus.cpp.

References asioService.

Referenced by rsb::transport::socket::BusServerImpl::acceptOne().

Here is the caller graph for this function:

const std::string rsb::transport::socket::Bus::getTransportURL ( ) const
virtual

Reimplemented in rsb::transport::socket::BusServerImpl, and rsb::transport::socket::LifecycledBusServer.

Definition at line 239 of file Bus.cpp.

References connections.

void rsb::transport::socket::Bus::handle ( EventPtr  event)
virtual

Handle event.

Parameters
eventThe event that should be handled.

Implements rsb::eventprocessing::Handler.

Reimplemented in rsb::transport::socket::LifecycledBusServer.

Definition at line 178 of file Bus.cpp.

References connectionLock, connections, connectorLock, logger, removeConnection(), and sinks.

Here is the call graph for this function:

void rsb::transport::socket::Bus::handleIncoming ( EventPtr  event,
BusConnectionPtr  connection 
)
protectedvirtual

Reimplemented in rsb::transport::socket::BusServerImpl, rsb::transport::socket::LifecycledBusServer, and rsb::transport::socket::BusServer.

Definition at line 150 of file Bus.cpp.

References connectorLock, logger, and sinks.

Referenced by rsb::transport::socket::BusServerImpl::handleIncoming().

Here is the caller graph for this function:

bool rsb::transport::socket::Bus::isTcpnodelay ( ) const
virtual

Reimplemented in rsb::transport::socket::LifecycledBusServer.

Definition at line 84 of file Bus.cpp.

References tcpnodelay.

Referenced by rsb::transport::socket::BusServerImpl::handleAccept().

Here is the caller graph for this function:

void rsb::transport::socket::Bus::printContents ( std::ostream &  stream) const
virtual

Reimplemented in rsb::transport::socket::LifecycledBusServer.

Definition at line 234 of file Bus.cpp.

References connections, and sinks.

void rsb::transport::socket::Bus::removeConnection ( BusConnectionPtr  connection)
virtual

Removes connection from the list of connections of this bus.

connection is not closed or otherwise modified.

Parameters
connectionThe connection that should be removed.

Reimplemented in rsb::transport::socket::LifecycledBusServer.

Definition at line 142 of file Bus.cpp.

References connectionLock, connections, and logger.

Referenced by handle(), and rsb::transport::socket::BusServerImpl::handleIncoming().

Here is the caller graph for this function:

void rsb::transport::socket::Bus::removeSink ( InConnector sink)
virtual

Reimplemented in rsb::transport::socket::LifecycledBusServer.

Definition at line 105 of file Bus.cpp.

References connectorLock, rsb::transport::socket::ConnectorBase::getScope(), logger, and sinks.

Here is the call graph for this function:

Friends And Related Function Documentation

friend class BusConnection
friend

Definition at line 76 of file Bus.h.

Referenced by rsb::transport::socket::BusServerImpl::handleAccept().

Member Data Documentation

AsioServiceContextPtr rsb::transport::socket::Bus::asioService
private

Definition at line 129 of file Bus.h.

Referenced by getService().

boost::recursive_mutex rsb::transport::socket::Bus::connectionLock
private

Definition at line 132 of file Bus.h.

Referenced by addConnection(), getConnectionLock(), handle(), and removeConnection().

ConnectionList rsb::transport::socket::Bus::connections
private
boost::recursive_mutex rsb::transport::socket::Bus::connectorLock
private

Definition at line 135 of file Bus.h.

Referenced by addSink(), handle(), handleIncoming(), and removeSink().

rsc::logging::LoggerPtr rsb::transport::socket::Bus::logger
private

Definition at line 125 of file Bus.h.

Referenced by addConnection(), addSink(), handle(), handleIncoming(), removeConnection(), removeSink(), and ~Bus().

SinkMap rsb::transport::socket::Bus::sinks
private

Definition at line 134 of file Bus.h.

Referenced by addSink(), handle(), handleIncoming(), printContents(), removeSink(), and ~Bus().

bool rsb::transport::socket::Bus::tcpnodelay
private

Definition at line 137 of file Bus.h.

Referenced by isTcpnodelay().


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