ubuntu-location-service  0.0.2
interface.h
1 /*
2  * Copyright © 2012-2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_
20 
21 #include "com/ubuntu/location/channel.h"
22 #include "com/ubuntu/location/heading.h"
23 #include "com/ubuntu/location/position.h"
24 #include "com/ubuntu/location/provider.h"
25 #include "com/ubuntu/location/update.h"
26 #include "com/ubuntu/location/velocity.h"
27 
28 #include <org/freedesktop/dbus/codec.h>
29 #include <org/freedesktop/dbus/traits/service.h>
30 #include <org/freedesktop/dbus/types/object_path.h>
31 
32 namespace com
33 {
34 namespace ubuntu
35 {
36 namespace location
37 {
38 namespace service
39 {
40 namespace session
41 {
42 class Interface
43 {
44 public:
46  {
48 
49  inline static const std::string& name()
50  {
51  static const std::string s
52  {
53  "UpdatePosition"
54  };
55  return s;
56  }
57 
58  typedef void ResultType;
59 
60  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
61  };
62 
64  {
66 
67  inline static const std::string& name()
68  {
69  static const std::string s
70  {
71  "UpdateVelocity"
72  };
73  return s;
74  }
75 
76  typedef void ResultType;
77 
78  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
79  };
80 
82  {
84 
85  inline static const std::string& name()
86  {
87  static const std::string s
88  {
89  "UpdateHeading"
90  };
91  return s;
92  }
93 
94  typedef void ResultType;
95 
96  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
97  };
98 
100  {
102 
103  inline static const std::string& name()
104  {
105  static const std::string s
106  {
107  "StartPositionUpdates"
108  };
109  return s;
110  }
111 
112  typedef void ResultType;
113 
114  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
115  };
116 
118  {
120 
121  inline static const std::string& name()
122  {
123  static const std::string s
124  {
125  "StopPositionUpdates"
126  };
127  return s;
128  }
129 
130  typedef void ResultType;
131 
132  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
133  };
134 
136  {
138 
139  inline static const std::string& name()
140  {
141  static const std::string s
142  {
143  "StartVelocityUpdates"
144  };
145  return s;
146  }
147 
148  typedef void ResultType;
149 
150  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
151  };
152 
154  {
156 
157  inline static const std::string& name()
158  {
159  static const std::string s
160  {
161  "StopVelocityUpdates"
162  };
163  return s;
164  }
165 
166  typedef void ResultType;
167 
168  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
169  };
170 
172  {
174 
175  inline static const std::string& name()
176  {
177  static const std::string s
178  {
179  "StartHeadingUpdates"
180  };
181  return s;
182  }
183 
184  typedef void ResultType;
185 
186  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
187  };
188 
190  {
192 
193  inline static const std::string& name()
194  {
195  static const std::string s
196  {
197  "StopHeadingUpdates"
198  };
199  return s;
200  }
201 
202  typedef void ResultType;
203 
204  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
205  };
206 
207  struct Errors
208  {
209  struct ErrorParsingUpdate { inline static std::string name() { return "com.ubuntu.location.Service.Session.ErrorParsingUpdate"; } };
210  struct ErrorStartingUpdate { inline static std::string name() { return "com.ubuntu.location.Service.Session.ErrorStartingUpdate"; } };
211  };
212 
213  typedef std::shared_ptr<Interface> Ptr;
214 
215  Interface(const Interface&) = delete;
216  virtual ~Interface() noexcept;
217  Interface& operator=(const Interface&) = delete;
218 
219  virtual const org::freedesktop::dbus::types::ObjectPath& path() const = 0;
220 
221  ChannelConnection install_position_updates_handler(std::function<void(const Update<Position>&)> handler);
222  ChannelConnection install_velocity_updates_handler(std::function<void(const Update<Velocity>&)> handler);
223  ChannelConnection install_heading_updates_handler(std::function<void(const Update<Heading>&)> handler);
224 
225  virtual void start_position_updates() = 0;
226  virtual void stop_position_updates() noexcept = 0;
227  virtual void start_velocity_updates() = 0;
228  virtual void stop_velocity_updates() noexcept = 0;
229  virtual void start_heading_updates() = 0;
230  virtual void stop_heading_updates() noexcept = 0;
231 
232 protected:
233  Interface();
234 
235  Channel<Update<Position>>& access_position_updates_channel();
236  Channel<Update<Heading>>& access_heading_updates_channel();
237  Channel<Update<Velocity>>& access_velocity_updates_channel();
238 
239 private:
240  struct Private;
241  std::unique_ptr<Private> d;
242 };
243 }
244 }
245 }
246 }
247 }
248 namespace org
249 {
250 namespace freedesktop
251 {
252 namespace dbus
253 {
254 namespace traits
255 {
256 template<>
257 struct Service<com::ubuntu::location::service::session::Interface>
258 {
259  static const std::string& interface_name()
260  {
261  static const std::string s
262  {
263  "com.ubuntu.location.Service.Session"
264  };
265  return s;
266  }
267 };
268 }
269 }
270 }
271 }
272 
273 #include "com/ubuntu/location/codec.h"
274 
275 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_