service/session/skeleton.h
Go to the documentation of this file.
/*
* Copyright © 2012-2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*/
#ifndef LOCATION_SERVICE_COM_LOMIRI_LOCATION_SERVICE_SESSION_SKELETON_H_
#define LOCATION_SERVICE_COM_LOMIRI_LOCATION_SERVICE_SESSION_SKELETON_H_
#include <com/lomiri/location/service/session/interface.h>
#include <com/lomiri/location/heading.h>
#include <com/lomiri/location/position.h>
#include <com/lomiri/location/provider.h>
#include <com/lomiri/location/update.h>
#include <com/lomiri/location/velocity.h>
#include <core/dbus/message.h>
#include <core/dbus/object.h>
#include <core/dbus/skeleton.h>
#include <memory>
#include <string>
namespace com
{
namespace lomiri
{
namespace location
{
namespace service
{
namespace session
{
class Skeleton : public core::dbus::Skeleton<Interface>
{
public:
// All local, i.e., in-process creation-time properties of the Skeleton.
struct Local
{
// The actual implementation of com::lomiri::location::service::session::Interface.
Interface::Ptr impl;
// The bus connection that the object is exposed upon.
core::dbus::Bus::Ptr bus;
};
// We communicate position, heading and velocity updates to the client
// via an explicit function call. The reason is simple: We want to know
// whether the client is still alive and responding as expected to make sure
// that we stop positioning as early as possible.
struct Remote
{
// The remote object corresponding to the client, implementing
// com.lomiri.location.service.session.Interface
core::dbus::Object::Ptr object;
// The application ID of the client
std::string app_id;
};
struct Configuration
{
// The object path of the session object, shared between clients and service.
core::dbus::types::ObjectPath path;
// Local attributes
Local local;
// Remote attributes
Remote remote;
};
Skeleton(const Configuration& configuration);
virtual ~Skeleton() noexcept;
virtual const core::dbus::types::ObjectPath& path() const;
const std::string& remote_app_id() const { return configuration.remote.app_id; }
private:
// Handle incoming requests for Start/StopPositionUpdates
virtual void on_start_position_updates(const core::dbus::Message::Ptr&);
virtual void on_stop_position_updates(const core::dbus::Message::Ptr&);
// Handles incoming requests for Start/StopHeadingUpdates
virtual void on_start_heading_updates(const core::dbus::Message::Ptr&);
virtual void on_stop_heading_updates(const core::dbus::Message::Ptr&);
// Handles incoming requests for Start/StopVelocityUpdates
virtual void on_start_velocity_updates(const core::dbus::Message::Ptr&);
virtual void on_stop_velocity_updates(const core::dbus::Message::Ptr&);
// Invoked whenever the actual session impl. for the session reports a position update.
virtual void on_position_changed(const Update<Position>& position);
// Invoked whenever the actual session impl. reports a heading update.
virtual void on_heading_changed(const Update<Heading>& heading);
// Invoked whenever the actual session impl. reports a velocity update.
virtual void on_velocity_changed(const Update<Velocity>& velocity);
// Stores all attributes passed at creation time.
Configuration configuration;
// The DBus object corresponding to the session.
core::dbus::Object::Ptr object;
// Scoped connections for automatically disconnecting on destruction
struct
{
// Corresponds to position updates coming in from the actual implementation instance.
core::ScopedConnection position_changed;
// Corresponds to heading updates coming in from the actual implementation instance.
core::ScopedConnection heading_changed;
// Corresponds to velocity updates coming in from the actual implementation instance.
core::ScopedConnection velocity_changed;
} connections;
};
}
}
}
}
}
#endif // LOCATION_SERVICE_COM_LOMIRI_LOCATION_SERVICE_SESSION_SKELETON_H_
com::lomiri::location::service::Configuration
Definition service/configuration.h:38
com::lomiri::location::service::session::Interface::Ptr
std::shared_ptr< Interface > Ptr
Definition service/session/interface.h:105
com::lomiri::location::service::session::Skeleton::Skeleton
Skeleton(const Configuration &configuration)
com::lomiri::location::service::session::Skeleton::velocity_changed
core::ScopedConnection velocity_changed
Definition service/session/skeleton.h:117
com::lomiri::location::service::session::Skeleton::heading_changed
core::ScopedConnection heading_changed
Definition service/session/skeleton.h:115
com::lomiri::location::service::session::Skeleton::~Skeleton
virtual ~Skeleton() noexcept
com::lomiri::location::service::session::Skeleton::remote_app_id
const std::string & remote_app_id() const
Definition service/session/skeleton.h:85
com::lomiri::location::service::session::Skeleton::path
virtual const core::dbus::types::ObjectPath & path() const
com::lomiri::location::service::session::Skeleton::position_changed
core::ScopedConnection position_changed
Definition service/session/skeleton.h:113
core::dbus::Skeleton
heading.h
com::lomiri::location::service::session
Definition implementation.h:36
com::lomiri::location::service
Definition service/configuration.h:36
com::lomiri::location
Definition accuracy.h:28
com::lomiri
Definition accuracy.h:26
com
Definition accuracy.h:24
core::dbus
Definition codec.h:41
core
Definition codec.h:39
position.h
provider.h
interface.h
com::lomiri::location::Update
Templated class that wraps a value and timestamp.
Definition update.h:37
com::lomiri::location::service::session::Skeleton::Configuration
Definition service/session/skeleton.h:72
com::lomiri::location::service::session::Skeleton::Configuration::path
core::dbus::types::ObjectPath path
Definition service/session/skeleton.h:74
com::lomiri::location::service::session::Skeleton::Configuration::remote
Remote remote
Definition service/session/skeleton.h:78
com::lomiri::location::service::session::Skeleton::Configuration::local
Local local
Definition service/session/skeleton.h:76
com::lomiri::location::service::session::Skeleton::Local
Definition service/session/skeleton.h:51
com::lomiri::location::service::session::Skeleton::Local::impl
Interface::Ptr impl
Definition service/session/skeleton.h:53
com::lomiri::location::service::session::Skeleton::Local::bus
core::dbus::Bus::Ptr bus
Definition service/session/skeleton.h:55
com::lomiri::location::service::session::Skeleton::Remote
Definition service/session/skeleton.h:63
com::lomiri::location::service::session::Skeleton::Remote::object
core::dbus::Object::Ptr object
Definition service/session/skeleton.h:66
com::lomiri::location::service::session::Skeleton::Remote::app_id
std::string app_id
Definition service/session/skeleton.h:68
update.h
velocity.h