~thomas-voss/location-service/add-snapcraft-setup-next

« back to all changes in this revision

Viewing changes to src/location/providers/geoclue/geoclue.h

Merge lp:~thomas-voss/location-service/simplify-provider-interface.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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_PROVIDERS_GEOCLUE_GEOCLUE_H_
19
 
#define LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_
20
 
 
21
 
#include <core/dbus/service.h>
22
 
#include <core/dbus/traits/service.h>
23
 
#include <core/dbus/types/struct.h>
24
 
#include <core/dbus/types/stl/tuple.h>
25
 
 
26
 
#include <string>
27
 
 
28
 
namespace dbus = core::dbus;
29
 
 
30
 
namespace org
31
 
{
32
 
namespace freedesktop
33
 
{
34
 
struct Geoclue
35
 
{
36
 
    enum class Status : int
37
 
    {
38
 
        error,
39
 
        unavailable,
40
 
        acquiring,
41
 
        available
42
 
    };
43
 
 
44
 
    friend std::ostream& operator<<(std::ostream& out, const Status& status)
45
 
    {
46
 
        static std::map<Status, std::string> lut =
47
 
        {
48
 
            {Status::error, "error"},
49
 
            {Status::unavailable, "unavailable"},
50
 
            {Status::acquiring, "acquiring"},
51
 
            {Status::available, "available"}
52
 
        };
53
 
 
54
 
        return out << lut[status];
55
 
    }
56
 
 
57
 
    struct GetProviderInfo
58
 
    {
59
 
        inline static std::string name()
60
 
        {
61
 
            return "GetProviderInfo";
62
 
        }
63
 
        typedef Geoclue Interface;
64
 
        typedef std::tuple<std::string, std::string> ResultType;
65
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
66
 
    };
67
 
 
68
 
    struct GetStatus
69
 
    {
70
 
        inline static std::string name()
71
 
        {
72
 
            return "GetStatus";
73
 
        }
74
 
        typedef Geoclue Interface;
75
 
        typedef int32_t ResultType;
76
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
77
 
    };
78
 
 
79
 
    struct AddReference
80
 
    {
81
 
        inline static std::string name()
82
 
        {
83
 
            return "AddReference";
84
 
        }
85
 
        typedef Geoclue Interface;
86
 
        typedef void ResultType;
87
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
88
 
    };
89
 
 
90
 
    struct RemoveReference
91
 
    {
92
 
        inline static std::string name()
93
 
        {
94
 
            return "RemoveReference";
95
 
        }
96
 
        typedef Geoclue Interface;
97
 
        typedef void ResultType;
98
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
99
 
    };
100
 
 
101
 
    struct Address
102
 
    {
103
 
        struct GetAddress
104
 
        {
105
 
            inline static std::string name()
106
 
            {
107
 
                return "GetAddress";
108
 
            }
109
 
            typedef Address Interface;
110
 
            typedef std::tuple<int32_t, std::map<std::string, std::string>, dbus::types::Struct<std::tuple<int32_t, double, double>>> ResultType;
111
 
            inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
112
 
        };
113
 
 
114
 
        struct Signals
115
 
        {
116
 
            struct AddressChanged
117
 
            {
118
 
                inline static std::string name()
119
 
                {
120
 
                    return "PositionChanged";
121
 
                };
122
 
                typedef Address Interface;
123
 
                typedef std::tuple<int32_t, std::map<std::string, std::string>, dbus::types::Struct<std::tuple<int32_t, double, double>>> ArgumentType;
124
 
            };
125
 
        };
126
 
    };
127
 
 
128
 
    struct Position
129
 
    {
130
 
        struct Field
131
 
        {
132
 
            Field() = delete;
133
 
 
134
 
            static const int none = 0;
135
 
            static const int latitude = 1;
136
 
            static const int longitude = 2;
137
 
            static const int altitude = 3;
138
 
        };
139
 
 
140
 
        typedef std::bitset<4> FieldFlags;
141
 
 
142
 
        struct GetPosition
143
 
        {
144
 
            inline static std::string name()
145
 
            {
146
 
                return "GetPosition";
147
 
            }
148
 
            typedef Position Interface;
149
 
            typedef std::tuple<int32_t, int32_t, double, double, double, dbus::types::Struct<std::tuple<int32_t, double, double>>> ResultType;
150
 
            inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
151
 
        };
152
 
 
153
 
        struct Signals
154
 
        {
155
 
            struct PositionChanged
156
 
            {
157
 
                inline static std::string name()
158
 
                {
159
 
                    return "PositionChanged";
160
 
                };
161
 
                typedef Position Interface;
162
 
                typedef std::tuple<int32_t, int32_t, double, double, double, dbus::types::Struct<std::tuple<int32_t, double, double>>> ArgumentType;
163
 
            };
164
 
        };
165
 
    };
166
 
 
167
 
    struct Velocity
168
 
    {
169
 
        struct Field
170
 
        {
171
 
            Field() = delete;
172
 
 
173
 
            static const int none = 0;
174
 
            static const int speed = 1;
175
 
            static const int direction = 2;
176
 
            static const int climb = 3;
177
 
        };
178
 
 
179
 
        typedef std::bitset<4> FieldFlags;
180
 
 
181
 
        struct GetVelocity
182
 
        {
183
 
            inline static std::string name()
184
 
            {
185
 
                return "GetVelocity";
186
 
            }
187
 
            typedef Velocity Interface;
188
 
            typedef std::tuple<int32_t, int32_t, double, double, double> ResultType;
189
 
            inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
190
 
        };
191
 
        struct Signals
192
 
        {
193
 
            struct VelocityChanged
194
 
            {
195
 
                inline static std::string name()
196
 
                {
197
 
                    return "VelocityChanged";
198
 
                };
199
 
                typedef Velocity Interface;
200
 
                typedef std::tuple<int32_t, int32_t, double, double, double> ArgumentType;
201
 
            };
202
 
        };
203
 
    };
204
 
};
205
 
}
206
 
}
207
 
 
208
 
namespace core
209
 
{
210
 
namespace dbus
211
 
{
212
 
namespace traits
213
 
{
214
 
template<>
215
 
struct Service<org::freedesktop::Geoclue>
216
 
{
217
 
    inline static const std::string& interface_name()
218
 
    {
219
 
        static const std::string s{"org.freedesktop.Geoclue"};
220
 
        return s;
221
 
    }
222
 
};
223
 
 
224
 
template<>
225
 
struct Service<org::freedesktop::Geoclue::Address>
226
 
{
227
 
    inline static const std::string& interface_name()
228
 
    {
229
 
        static const std::string s{"org.freedesktop.Geoclue.Address"};
230
 
        return s;
231
 
    }
232
 
};
233
 
 
234
 
template<>
235
 
struct Service<org::freedesktop::Geoclue::Position>
236
 
{
237
 
    inline static const std::string& interface_name()
238
 
    {
239
 
        static const std::string s{"org.freedesktop.Geoclue.Position"};
240
 
        return s;
241
 
    }
242
 
};
243
 
 
244
 
template<>
245
 
struct Service<org::freedesktop::Geoclue::Velocity>
246
 
{
247
 
    inline static const std::string& interface_name()
248
 
    {
249
 
        static const std::string s{"org.freedesktop.Geoclue.Velocity"};
250
 
        return s;
251
 
    }
252
 
};
253
 
}
254
 
}
255
 
}
256
 
 
257
 
#endif // LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_