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