~thomas-voss/location-service/simplify-provider-interface

« back to all changes in this revision

Viewing changes to src/location/service/stub.cpp

  • Committer: Thomas Voß
  • Date: 2016-06-27 11:05:34 UTC
  • mfrom: (258.1.3 simplify-namespaces)
  • Revision ID: thomas.voss@canonical.com-20160627110534-vgl06rzgh7if12uo
Merge lp:~thomas-voss/location-service/simplify-namespaces

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *
16
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17
17
 */
18
 
#include <com/ubuntu/location/service/stub.h>
19
 
#include <com/ubuntu/location/service/session/stub.h>
 
18
#include <location/service/stub.h>
 
19
#include <location/service/session/stub.h>
20
20
 
21
 
#include <com/ubuntu/location/logging.h>
 
21
#include <location/logging.h>
22
22
 
23
23
#include <core/dbus/property.h>
24
24
 
25
 
namespace cul = com::ubuntu::location;
26
 
namespace culs = com::ubuntu::location::service;
27
 
namespace culss = com::ubuntu::location::service::session;
28
 
 
29
25
namespace dbus = core::dbus;
30
26
 
31
 
struct culs::Stub::Private
 
27
struct location::service::Stub::Private
32
28
{
33
29
    Private(const dbus::Bus::Ptr& connection,
34
30
            const dbus::Object::Ptr& object)
35
31
        : bus(connection),
36
32
          object(object),
37
 
          state(object->get_property<culs::Interface::Properties::State>()),
38
 
          does_satellite_based_positioning(object->get_property<culs::Interface::Properties::DoesSatelliteBasedPositioning>()),
39
 
          does_report_cell_and_wifi_ids(object->get_property<culs::Interface::Properties::DoesReportCellAndWifiIds>()),
40
 
          is_online(object->get_property<culs::Interface::Properties::IsOnline>()),
41
 
          visible_space_vehicles(object->get_property<culs::Interface::Properties::VisibleSpaceVehicles>())
 
33
          state(object->get_property<location::service::Interface::Properties::State>()),
 
34
          does_satellite_based_positioning(object->get_property<location::service::Interface::Properties::DoesSatelliteBasedPositioning>()),
 
35
          does_report_cell_and_wifi_ids(object->get_property<location::service::Interface::Properties::DoesReportCellAndWifiIds>()),
 
36
          is_online(object->get_property<location::service::Interface::Properties::IsOnline>()),
 
37
          visible_space_vehicles(object->get_property<location::service::Interface::Properties::VisibleSpaceVehicles>())
42
38
    {
43
39
    }
44
40
 
45
41
    dbus::Bus::Ptr bus;
46
42
    dbus::Object::Ptr object;
47
 
    std::shared_ptr<dbus::Property<culs::Interface::Properties::State>> state;
48
 
    std::shared_ptr<dbus::Property<culs::Interface::Properties::DoesSatelliteBasedPositioning>> does_satellite_based_positioning;
49
 
    std::shared_ptr<dbus::Property<culs::Interface::Properties::DoesReportCellAndWifiIds>> does_report_cell_and_wifi_ids;
50
 
    std::shared_ptr<dbus::Property<culs::Interface::Properties::IsOnline>> is_online;
51
 
    std::shared_ptr<dbus::Property<culs::Interface::Properties::VisibleSpaceVehicles>> visible_space_vehicles;
 
43
    std::shared_ptr<dbus::Property<location::service::Interface::Properties::State>> state;
 
44
    std::shared_ptr<dbus::Property<location::service::Interface::Properties::DoesSatelliteBasedPositioning>> does_satellite_based_positioning;
 
45
    std::shared_ptr<dbus::Property<location::service::Interface::Properties::DoesReportCellAndWifiIds>> does_report_cell_and_wifi_ids;
 
46
    std::shared_ptr<dbus::Property<location::service::Interface::Properties::IsOnline>> is_online;
 
47
    std::shared_ptr<dbus::Property<location::service::Interface::Properties::VisibleSpaceVehicles>> visible_space_vehicles;
52
48
};
53
49
 
54
 
culs::Stub::Stub(const dbus::Bus::Ptr& connection) : dbus::Stub<culs::Interface>(connection),
55
 
    d(new Private{connection, access_service()->object_for_path(culs::Interface::path())})
56
 
{
57
 
}
58
 
 
59
 
culs::Stub::~Stub() noexcept
60
 
{
61
 
}
62
 
 
63
 
culss::Interface::Ptr culs::Stub::create_session_for_criteria(const cul::Criteria& criteria)
 
50
location::service::Stub::Stub(const dbus::Bus::Ptr& connection) : dbus::Stub<location::service::Interface>(connection),
 
51
    d(new Private{connection, access_service()->object_for_path(location::service::Interface::path())})
 
52
{
 
53
}
 
54
 
 
55
location::service::Stub::~Stub() noexcept
 
56
{
 
57
}
 
58
 
 
59
location::service::session::Interface::Ptr location::service::Stub::create_session_for_criteria(const location::Criteria& criteria)
64
60
{
65
61
    auto op = d->object->transact_method<
66
 
            culs::Interface::CreateSessionForCriteria,
67
 
            culs::Interface::CreateSessionForCriteria::ResultType
 
62
            location::service::Interface::CreateSessionForCriteria,
 
63
            location::service::Interface::CreateSessionForCriteria::ResultType
68
64
            >(criteria);
69
65
 
70
66
    if (op.is_error())
73
69
        throw std::runtime_error(ss.str());
74
70
    }
75
71
 
76
 
    return culss::Interface::Ptr(new culss::Stub{d->bus, op.value()});
 
72
    return location::service::session::Interface::Ptr(new location::service::session::Stub{d->bus, op.value()});
77
73
}
78
74
 
79
 
const core::Property<culs::State>& culs::Stub::state() const
 
75
const core::Property<location::service::State>& location::service::Stub::state() const
80
76
{
81
77
    return *d->state;
82
78
}
83
79
 
84
 
core::Property<bool>& culs::Stub::does_satellite_based_positioning()
 
80
core::Property<bool>& location::service::Stub::does_satellite_based_positioning()
85
81
{
86
82
    return *d->does_satellite_based_positioning;
87
83
}
88
84
 
89
 
core::Property<bool>& culs::Stub::does_report_cell_and_wifi_ids()
 
85
core::Property<bool>& location::service::Stub::does_report_cell_and_wifi_ids()
90
86
{
91
87
    return *d->does_report_cell_and_wifi_ids;
92
88
}
93
89
 
94
 
core::Property<bool>& culs::Stub::is_online()
 
90
core::Property<bool>& location::service::Stub::is_online()
95
91
{
96
92
    return *d->is_online;
97
93
}
98
94
 
99
 
core::Property<std::map<cul::SpaceVehicle::Key, cul::SpaceVehicle>>& culs::Stub::visible_space_vehicles()
 
95
core::Property<std::map<location::SpaceVehicle::Key, location::SpaceVehicle>>& location::service::Stub::visible_space_vehicles()
100
96
{
101
97
    return *d->visible_space_vehicles;
102
98
}