Robot Raconteur Core C++ Library
Client.h
Go to the documentation of this file.
1 
24 #pragma once
25 
31 #include <boost/atomic.hpp>
32 #include <set>
33 
34 #pragma warning(push)
35 #pragma warning(disable : 4996)
36 #include <boost/signals2.hpp>
37 
38 namespace RobotRaconteur
39 {
40 class ROBOTRACONTEUR_CORE_API ClientContext;
41 class ROBOTRACONTEUR_CORE_API PipeClientBase;
42 class ROBOTRACONTEUR_CORE_API WireClientBase;
43 
44 class ROBOTRACONTEUR_CORE_API ServiceStub : public virtual RRObject, public RR_ENABLE_SHARED_FROM_THIS<ServiceStub>
45 {
46 
47  public:
48  ServiceStub(boost::string_ref path, const RR_SHARED_PTR<ClientContext>& c);
49 
50  std::string ServicePath;
51 
52  RR_WEAK_PTR<ClientContext> context;
53 
54  uint32_t RREndpoint;
55 
56  RR_SHARED_PTR<boost::recursive_mutex> RRMutex;
57 
58  RR_SHARED_PTR<ClientContext> GetContext();
59 
60  RR_INTRUSIVE_PTR<MessageEntry> ProcessRequest(const RR_INTRUSIVE_PTR<MessageEntry>& m);
61 
62  void AsyncProcessRequest(const RR_INTRUSIVE_PTR<MessageEntry>& m,
63  RR_MOVE_ARG(boost::function<void(const RR_INTRUSIVE_PTR<MessageEntry>&,
64  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
65  int32_t timeout = RR_TIMEOUT_INFINITE);
66 
67  virtual void DispatchEvent(const RR_INTRUSIVE_PTR<MessageEntry>& m) = 0;
68 
69  RR_SHARED_PTR<RRObject> FindObjRef(boost::string_ref n);
70 
71  void AsyncFindObjRef(boost::string_ref n,
72  RR_MOVE_ARG(boost::function<void(const RR_SHARED_PTR<RRObject>&,
73  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
74  int32_t timeout = RR_TIMEOUT_INFINITE);
75 
76  RR_SHARED_PTR<RRObject> FindObjRef(boost::string_ref n, boost::string_ref i);
77 
78  RR_SHARED_PTR<RRObject> FindObjRefTyped(boost::string_ref n, boost::string_ref objecttype);
79 
80  RR_SHARED_PTR<RRObject> FindObjRefTyped(boost::string_ref n, boost::string_ref i, boost::string_ref objecttype);
81 
82  void AsyncFindObjRef(boost::string_ref n, boost::string_ref i,
83  RR_MOVE_ARG(boost::function<void(const RR_SHARED_PTR<RRObject>&,
84  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
85  int32_t timeout = RR_TIMEOUT_INFINITE);
86 
87  void AsyncFindObjRefTyped(boost::string_ref n, boost::string_ref objecttype,
88  RR_MOVE_ARG(boost::function<void(const RR_SHARED_PTR<RRObject>&,
89  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
90  int32_t timeout = RR_TIMEOUT_INFINITE);
91 
92  void AsyncFindObjRefTyped(boost::string_ref n, boost::string_ref i, boost::string_ref objecttype,
93  RR_MOVE_ARG(boost::function<void(const RR_SHARED_PTR<RRObject>&,
94  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
95  int32_t timeout = RR_TIMEOUT_INFINITE);
96 
97  template <typename T>
98  static void EndAsyncFindObjRef(
99  const RR_SHARED_PTR<RRObject>& obj, const RR_SHARED_PTR<RobotRaconteurException>& err,
100  const boost::function<void(const RR_SHARED_PTR<T>&, const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
101 
102  std::string FindObjectType(boost::string_ref n);
103 
104  std::string FindObjectType(boost::string_ref n, boost::string_ref i);
105 
106  void AsyncFindObjectType(boost::string_ref n,
107  RR_MOVE_ARG(boost::function<void(const RR_SHARED_PTR<std::string>&,
108  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
109  int32_t timeout = RR_TIMEOUT_INFINITE);
110 
111  void AsyncFindObjectType(boost::string_ref n, boost::string_ref i,
112  RR_MOVE_ARG(boost::function<void(const RR_SHARED_PTR<std::string>&,
113  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
114  int32_t timeout = RR_TIMEOUT_INFINITE);
115 
116  void AsyncSendPipeMessage(const RR_INTRUSIVE_PTR<MessageEntry>& m, bool unreliable,
117  const boost::function<void(const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
118 
119  void SendWireMessage(const RR_INTRUSIVE_PTR<MessageEntry>& m);
120 
121  virtual void DispatchPipeMessage(const RR_INTRUSIVE_PTR<MessageEntry>& m);
122 
123  virtual void DispatchWireMessage(const RR_INTRUSIVE_PTR<MessageEntry>& m);
124 
125  virtual RR_INTRUSIVE_PTR<MessageEntry> CallbackCall(const RR_INTRUSIVE_PTR<MessageEntry>& m);
126 
127  RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.ServiceStub"; }
128 
129  virtual void RRClose();
130 
131  virtual void RRInitStub() = 0;
132 
133  virtual RR_SHARED_PTR<PipeClientBase> RRGetPipeClient(boost::string_ref membername);
134 
135  virtual RR_SHARED_PTR<WireClientBase> RRGetWireClient(boost::string_ref membername);
136 
137  RR_SHARED_PTR<RobotRaconteurNode> RRGetNode();
138  RR_WEAK_PTR<RobotRaconteurNode> RRGetNodeWeak();
139 
140  protected:
141  RR_WEAK_PTR<RobotRaconteurNode> node;
142 };
143 
144 struct ROBOTRACONTEUR_CORE_API PullServiceDefinitionReturn
145 {
146  RR_SHARED_PTR<ServiceDefinition> def;
147  RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> > attributes;
148  std::set<std::string> extra_imports;
149 };
150 
151 struct ROBOTRACONTEUR_CORE_API PullServiceDefinitionAndImportsReturn
152 {
153  std::vector<RR_SHARED_PTR<ServiceDefinition> > defs;
154  RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> > attributes;
155  std::set<std::string> extra_imports;
156 };
157 
158 class ROBOTRACONTEUR_CORE_API ClientContext : public Endpoint, public RR_ENABLE_SHARED_FROM_THIS<ClientContext>
159 {
160  protected:
161  RR_UNORDERED_MAP<MessageStringPtr, RR_SHARED_PTR<ServiceStub> > stubs;
162  boost::mutex stubs_lock;
163  std::list<std::string> active_stub_searches;
164  std::list<boost::tuple<std::string, boost::function<void(const RR_SHARED_PTR<RRObject>&,
165  const RR_SHARED_PTR<RobotRaconteurException>&)> > >
166  active_stub_searches_handlers;
167 
168  RR_SHARED_PTR<ServiceFactory> m_ServiceDef;
169 
170  public:
171  RR_SHARED_PTR<ServiceFactory> GetServiceDef() const;
172 
173  ClientContext(const RR_SHARED_PTR<RobotRaconteurNode>& node);
174 
175  ClientContext(const RR_SHARED_PTR<ServiceFactory>& service_def, const RR_SHARED_PTR<RobotRaconteurNode>& node);
176 
177  RR_SHARED_PTR<RRObject> FindObjRef(boost::string_ref path, boost::string_ref objecttype = "");
178 
179  void AsyncFindObjRef(boost::string_ref path, boost::string_ref objecttype2,
180  RR_MOVE_ARG(boost::function<void(const RR_SHARED_PTR<RRObject>&,
181  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
182  int32_t timeout = RR_TIMEOUT_INFINITE);
183 
184  template <typename T>
185  static void EndAsyncFindObjRef(
186  const RR_SHARED_PTR<RRObject>& obj, const RR_SHARED_PTR<RobotRaconteurException>& err,
187  const boost::function<void(const RR_SHARED_PTR<T>&, const RR_SHARED_PTR<RobotRaconteurException>&)>& handler)
188  {
189  if (err)
190  {
191  handler(RR_SHARED_PTR<T>(), err);
192  return;
193  }
194  else
195  {
196  RR_SHARED_PTR<T> castobj = RR_DYNAMIC_POINTER_CAST<T>(obj);
197  if (!castobj)
198  {
199  handler(RR_SHARED_PTR<T>(), RR_MAKE_SHARED<DataTypeMismatchException>("Invalid object type returned"));
200  return;
201  }
202  handler(castobj, RR_SHARED_PTR<RobotRaconteurException>());
203  }
204  }
205 
206  protected:
207  void AsyncFindObjRef1(const RR_INTRUSIVE_PTR<MessageEntry>& ret, const RR_SHARED_PTR<RobotRaconteurException>& err,
208  const std::string& path, const std::string& objecttype2,
209  const boost::function<void(const RR_SHARED_PTR<RRObject>&,
210  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler,
211  int32_t timeout);
212 
213  void AsyncFindObjRef2(const RR_SHARED_PTR<PullServiceDefinitionAndImportsReturn>& ret,
214  const RR_SHARED_PTR<RobotRaconteurException>& err, const std::string& objecttype,
215  const std::string& objectdef, const std::string& path, const std::string& objecttype2,
216  const boost::function<void(const RR_SHARED_PTR<RRObject>&,
217  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler,
218  int32_t timeout);
219 
220  void AsyncFindObjRef3(const RR_SHARED_PTR<RRObject>& ret, const RR_SHARED_PTR<RobotRaconteurException>& err,
221  const std::string& path,
222  const boost::function<void(const RR_SHARED_PTR<RRObject>&,
223  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
224 
225  public:
226  std::string FindObjectType(boost::string_ref path);
227 
228  void AsyncFindObjectType(boost::string_ref path,
229  RR_MOVE_ARG(boost::function<void(const RR_SHARED_PTR<std::string>&,
230  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
231  int32_t timeout = RR_TIMEOUT_INFINITE);
232 
233  bool VerifyObjectImplements(boost::string_ref objecttype, boost::string_ref implementstype);
234 
235  protected:
236  void AsyncFindObjectType1(const RR_INTRUSIVE_PTR<MessageEntry>& ret,
237  const RR_SHARED_PTR<RobotRaconteurException>& err, const std::string& path,
238  const boost::function<void(const RR_SHARED_PTR<std::string>&,
239  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
240 
241  private:
242  boost::mutex pulled_service_defs_lock;
243  std::map<std::string, RR_SHARED_PTR<ServiceDefinition> > pulled_service_defs;
244 
245  bool VerifyObjectImplements2(boost::string_ref objecttype, boost::string_ref implementstype);
246 
247  struct outstanding_request
248  {
249  RR_INTRUSIVE_PTR<MessageEntry> ret;
250  RR_SHARED_PTR<AutoResetEvent> evt;
251  boost::function<void(const RR_INTRUSIVE_PTR<MessageEntry>& ret, const RR_SHARED_PTR<RobotRaconteurException>&)>
252  handler;
253  RR_SHARED_PTR<Timer> timer;
254  };
255 
256  boost::mutex outstanding_requests_lock;
257  RR_UNORDERED_MAP<uint32_t, RR_SHARED_PTR<outstanding_request> > outstanding_requests;
258 
259  boost::mutex FindObjRef_lock;
260 
261  public:
262  RR_INTRUSIVE_PTR<MessageEntry> ProcessRequest(const RR_INTRUSIVE_PTR<MessageEntry>& m);
263 
264  void AsyncProcessRequest(const RR_INTRUSIVE_PTR<MessageEntry>& m,
265  RR_MOVE_ARG(boost::function<void(const RR_INTRUSIVE_PTR<MessageEntry>&,
266  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
267  int32_t timeout = RR_TIMEOUT_INFINITE);
268 
269  using Endpoint::SendMessage;
270  void SendMessage(const RR_INTRUSIVE_PTR<MessageEntry>& m);
271 
272  using Endpoint::AsyncSendMessage;
273  void AsyncSendMessage(const RR_INTRUSIVE_PTR<MessageEntry>& m,
274  const boost::function<void(const RR_SHARED_PTR<RobotRaconteurException>&)>& callback);
275 
276  private:
277  void AsyncProcessRequest_err(const RR_SHARED_PTR<RobotRaconteurException>& error, uint32_t requestid);
278 
279  void AsyncProcessRequest_timeout(const TimerEvent& error, uint32_t requestid);
280 
281  uint32_t request_number;
282 
283  RR_SHARED_PTR<Timer> connection_test_timer;
284 
285  void connection_test(const TimerEvent& ev);
286 
287  public:
288  RR_OVIRTUAL void MessageReceived(const RR_INTRUSIVE_PTR<Message>& m) RR_OVERRIDE;
289 
290  protected:
291  void MessageEntryReceived(const RR_INTRUSIVE_PTR<MessageEntry>& m);
292 
293  std::string m_ServiceName;
294 
295  public:
296  std::string GetServiceName() const;
297 
298  bool GetConnected() const;
299 
300  protected:
301  bool m_Connected;
302  boost::mutex m_Connected_lock;
303  boost::mutex close_lock;
304 
305  private:
306  RR_SHARED_PTR<Transport> connecttransport;
307  std::string connecturl;
308 
309  public:
310  std::map<std::string, RR_INTRUSIVE_PTR<RRValue> > GetAttributes();
311 
312  private:
313  std::map<std::string, RR_INTRUSIVE_PTR<RRValue> > m_Attributes;
314  boost::mutex m_Attributes_lock;
315 
316  public:
317  RR_SHARED_PTR<RRObject> ConnectService(const RR_SHARED_PTR<Transport>& c, boost::string_ref url,
318  boost::string_ref username = "",
319  const RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >& credentials =
320  (RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >()),
321  boost::string_ref objecttype = "");
322 
323  RR_SHARED_PTR<RRObject> ConnectService(const RR_SHARED_PTR<Transport>& c,
324  const RR_SHARED_PTR<ITransportConnection>& tc, boost::string_ref url,
325  boost::string_ref username = "",
326  const RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >& credentials =
327  (RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >()),
328  boost::string_ref objecttype = "");
329 
330  void AsyncConnectService(
331  const RR_SHARED_PTR<Transport>& c, boost::string_ref url, boost::string_ref username,
332  const RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >& credentials, boost::string_ref objecttype,
333  RR_MOVE_ARG(
334  boost::function<void(const RR_SHARED_PTR<RRObject>&, const RR_SHARED_PTR<RobotRaconteurException>&)>)
335  handler,
336  int32_t timeout = RR_TIMEOUT_INFINITE);
337 
338  void AsyncConnectService(
339  const RR_SHARED_PTR<Transport>& c, const RR_SHARED_PTR<ITransportConnection>& tc, boost::string_ref url,
340  boost::string_ref username, const RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >& credentials,
341  boost::string_ref objecttype,
342  RR_MOVE_ARG(
343  boost::function<void(const RR_SHARED_PTR<RRObject>&, const RR_SHARED_PTR<RobotRaconteurException>&)>)
344  handler,
345  int32_t timeout = RR_TIMEOUT_INFINITE);
346 
347  protected:
348  // These functions are part of the connection process
349  void AsyncConnectService1(
350  const RR_SHARED_PTR<Transport>& c, const RR_SHARED_PTR<ITransportConnection>& tc,
351  const RR_SHARED_PTR<RobotRaconteurException>& e, const std::string& url, const std::string& username,
352  const RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >& credentials, const std::string& objecttype,
353  boost::function<void(const RR_SHARED_PTR<RRObject>&, const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
354 
355  void AsyncConnectService2(
356  const RR_SHARED_PTR<PullServiceDefinitionAndImportsReturn>& d, const RR_SHARED_PTR<RobotRaconteurException>& e,
357  const std::string& username, const RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >& credentials,
358  const std::string& objecttype,
359  boost::function<void(const RR_SHARED_PTR<RRObject>&, const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
360 
361  void AsyncConnectService3(
362  const RR_INTRUSIVE_PTR<MessageEntry>& ret, const RR_SHARED_PTR<RobotRaconteurException>& e,
363  const std::string& username, const RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >& credentials,
364  const std::string& objecttype, const RR_SHARED_PTR<PullServiceDefinitionAndImportsReturn>& d,
365  const boost::function<void(const RR_SHARED_PTR<RRObject>&, const RR_SHARED_PTR<RobotRaconteurException>&)>&
366  handler);
367 
368  void AsyncConnectService4(const RR_SHARED_PTR<PullServiceDefinitionAndImportsReturn>& d,
369  const RR_SHARED_PTR<RobotRaconteurException>& e, const std::string& username,
370  const RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >& credentials,
371  const std::string& objecttype, const std::string& type,
372  const boost::function<void(const RR_SHARED_PTR<RRObject>&,
373  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
374 
375  void AsyncConnectService5(const RR_INTRUSIVE_PTR<MessageEntry>& ret,
376  const RR_SHARED_PTR<RobotRaconteurException>& e, const std::string& username,
377  const RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> >& credentials,
378  const std::string& objecttype, const std::string& type,
379  const RR_SHARED_PTR<PullServiceDefinitionAndImportsReturn>& d,
380  const boost::function<void(const RR_SHARED_PTR<RRObject>&,
381  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
382 
383  void AsyncConnectService6(const RR_SHARED_PTR<std::string>& ret, const RR_SHARED_PTR<RobotRaconteurException>& e,
384  const std::string& type, const std::string& username,
385  const RR_SHARED_PTR<PullServiceDefinitionAndImportsReturn>& d,
386  const boost::function<void(const RR_SHARED_PTR<RRObject>&,
387  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
388 
389  void AsyncConnectService7(const RR_INTRUSIVE_PTR<MessageEntry>& ret,
390  const RR_SHARED_PTR<RobotRaconteurException>& e, const std::string& objecttype,
391  const std::string& username,
392  const boost::function<void(const RR_SHARED_PTR<RRObject>&,
393  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
394 
395  boost::recursive_mutex connect_lock;
396 
397  public:
398  void Close();
399 
400  void AsyncClose(RR_MOVE_ARG(boost::function<void()>) handler);
401 
402  protected:
403  void AsyncClose1(const RR_INTRUSIVE_PTR<MessageEntry>& m, const RR_SHARED_PTR<RobotRaconteurException>& err,
404  const boost::function<void()>& handler);
405 
406  public:
407  void AsyncSendPipeMessage(const RR_INTRUSIVE_PTR<MessageEntry>& m, bool unreliable,
408  const boost::function<void(const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
409 
410  void SendWireMessage(const RR_INTRUSIVE_PTR<MessageEntry>& m);
411 
412  PullServiceDefinitionReturn PullServiceDefinition(boost::string_ref ServiceType = "");
413 
414  void AsyncPullServiceDefinition(boost::string_ref ServiceType,
415  RR_MOVE_ARG(boost::function<void(const RR_SHARED_PTR<PullServiceDefinitionReturn>&,
416  const RR_SHARED_PTR<RobotRaconteurException>&)>)
417  handler,
418  int32_t timeout = RR_TIMEOUT_INFINITE);
419 
420  protected:
421  void AsyncPullServiceDefinition1(const RR_INTRUSIVE_PTR<MessageEntry>& ret3,
422  const RR_SHARED_PTR<RobotRaconteurException>& err, const std::string& ServiceType,
423  boost::function<void(const RR_SHARED_PTR<PullServiceDefinitionReturn>&,
424  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
425 
426  public:
427  PullServiceDefinitionAndImportsReturn PullServiceDefinitionAndImports(boost::string_ref servicetype = "");
428 
429  void AsyncPullServiceDefinitionAndImports(
430  boost::string_ref servicetype,
431  RR_MOVE_ARG(boost::function<void(const RR_SHARED_PTR<PullServiceDefinitionAndImportsReturn>&,
432  const RR_SHARED_PTR<RobotRaconteurException>&)>) handler,
433  int32_t timeout = RR_TIMEOUT_INFINITE);
434 
435  protected:
436  void AsyncPullServiceDefinitionAndImports1(
437  const RR_SHARED_PTR<PullServiceDefinitionReturn>& pull_ret, const RR_SHARED_PTR<RobotRaconteurException>& err,
438  const std::string& servicetype, const RR_SHARED_PTR<PullServiceDefinitionAndImportsReturn>& current,
439  boost::function<void(const RR_SHARED_PTR<PullServiceDefinitionAndImportsReturn>&,
440  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler,
441  boost::posix_time::ptime timeout_time);
442 
443  public:
444  std::vector<std::string> GetPulledServiceTypes();
445 
446  RR_SHARED_PTR<ServiceFactory> GetPulledServiceType(boost::string_ref type);
447 
448  private:
449  boost::mutex pulled_service_types_lock;
450  RR_UNORDERED_MAP<std::string, RR_SHARED_PTR<ServiceFactory> > pulled_service_types;
451 
452  bool use_pulled_types;
453 
454  RR_SHARED_PTR<ITransportConnection> TransportConnection;
455 
456  boost::mutex m_Authentication_lock;
457 
458  bool m_UserAuthenticated;
459 
460  public:
461  const bool GetUserAuthenticated();
462 
463  private:
464  std::string m_AuthenticatedUsername;
465 
466  public:
467  const std::string GetAuthenticatedUsername();
468 
469  std::string AuthenticateUser(boost::string_ref username, const RR_INTRUSIVE_PTR<RRValue>& credentials);
470 
471  void AsyncAuthenticateUser(
472  boost::string_ref username, const RR_INTRUSIVE_PTR<RRValue>& credentials,
473  RR_MOVE_ARG(
474  boost::function<void(const RR_SHARED_PTR<std::string>&, const RR_SHARED_PTR<RobotRaconteurException>&)>)
475  handler,
476  int32_t timeout = RR_TIMEOUT_INFINITE);
477 
478  protected:
479  void AsyncAuthenticateUser2(const RR_INTRUSIVE_PTR<MessageEntry>& ret,
480  const RR_SHARED_PTR<RobotRaconteurException>& err, const std::string& username,
481  boost::function<void(const RR_SHARED_PTR<std::string>&,
482  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
483 
484  public:
485  std::string LogoutUser();
486 
487  std::string RequestObjectLock(const RR_SHARED_PTR<RRObject>& obj, RobotRaconteurObjectLockFlags flags);
488 
489  void AsyncRequestObjectLock(
490  const RR_SHARED_PTR<RRObject>& obj, RobotRaconteurObjectLockFlags flags,
491  RR_MOVE_ARG(
492  boost::function<void(const RR_SHARED_PTR<std::string>&, const RR_SHARED_PTR<RobotRaconteurException>&)>)
493  handler,
494  int32_t timeout = RR_TIMEOUT_INFINITE);
495 
496  protected:
497  void EndAsyncLockOp(const RR_INTRUSIVE_PTR<MessageEntry>& ret, const RR_SHARED_PTR<RobotRaconteurException>& err,
498  boost::function<void(const RR_SHARED_PTR<std::string>&,
499  const RR_SHARED_PTR<RobotRaconteurException>&)>& handler);
500 
501  public:
502  std::string ReleaseObjectLock(const RR_SHARED_PTR<RRObject>& obj);
503 
504  void AsyncReleaseObjectLock(
505  const RR_SHARED_PTR<RRObject>& obj,
506  RR_MOVE_ARG(
507  boost::function<void(const RR_SHARED_PTR<std::string>&, const RR_SHARED_PTR<RobotRaconteurException>&)>)
508  handler,
509  int32_t timeout = RR_TIMEOUT_INFINITE);
510 
511  std::string MonitorEnter(const RR_SHARED_PTR<RRObject>& obj, int32_t timeout);
512 
513  void MonitorExit(const RR_SHARED_PTR<RRObject>& obj);
514 
515  RR_OVIRTUAL void PeriodicCleanupTask() RR_OVERRIDE;
516 
517  uint32_t CheckServiceCapability(boost::string_ref name);
518 
519  // public event ClientServiceListenerDelegate ClientServiceListener;
520 
521  boost::signals2::signal<void(const RR_SHARED_PTR<ClientContext>&, ClientServiceListenerEventType,
522  const RR_SHARED_PTR<void>&)>
523  ClientServiceListener;
524 
525  protected:
526  void ProcessCallbackCall(const RR_INTRUSIVE_PTR<MessageEntry>& m);
527 
528  boost::atomic<bool> use_combined_connection;
529 
530  public:
531  RR_OVIRTUAL void TransportConnectionClosed(uint32_t endpoint) RR_OVERRIDE;
532 
533  virtual void TransportConnectionClosed1();
534 };
535 
536 template <typename T>
537 void ServiceStub::EndAsyncFindObjRef(
538  const RR_SHARED_PTR<RRObject>& obj, const RR_SHARED_PTR<RobotRaconteurException>& err,
539  const boost::function<void(const RR_SHARED_PTR<T>&, const RR_SHARED_PTR<RobotRaconteurException>&)>& handler)
540 {
541  ClientContext::EndAsyncFindObjRef(obj, err, handler);
542 }
543 
544 #ifndef ROBOTRACONTEUR_NO_CXX11_TEMPLATE_ALIASES
545 using ServiceStubPtr = RR_SHARED_PTR<ServiceStub>;
546 using ServiceStubConstPtr = RR_SHARED_PTR<const ServiceStub>;
547 #endif
548 
549 } // namespace RobotRaconteur
#define RR_TIMEOUT_INFINITE
Disable timeout for asynchronous operations.
Definition: RobotRaconteurConstants.h:566