~sil2100/location-service/gps-arm64

« back to all changes in this revision

Viewing changes to include/location_service/com/ubuntu/location/service/session/implementation.h

  • Committer: Thomas Voß
  • Date: 2013-05-28 14:20:45 UTC
  • Revision ID: thomas.voss@canonical.com-20130528142045-kq5umqdmm4o53vwk
Initial push.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_
 
2
#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_
 
3
 
 
4
#include "com/ubuntu/location/service/session/skeleton.h"
 
5
 
 
6
#include "com/ubuntu/location/provider.h"
 
7
 
 
8
#include <functional>
 
9
#include <memory>
 
10
 
 
11
namespace com
 
12
{
 
13
namespace ubuntu
 
14
{
 
15
namespace location
 
16
{
 
17
namespace service
 
18
{
 
19
namespace session
 
20
{
 
21
class Implementation : public Skeleton
 
22
{
 
23
  public:
 
24
    Implementation(
 
25
        const org::freedesktop::dbus::Bus::Ptr& bus, 
 
26
        const org::freedesktop::dbus::types::ObjectPath& session_path, 
 
27
        const Provider::Ptr& provider)
 
28
        : Skeleton(bus, session_path),
 
29
          provider(provider),
 
30
          controller(provider->state_controller())
 
31
    {
 
32
        position_updates_connection = 
 
33
                provider->subscribe_to_position_updates([this](const Update<Position>& update)
 
34
                                                        {
 
35
                                                            access_position_updates_channel()(update);
 
36
                                                        });
 
37
        heading_updates_connection = 
 
38
                provider->subscribe_to_heading_updates([this](const Update<Heading>& update)
 
39
                                                       {
 
40
                                                           access_heading_updates_channel()(update);
 
41
                                                       });
 
42
        velocity_updates_connection = 
 
43
                provider->subscribe_to_velocity_updates([this](const Update<Velocity>& update)
 
44
                                                        {
 
45
                                                            access_velocity_updates_channel()(update);
 
46
                                                        });
 
47
    }
 
48
    
 
49
    virtual ~Implementation() noexcept
 
50
    {
 
51
    }
 
52
 
 
53
    virtual void start_position_updates() 
 
54
    {
 
55
        controller->start_position_updates();
 
56
        if (controller->cached_position_update().is_valid())
 
57
            access_position_updates_channel()(controller->cached_position_update().value());
 
58
    }
 
59
 
 
60
    virtual void stop_position_updates() noexcept 
 
61
    {
 
62
        controller->stop_position_updates();
 
63
    }
 
64
 
 
65
    virtual void start_velocity_updates() 
 
66
    {
 
67
        controller->start_velocity_updates();
 
68
        if (controller->cached_velocity_update().is_valid())
 
69
            access_velocity_updates_channel()(controller->cached_velocity_update().value());
 
70
    }
 
71
 
 
72
    virtual void stop_velocity_updates() noexcept
 
73
    {
 
74
        controller->stop_velocity_updates();
 
75
    }
 
76
 
 
77
    virtual void start_heading_updates()
 
78
    {
 
79
        controller->start_heading_updates();
 
80
        if (controller->cached_heading_update().is_valid())
 
81
            access_heading_updates_channel()(controller->cached_heading_update().value());
 
82
    }
 
83
 
 
84
    virtual void stop_heading_updates() noexcept
 
85
    {
 
86
        controller->stop_heading_updates();
 
87
    }
 
88
 
 
89
  private:
 
90
    Provider::Ptr provider;
 
91
    Provider::Controller::Ptr controller;
 
92
    ScopedChannelConnection position_updates_connection;
 
93
    ScopedChannelConnection velocity_updates_connection;
 
94
    ScopedChannelConnection heading_updates_connection;
 
95
 
 
96
};
 
97
}
 
98
}
 
99
}
 
100
}
 
101
}
 
102
 
 
103
#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_