~thomas-voss/location-service/fix-service-path

« back to all changes in this revision

Viewing changes to include/location_service/com/ubuntu/location/codec.h

Expose service::State to the bus. (LP: #1536774)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <com/ubuntu/location/space_vehicle.h>
26
26
#include <com/ubuntu/location/update.h>
27
27
#include <com/ubuntu/location/velocity.h>
 
28
#include <com/ubuntu/location/service/state.h>
28
29
#include <com/ubuntu/location/units/units.h>
29
30
#include <com/ubuntu/location/wgs84/altitude.h>
30
31
#include <com/ubuntu/location/wgs84/latitude.h>
32
33
 
33
34
#include <core/dbus/codec.h>
34
35
 
 
36
#include <sstream>
 
37
 
35
38
namespace core
36
39
{
37
40
namespace dbus
38
41
{
39
42
namespace helper
40
43
{
 
44
template<>
 
45
struct TypeMapper<com::ubuntu::location::service::State>
 
46
{
 
47
    constexpr static ArgumentType type_value()
 
48
    {
 
49
        return ArgumentType::string;
 
50
    }
 
51
 
 
52
    constexpr static bool is_basic_type()
 
53
    {
 
54
        return true;
 
55
    }
 
56
    constexpr static bool requires_signature()
 
57
    {
 
58
        return false;
 
59
    }
 
60
 
 
61
    static std::string signature()
 
62
    {
 
63
        static const std::string s = TypeMapper<std::string>::signature();
 
64
        return s;
 
65
    }
 
66
};
 
67
}
 
68
 
 
69
template<>
 
70
struct Codec<com::ubuntu::location::service::State>
 
71
{
 
72
    static void encode_argument(Message::Writer& writer, const com::ubuntu::location::service::State& in)
 
73
    {
 
74
        std::stringstream ss; ss << in; auto s = ss.str();
 
75
        writer.push_stringn(s.c_str(), s.size());
 
76
    }
 
77
 
 
78
    static void decode_argument(Message::Reader& reader, com::ubuntu::location::service::State& in)
 
79
    {
 
80
        auto s = reader.pop_string();
 
81
        std::stringstream ss{s}; ss >> in;
 
82
    }
 
83
};
 
84
namespace helper
 
85
{
41
86
template<typename T>
42
87
struct TypeMapper<com::ubuntu::location::units::Quantity<T>>
43
88
{