ubuntu-location-service  ..
An aggregating location service providing positioning and geocoding capabilities to applications.
skeleton.h
Go to the documentation of this file.
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_SKELETON_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_
20 
22 
28 
29 #include <core/dbus/message.h>
30 #include <core/dbus/object.h>
31 #include <core/dbus/skeleton.h>
32 
33 #include <memory>
34 
35 namespace com
36 {
37 namespace ubuntu
38 {
39 namespace location
40 {
41 namespace service
42 {
43 namespace session
44 {
45 class Skeleton : public core::dbus::Skeleton<Interface>
46 {
47 public:
48  // All local, i.e., in-process creation-time properties of the Skeleton.
49  struct Local
50  {
51  // The actual implementation of com::ubuntu::location::service::session::Interface.
53  // The bus connection that the object is exposed upon.
54  core::dbus::Bus::Ptr bus;
55  };
56 
57  // We communicate position, heading and velocity updates to the client
58  // via an explicit function call. The reason is simple: We want to know
59  // whether the client is still alive and responding as expected to make sure
60  // that we stop positioning as early as possible.
61  struct Remote
62  {
63  // The remote object corresponding to the client, implementing
64  // com.ubuntu.location.service.session.Interface
65  core::dbus::Object::Ptr object;
66  };
67 
69  {
70  // The object path of the session object, shared between clients and service.
71  core::dbus::types::ObjectPath path;
72  // Local attributes
74  // Remote attributes
76  };
77 
78  Skeleton(const Configuration& configuration);
79  virtual ~Skeleton() noexcept;
80 
81  virtual const core::dbus::types::ObjectPath& path() const;
82 
83 private:
84  // Handle incoming requests for Start/StopPositionUpdates
85  virtual void on_start_position_updates(const core::dbus::Message::Ptr&);
86  virtual void on_stop_position_updates(const core::dbus::Message::Ptr&);
87  // Handles incoming requests for Start/StopHeadingUpdates
88  virtual void on_start_heading_updates(const core::dbus::Message::Ptr&);
89  virtual void on_stop_heading_updates(const core::dbus::Message::Ptr&);
90  // Handles incoming requests for Start/StopVelocityUpdates
91  virtual void on_start_velocity_updates(const core::dbus::Message::Ptr&);
92  virtual void on_stop_velocity_updates(const core::dbus::Message::Ptr&);
93 
94  // Invoked whenever the actual session impl. for the session reports a position update.
95  virtual void on_position_changed(const Update<Position>& position);
96  // Invoked whenever the actual session impl. reports a heading update.
97  virtual void on_heading_changed(const Update<Heading>& heading);
98  // Invoked whenever the actual session impl. reports a velocity update.
99  virtual void on_velocity_changed(const Update<Velocity>& velocity);
100 
101  // Stores all attributes passed at creation time.
102  Configuration configuration;
103  // The DBus object corresponding to the session.
104  core::dbus::Object::Ptr object;
105  // Scoped connections for automatically disconnecting on destruction
106  struct
107  {
108  // Corresponds to position updates coming in from the actual implementation instance.
109  core::ScopedConnection position_changed;
110  // Corresponds to heading updates coming in from the actual implementation instance.
111  core::ScopedConnection heading_changed;
112  // Corresponds to velocity updates coming in from the actual implementation instance.
113  core::ScopedConnection velocity_changed;
114  } connections;
115 };
116 }
117 }
118 }
119 }
120 }
121 
122 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_
units::Quantity< units::Velocity > Velocity
Velocity is measured in m/s.
Definition: velocity.h:30
Templated class that wraps a value and timestamp.
Definition: update.h:36
Definition: codec.h:35
Definition: accuracy.h:23
virtual const core::dbus::types::ObjectPath & path() const
The Position struct models a position in the wgs84 coordinate system.
Definition: position.h:39
Skeleton(const Configuration &configuration)
units::Quantity< units::PlaneAngle > Heading
Definition: heading.h:30