libalcommon  2.5.7.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
AL::ALBroker Class Reference

ALBroker serves methods advertised by connected modules to clients participating in the network. All executables create at least one broker in main.cpp. A broker will wait for http request, remote C++ request from PC application... More...

#include "alcommon/albroker.h"

Public Types

typedef boost::shared_ptr
< ALBroker
Ptr
 Shared pointer to ALBroker. More...
 
typedef boost::weak_ptr< ALBrokerWeakPtr
 Weak pointer to ALBroker. More...
 

Public Member Functions

boost::shared_ptr< ALBrokergetThis ()
 Getter to this. More...
 
boost::shared_ptr< const ALBrokergetThis () const
 Getter to this. More...
 
 ALBroker ()
 Default Constructor. More...
 
virtual ~ALBroker (void)
 Destructor. More...
 
void setBrokerManagerInstance (boost::shared_ptr< ALBrokerManager > pBrokerManager)
 Sets the brokerManager instance. More...
 
boost::shared_ptr< ALModuleCoregetModuleByName (const std::string &pModuleName)
 Another way to get module by name. More...
 
int unregisterModule (const std::string &pModuleName)
 Called when a module, belonging to this broker, quits. More...
 
bool isModulePresent (const std::string &pModuleName)
 Call to know if a module is present. More...
 
int getModuleList (boost::shared_ptr< std::vector< ALModuleInfo > > pModuleList)
 Return the registered module list. More...
 
int getBrokerList (std::vector< ALModuleInfo > &pBrokerList)
 Return the list of registered Brokers. More...
 
int getGlobalModuleList (boost::shared_ptr< std::vector< ALModuleInfo > > pModuleList)
 Return the registered module list in every broker (global). More...
 
bool isExiting () const
 Check if the application is existing. More...
 
bool isConnected ()
 Return whether the broker is connected or not. More...
 
int shutdown ()
 shutdown, close all modules and send exit command to child broker. More...
 
std::string getName () const
 Get the name of the broker. More...
 
std::string getIP () const
 Get the IP address of the broker. More...
 
int getPort () const
 fBorkerPort getter. More...
 
std::string getParentIP () const
 Return the parent IP if any. More...
 
int getParentPort () const
 Return the parent Port if any. More...
 
boost::shared_ptr< ALProxygetProxy (const std::string &pProxyName, int deprecated=0)
 Get an existing proxy if it exists, create a proxy with option otherwise. More...
 
template<typename T >
boost::shared_ptr< T > getSpecialisedProxy (const std::string &name=std::string())
 
qi::SessionPtr session ()
 

Static Public Member Functions

static boost::shared_ptr
< ALBroker
createBroker (const std::string &pName, const std::string &pIP, int pPort, const std::string &pParentIP, int pParentPort, int pKeepAlive=0, std::string pPath="", bool pLoadLib=true)
 CreateBroker helps to broker creation. More...
 
static boost::shared_ptr
< ALBroker
createBroker (const std::string &name, qi::SessionPtr session)
 

Public Attributes

boost::weak_ptr< ALBrokerManagerfBrokerManager
 
ALBrokerPrivate * _p
 

Detailed Description

ALBroker serves methods advertised by connected modules to clients participating in the network. All executables create at least one broker in main.cpp. A broker will wait for http request, remote C++ request from PC application...

Brokers can be connected to each other to form a tree where each broker has parent broker until the base of the tree. Typically there is one broker for each process and any number of attached modules, each with any number of advertised methods.

Brokers transparently handle directory services so that clients need not know if the module that provides a service is in the same process, on the same machine, or on the same tcp network.

Within the same process, direct method calls are used to provide optimal speed without having to change your method signatures.

Remote communication is currently handled by SOAP

In most practical usage, you will never need to explicitly create a broker. The main NAOqi process has one, and module that is compiled as 'remote' and that uses ALToolsMain, will create a broker for you if required.

Definition at line 73 of file albroker.h.

Member Typedef Documentation

Shared pointer to ALBroker.

Deprecated:
Use boost::shared_ptr<ALBroker> instead

Definition at line 81 of file albroker.h.

Weak pointer to ALBroker.

Deprecated:
Use boost::weak_ptr<ALBroker> instead

Definition at line 87 of file albroker.h.

Constructor & Destructor Documentation

AL::ALBroker::ALBroker ( )

Default Constructor.

virtual AL::ALBroker::~ALBroker ( void  )
virtual

Destructor.

Member Function Documentation

static boost::shared_ptr<ALBroker> AL::ALBroker::createBroker ( const std::string &  pName,
const std::string &  pIP,
int  pPort,
const std::string &  pParentIP,
int  pParentPort,
int  pKeepAlive = 0,
std::string  pPath = "",
bool  pLoadLib = true 
)
static

CreateBroker helps to broker creation.

Parameters
pNamebroker name
pIPbroker IP
pPortbroker port
pParentIPparent broker IP
pParentPortparent broker port
pKeepAlivetrue => broker will not be destroyed if parent broker is destroyed
pPathdeprecated, do not use, will have no effect
pLoadLibboolean to know if the module is loaded
Returns
pointer on broker
static boost::shared_ptr<ALBroker> AL::ALBroker::createBroker ( const std::string &  name,
qi::SessionPtr  session 
)
static
int AL::ALBroker::getBrokerList ( std::vector< ALModuleInfo > &  pBrokerList)

Return the list of registered Brokers.

Parameters
pBrokerList[out] list of Broker information
Returns
0 on success
int AL::ALBroker::getGlobalModuleList ( boost::shared_ptr< std::vector< ALModuleInfo > >  pModuleList)

Return the registered module list in every broker (global).

Parameters
pModuleListlist of module information
Returns
0 on success
std::string AL::ALBroker::getIP ( ) const

Get the IP address of the broker.

Returns
A string containing the broker IP.
boost::shared_ptr<ALModuleCore> AL::ALBroker::getModuleByName ( const std::string &  pModuleName)

Another way to get module by name.

Parameters
pModuleNamename of the module
Returns
A pointer to the module.
int AL::ALBroker::getModuleList ( boost::shared_ptr< std::vector< ALModuleInfo > >  pModuleList)

Return the registered module list.

Parameters
pModuleListlist of module information
Returns
0 on success
std::string AL::ALBroker::getName ( ) const

Get the name of the broker.

Returns
A string containing the module name.
std::string AL::ALBroker::getParentIP ( ) const

Return the parent IP if any.

int AL::ALBroker::getParentPort ( ) const

Return the parent Port if any.

int AL::ALBroker::getPort ( ) const

fBorkerPort getter.

Returns
A integer contain broker port.
boost::shared_ptr<ALProxy> AL::ALBroker::getProxy ( const std::string &  pProxyName,
int  deprecated = 0 
)

Get an existing proxy if it exists, create a proxy with option otherwise.

Parameters
pProxyNameproxy's name
[in]deprecateddeprecated option for the new proxy.
Returns
ALProxy.
template<typename T >
boost::shared_ptr<T> AL::ALBroker::getSpecialisedProxy ( const std::string &  name = std::string())
inline

Definition at line 218 of file albroker.h.

boost::shared_ptr<ALBroker> AL::ALBroker::getThis ( )

Getter to this.

Returns
A pointer to this
boost::shared_ptr<const ALBroker> AL::ALBroker::getThis ( ) const

Getter to this.

Returns
A const pointer to this
bool AL::ALBroker::isConnected ( )

Return whether the broker is connected or not.

Returns
true if connected
bool AL::ALBroker::isExiting ( ) const

Check if the application is existing.

Returns
true if application is exiting, false otherwise.
bool AL::ALBroker::isModulePresent ( const std::string &  pModuleName)

Call to know if a module is present.

Parameters
pModuleNamename of the module to search
Returns
true if the module is local or if the module is present in a broker connected.
qi::SessionPtr AL::ALBroker::session ( )
void AL::ALBroker::setBrokerManagerInstance ( boost::shared_ptr< ALBrokerManager pBrokerManager)

Sets the brokerManager instance.

Parameters
pBrokerManagerA pointer to the broker manager.
int AL::ALBroker::shutdown ( )

shutdown, close all modules and send exit command to child broker.

Returns
0 on succes
int AL::ALBroker::unregisterModule ( const std::string &  pModuleName)

Called when a module, belonging to this broker, quits.

References to the module (proxies, subscriptions to ALMemory, ...) will be deleted

Parameters
pModuleNamename of the module exiting
Returns
0 on success

Member Data Documentation

ALBrokerPrivate* AL::ALBroker::_p

Private implementation of ALBroker.

Definition at line 309 of file albroker.h.

boost::weak_ptr<ALBrokerManager> AL::ALBroker::fBrokerManager

for compat only, useless

Definition at line 306 of file albroker.h.


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