RSB  0.19.0
rsb::transport::socket::Factory Class Reference

The singleton instance of this class is responsible for managing bus provider objects. More...

#include <Factory.h>

Collaboration diagram for rsb::transport::socket::Factory:
Collaboration graph

Public Member Functions

 Factory ()
 
 ~Factory ()
 
BusPtr getBus (const Server &serverMode, const std::string &host, const boost::uint16_t &port, bool tcpnodelay)
 Returns either a BusClient or Server depending on the chosen serverMode and the existence of a server in the current process. More...
 

Private Types

typedef std::pair< std::string, boost::uint16_t > Endpoint
 
typedef boost::shared_ptr< boost::asio::ip::tcp::socket > SocketPtr
 
typedef boost::shared_ptr< boost::asio::io_service::work > WorkPtr
 
typedef std::map< Endpoint, boost::weak_ptr< Bus > > BusClientMap
 
typedef std::map< Endpoint, boost::weak_ptr< BusServer > > BusServerMap
 

Private Member Functions

BusPtr getBusClientFor (const std::string &host, boost::uint16_t port, bool tcpnodelay)
 
BusServerPtr getBusServerFor (const std::string &host, boost::uint16_t port, bool tcpnodelay)
 
template<class BusType >
boost::shared_ptr< BusType > searchInMap (const Endpoint &endpoint, bool tcpnodelay, std::map< Endpoint, boost::weak_ptr< BusType > > &map)
 Searches inside a given map for an active pointer to a Bus instance matching the given query. More...
 

Static Private Member Functions

static void checkOptions (BusPtr bus, bool tcpnodelay)
 

Private Attributes

rsc::logging::LoggerPtr logger
 
BusClientMap busClients
 
BusServerMap busServers
 
boost::mutex busMutex
 
AsioServiceContextPtr asioService
 

Detailed Description

The singleton instance of this class is responsible for managing bus provider objects.

For each endpoint (i.e. address and port), at most one client or server bus provider can exist.

Attention
This class is not thread safe and needs to be accessed in a synchronized manner, except for getBus.
Author
jmoringe

Definition at line 62 of file Factory.h.

Member Typedef Documentation

typedef std::map<Endpoint, boost::weak_ptr<Bus> > rsb::transport::socket::Factory::BusClientMap
private

Definition at line 82 of file Factory.h.

typedef std::map<Endpoint, boost::weak_ptr<BusServer> > rsb::transport::socket::Factory::BusServerMap
private

Definition at line 83 of file Factory.h.

typedef std::pair<std::string, boost::uint16_t> rsb::transport::socket::Factory::Endpoint
private

Definition at line 77 of file Factory.h.

typedef boost::shared_ptr<boost::asio::ip::tcp::socket> rsb::transport::socket::Factory::SocketPtr
private

Definition at line 78 of file Factory.h.

typedef boost::shared_ptr<boost::asio::io_service::work> rsb::transport::socket::Factory::WorkPtr
private

Definition at line 80 of file Factory.h.

Constructor & Destructor Documentation

rsb::transport::socket::Factory::Factory ( )

Definition at line 56 of file Factory.cpp.

References logger.

rsb::transport::socket::Factory::~Factory ( )

Definition at line 62 of file Factory.cpp.

References logger.

Member Function Documentation

void rsb::transport::socket::Factory::checkOptions ( BusPtr  bus,
bool  tcpnodelay 
)
staticprivate

Definition at line 218 of file Factory.cpp.

Referenced by searchInMap().

Here is the caller graph for this function:

BusPtr rsb::transport::socket::Factory::getBus ( const Server serverMode,
const std::string &  host,
const boost::uint16_t &  port,
bool  tcpnodelay 
)

Returns either a BusClient or Server depending on the chosen serverMode and the existence of a server in the current process.

Definition at line 191 of file Factory.cpp.

References busMutex, getBusClientFor(), getBusServerFor(), logger, rsb::transport::socket::SERVER_AUTO, rsb::transport::socket::SERVER_NO, and rsb::transport::socket::SERVER_YES.

Here is the call graph for this function:

BusPtr rsb::transport::socket::Factory::getBusClientFor ( const std::string &  host,
boost::uint16_t  port,
bool  tcpnodelay 
)
private

Definition at line 85 of file Factory.cpp.

References asioService, busClients, logger, and searchInMap().

Referenced by getBus().

Here is the call graph for this function:

Here is the caller graph for this function:

BusServerPtr rsb::transport::socket::Factory::getBusServerFor ( const std::string &  host,
boost::uint16_t  port,
bool  tcpnodelay 
)
private

Definition at line 161 of file Factory.cpp.

References asioService, busServers, logger, and searchInMap().

Referenced by getBus().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class BusType >
boost::shared_ptr< BusType > rsb::transport::socket::Factory::searchInMap ( const Endpoint endpoint,
bool  tcpnodelay,
std::map< Endpoint, boost::weak_ptr< BusType > > &  map 
)
private

Searches inside a given map for an active pointer to a Bus instance matching the given query.

Definition at line 67 of file Factory.cpp.

References checkOptions(), and logger.

Referenced by getBusClientFor(), and getBusServerFor().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

AsioServiceContextPtr rsb::transport::socket::Factory::asioService
private

Definition at line 91 of file Factory.h.

Referenced by getBusClientFor(), and getBusServerFor().

BusClientMap rsb::transport::socket::Factory::busClients
private

Definition at line 87 of file Factory.h.

Referenced by getBusClientFor().

boost::mutex rsb::transport::socket::Factory::busMutex
private

Definition at line 89 of file Factory.h.

Referenced by getBus().

BusServerMap rsb::transport::socket::Factory::busServers
private

Definition at line 88 of file Factory.h.

Referenced by getBusServerFor().

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

Definition at line 85 of file Factory.h.

Referenced by Factory(), getBus(), getBusClientFor(), getBusServerFor(), searchInMap(), and ~Factory().


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