libalcommon  1.14
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes
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>

List of all members.

Public Types

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

Public Member Functions

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

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.

Public Attributes

boost::weak_ptr< ALBrokerManagerfBrokerManager
ALBrokerImpl * _private

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 70 of file albroker.h.


Member Typedef Documentation

Shared pointer to ALBroker.

Deprecated:
Use boost::shared_ptr<ALBroker> instead

Definition at line 78 of file albroker.h.

Weak pointer to ALBroker.

Deprecated:
Use boost::weak_ptr<ALBroker> instead

Definition at line 84 of file albroker.h.


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
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.
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  pProxyOption = 0 
)

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

Parameters:
pProxyNameproxy's name
pProxyOptionoption for new proxy
Returns:
ALProxy.
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
const std::string AL::ALBroker::httpGet ( const std::string &  pPath)

Call for http get request on server.

Parameters:
pPathThe path requested by the sender
Returns:
http address.
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.
int AL::ALBroker::registerModule ( boost::shared_ptr< ALModuleCore pModule)

Give to naoqi all the information a module will need to get constructed.

It should be called upon module declaration.

Parameters:
pModuleinformation about the module the struct al__moduleInfo is defined with these members:
  • [string] name
  • [string] IP address
  • [int] architecture (see ALTypes.h)
  • [int] port
  • [int] Process ID
  • [int] module pointer
Returns:
0 on success
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

ALBrokerImpl* AL::ALBroker::_private

Private implementation of ALBroker.

Definition at line 322 of file albroker.h.

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

Pointer on ALBrokerManager.

Definition at line 319 of file albroker.h.


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