11 #ifndef _LIBALCOMMON_ALCOMMON_ALBROKER_H_
12 #define _LIBALCOMMON_ALCOMMON_ALBROKER_H_
20 # include <boost/shared_ptr.hpp>
21 # include <boost/smart_ptr/enable_shared_from_this.hpp>
22 # include <boost/noncopyable.hpp>
24 # include <qi/macro.hpp>
26 # define BROKERMASK_KEEPALIVE 1
27 # define BROKERMASK_LIGHT 2
28 # define BROKERMASK_NOSERVER 4
29 # define BROKERMASK_NOHEARTBEAT 8
30 # define BROKERMASK_WITHALNETWORK 16
70 class ALBroker :
public ::boost::enable_shared_from_this<ALBroker>,
public ::boost::noncopyable
78 typedef boost::shared_ptr<ALBroker>
Ptr;
84 typedef boost::weak_ptr<ALBroker>
WeakPtr;
90 boost::shared_ptr<ALBroker> getThis();
95 boost::shared_ptr<const ALBroker> getThis()
const;
111 void setBrokerManagerInstance(boost::shared_ptr<ALBrokerManager> pBrokerManager);
118 boost::shared_ptr<ALModuleCore> getModuleByName(
const std::string &pModuleName);
135 int registerModule(boost::shared_ptr<ALModuleCore> pModule);
145 int unregisterModule(
const std::string &pModuleName);
153 bool isModulePresent(
const std::string &pModuleName);
160 int getModuleList(boost::shared_ptr<std::vector<ALModuleInfo> > pModuleList);
167 int getBrokerList(std::vector<ALModuleInfo> &pBrokerList);
174 int getGlobalModuleList(boost::shared_ptr<std::vector<ALModuleInfo> > pModuleList);
181 bool isExiting()
const;
193 std::string getName()
const;
199 std::string getIP()
const;
210 std::string getParentIP();
223 boost::shared_ptr<ALProxy> getProxy(
const std::string &pProxyName,
int pProxyOption = 0);
230 const std::string httpGet(
const std::string &pPath);
233 template <
typename T>
234 boost::shared_ptr<T> getSpecialisedProxy(
const std::string &name = std::string()) {
236 return boost::shared_ptr<T>(
new T(getThis()));
238 return boost::shared_ptr<T>(
new T(getProxy(name)));
248 #define getMemoryProxy() getSpecialisedProxy<AL::ALMemoryProxy>("ALMemory")
257 #define getLedsProxy() getSpecialisedProxy<AL::ALLedsProxy>("ALLeds")
266 #define getLoggerProxy() getSpecialisedProxy<AL::ALLoggerProxy>("ALLogger")
275 #define getMotionProxy() getSpecialisedProxy<AL::ALMotionProxy>("ALMotion")
284 #define getPreferencesProxy() getSpecialisedProxy<AL::ALPreferencesProxy>("ALPreferences")
293 #define getDcmProxy() getSpecialisedProxy<AL::DCMProxy>("DCM")
308 static boost::shared_ptr<ALBroker> createBroker(
const std::string &pName,
309 const std::string &pIP,
311 const std::string &pParentIP,
314 std::string pPath =
"",
315 bool pLoadLib =
true);
329 #endif // _LIBALCOMMON_ALCOMMON_ALBROKER_H_