- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
autoservice.hpp
Go to the documentation of this file.
1
2 #pragma once
3
4 /*
5 ** Copyright (C) 2013 Aldebaran Robotics
6 ** See COPYING for the licence
7 */
8
9 #ifndef _QIMESSAGING_AUTOSERVICE_HPP_
10 #define _QIMESSAGING_AUTOSERVICE_HPP_
11
12 #include <string>
13 #include <stdexcept>
14 #include <boost/thread/mutex.hpp>
15 #include <qi/session.hpp>
16 #include <qi/anyobject.hpp>
17 #include <qi/trackable.hpp>
18
19 namespace qi
20 {
21
22 namespace detail
23 {
24 template <typename T>
25 class Keeper;
26 }
27
37 template <typename T>
38 class AutoService : public qi::Trackable<AutoService<T> >, public qi::detail::GenericObjectBounce<AutoService<T> >
39 {
40 public:
49 AutoService(const std::string& name, qi::SessionPtr session);
50
51 ~AutoService();
52
63 qi::detail::Keeper<T> operator->();
64 qi::detail::Keeper<T> operator->() const;
70 T& operator*();
71 T* get();
72 const T* get() const;
73
79 qi::FutureSync<void> waitForReady();
80
84 qi::Signal<void> serviceAdded;
85
89 qi::Signal<void> serviceRemoved;
90
91 qi::GenericObject* asGenericObject() const;
92
93 private:
94 void onServiceModified(const qi::Future<qi::AnyObject>& future);
95 void onServiceAdded(const std::string& name);
96 void onServiceRemoved(const std::string& name);
97
98 mutable boost::mutex _mutex;
99 SessionPtr _session;
100 qi::Object<T> _object;
101 std::string _name;
102 qi::Promise<void> _promise;
103 };
104
105 using AnyAutoService = AutoService<qi::Empty>;
106 }
107
108 #include "detail/autoservice.hxx"
109
110 #endif
qi::AutoService::asGenericObject
qi::GenericObject * asGenericObject() const
Definition: autoservice.hxx:135
qi::SessionPtr
boost::shared_ptr< Session > SessionPtr
Definition: session.hpp:34
qi::AutoService::serviceAdded
qi::Signal< void > serviceAdded
Definition: autoservice.hpp:84
qi::AutoService::operator->
qi::detail::Keeper< T > operator->()
Definition: autoservice.hxx:80
qi::Future
Definition: executioncontext.hpp:20
trackable.hpp
qi::AutoService::waitForReady
qi::FutureSync< void > waitForReady()
Definition: autoservice.hxx:129
qi::Signal< void >
Definition: signal.hpp:251
qi::AutoService
Definition: autoservice.hpp:38
qi::AutoService::AutoService
AutoService(const std::string &name, qi::SessionPtr session)
Definition: autoservice.hxx:6
qi::GenericObject
Definition: genericobject.hpp:41
qi::AutoService::operator*
T & operator*()
Definition: autoservice.hxx:122
qi::detail::GenericObjectBounce
Definition: object.hxx:61
qi::detail::Keeper
Definition: autoservice.hpp:25
qi::Object
Definition: object.hxx:243
qi::log::env::QI_DEFAULT_LOGHANDLER::name
char const *const name
qi::Trackable
Object tracking by blocking destruction while shared pointers are present.
Definition: trackable.hpp:45
qi::FutureSync
Definition: future_fwd.hpp:70
session.hpp
qi::Promise< void >
anyobject.hpp
autoservice.hxx
qi::AutoService::serviceRemoved
qi::Signal< void > serviceRemoved
Definition: autoservice.hpp:89
qi::AutoService::~AutoService
~AutoService()
Definition: autoservice.hxx:19