18 #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_
34 #include <core/dbus/codec.h>
49 return ArgumentType::string;
63 static const std::string s = TypeMapper<std::string>::signature();
74 std::stringstream ss; ss << in;
auto s = ss.str();
75 writer.push_stringn(s.c_str(), s.size());
80 auto s = reader.pop_string();
81 std::stringstream ss{s}; ss >> in;
91 return ArgumentType::floating_point;
105 static const std::string s = TypeMapper<double>::signature();
117 Codec<bool>::encode_argument(writer, has_value);
119 Codec<typename com::ubuntu::location::Optional<T>::value_type>::encode_argument(writer, *in);
124 bool has_value{
false};
125 Codec<bool>::decode_argument(reader, has_value);
129 Codec<typename com::ubuntu::location::Optional<T>::value_type>::decode_argument(reader, value);
143 Codec<typename com::ubuntu::location::units::Quantity<T>::value_type>::encode_argument(writer, in.value());
149 Codec<typename com::ubuntu::location::units::Quantity<T>::value_type>::decode_argument(reader, value);
154 template<
typename T,
typename U>
155 struct Codec<
com::ubuntu::location::wgs84::Coordinate<T,U>>
159 Codec<com::ubuntu::location::units::Quantity<U>>::encode_argument(writer, in.
value);
164 Codec<com::ubuntu::location::units::Quantity<U>>::decode_argument(reader, in.
value);
169 struct Codec<
com::ubuntu::location::Position>
176 Codec<com::ubuntu::location::wgs84::Latitude>::encode_argument(writer, in.
latitude);
177 Codec<com::ubuntu::location::wgs84::Longitude>::encode_argument(writer, in.
longitude);
178 Codec<com::ubuntu::location::Optional<com::ubuntu::location::wgs84::Altitude>>::encode_argument(writer, in.
altitude);
180 Codec<com::ubuntu::location::Optional<HorizontalAccuracy>>::encode_argument(writer, in.
accuracy.
horizontal);
181 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::encode_argument(writer, in.
accuracy.
vertical);
186 Codec<com::ubuntu::location::wgs84::Latitude>::decode_argument(reader, in.
latitude);
187 Codec<com::ubuntu::location::wgs84::Longitude>::decode_argument(reader, in.
longitude);
188 Codec<com::ubuntu::location::Optional<com::ubuntu::location::wgs84::Altitude>>::decode_argument(reader, in.
altitude);
190 Codec<com::ubuntu::location::Optional<HorizontalAccuracy>>::decode_argument(reader, in.
accuracy.
horizontal);
191 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::decode_argument(reader, in.
accuracy.
vertical);
199 struct TypeMapper<
com::ubuntu::location::SpaceVehicle::Key>
203 return ArgumentType::structure;
216 static const std::string s =
217 helper::TypeMapper<std::uint32_t>::signature() +
218 helper::TypeMapper<std::uint32_t>::signature();
223 struct TypeMapper<
com::ubuntu::location::SpaceVehicle>
227 return ArgumentType::structure;
241 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +
243 helper::TypeMapper<float>::signature() +
244 helper::TypeMapper<bool>::signature() +
245 helper::TypeMapper<bool>::signature() +
246 helper::TypeMapper<bool>::signature() +
247 helper::TypeMapper<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +
248 helper::TypeMapper<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +
249 DBUS_STRUCT_END_CHAR_AS_STRING;
256 struct Codec<
com::ubuntu::location::SpaceVehicle::Key>
260 writer.push_uint32(
static_cast<std::uint32_t
>(in.
type));
261 writer.push_uint32(in.
id);
267 in.
id = reader.pop_uint32();
272 struct Codec<
com::ubuntu::location::SpaceVehicle>
276 auto sub = writer.open_structure();
279 sub.push_floating_point(in.
snr);
283 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::encode_argument(sub, in.
azimuth);
284 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::encode_argument(sub, in.
elevation);
286 writer.close_structure(std::move(sub));
291 auto sub = reader.pop_structure();
294 in.
snr = sub.pop_floating_point();
298 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::decode_argument(sub, in.
azimuth);
299 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::decode_argument(sub, in.
elevation);
306 struct TypeMapper<std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>>
310 return ArgumentType::array;
329 struct Codec<std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>>
331 inline static void encode_argument(Message::Writer& writer,
const std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& arg)
334 auto sub = writer.open_array(signature);
336 for(
const auto& element : arg)
341 writer.close_array(std::move(sub));
344 inline static void decode_argument(Message::Reader& reader, std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& out)
346 auto sub = reader.pop_array();
347 while (sub.type() != ArgumentType::invalid)
351 out.insert(std::make_pair(sv.
key, sv));
357 struct Codec<
com::ubuntu::location::Criteria>
372 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::encode_argument(writer, in.
accuracy.
vertical);
373 Codec<com::ubuntu::location::Optional<VelocityAccuracy>>::encode_argument(writer, in.
accuracy.
velocity);
374 Codec<com::ubuntu::location::Optional<HeadingAccuracy>>::encode_argument(writer, in.
accuracy.
heading);
385 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::decode_argument(reader, in.
accuracy.
vertical);
386 Codec<com::ubuntu::location::Optional<VelocityAccuracy>>::decode_argument(reader, in.
accuracy.
velocity);
387 Codec<com::ubuntu::location::Optional<HeadingAccuracy>>::decode_argument(reader, in.
accuracy.
heading);
392 struct Codec<
com::ubuntu::location::Provider::Features>
396 writer.push_int32(
static_cast<std::int32_t
>(in));
406 struct Codec<
com::ubuntu::location::Provider::Requirements>
410 writer.push_int32(
static_cast<std::int32_t
>(in));
424 writer.push_int32(
static_cast<std::int32_t
>(in));
436 struct TypeMapper<
com::ubuntu::location::Update<T>>
440 return ArgumentType::structure;
453 static const std::string s =
454 helper::TypeMapper<T>::signature() +
455 helper::TypeMapper<uint64_t>::signature();
462 struct Codec<
com::ubuntu::location::Update<T>>
466 Codec<T>::encode_argument(writer, in.
value);
467 Codec<int64_t>::encode_argument(writer, in.
when.time_since_epoch().count());
472 Codec<T>::decode_argument(reader, in.
value);
Features
Enumerates the known features that can be supported by providers.
Requirements
Enumerates the requirements of a provider implementation.
State
Enumerates all known system connectivity states.
State
State enumerates the known states of the service.
boost::units::quantity< Unit, double > Quantity
boost::optional< T > Optional
WifiAndCellIdReportingState
std::chrono::high_resolution_clock::time_point Timestamp
Timestamp type of the location service clock.
std::chrono::high_resolution_clock::duration Duration
Duration type of the location service clock.
units::Quantity< units::Length > horizontal
The client requires measurements of at least this horizontal accuracy.
Optional< units::Quantity< units::PlaneAngle > > heading
The client requires measurements of at least this heading accuracy.
Optional< units::Quantity< units::Velocity > > velocity
The client requires measurements of at least this velocity accuracy.
Optional< units::Quantity< units::Length > > vertical
The client requires measurements of at least this vertical accuracy.
bool position
The client needs position measurements.
bool heading
The client needs heading measurements.
bool velocity
The client needs velocity measurments.
bool altitude
The client needs altitude measurements.
Summarizes criteria of a client session with respect to functionality and accuracy for position,...
struct com::ubuntu::location::Criteria::Accuracy accuracy
struct com::ubuntu::location::Criteria::Requires requires
Optional< Vertical > vertical
units::Quantity< units::Length > Vertical
units::Quantity< units::Length > Horizontal
Optional< Horizontal > horizontal
The Position struct models a position in the wgs84 coordinate system.
wgs84::Longitude longitude
Optional< wgs84::Altitude > altitude
Uniquely identifies a space vehicle, given its type and its id.
Type type
The positioning system this vehicle belongs to.
Id id
Unique id of the space vehicle.
A space-vehicle as visible to providers.
Key key
Unique key identifying an instance.
bool has_ephimeris_data
Ephimeris data is available for this vehicle.
float snr
Signal to noise ratio;.
bool used_in_fix
This vehicle has been used to obtain a fix.
units::Quantity< units::PlaneAngle > azimuth
Azimuth of SV.
units::Quantity< units::PlaneAngle > elevation
Elevation of SV.
Type
Enumerates all known space-vehicle types.
bool has_almanac_data
Almanac data available for this vehicle.
Templated class that wraps a value and timestamp.
com::ubuntu::location::units::Quantity< com::ubuntu::location::units::Length > VerticalAccuracy
com::ubuntu::location::units::Quantity< com::ubuntu::location::units::Velocity > VelocityAccuracy
com::ubuntu::location::units::Quantity< com::ubuntu::location::units::Length > HorizontalAccuracy
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Criteria &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Criteria &in)
com::ubuntu::location::units::Quantity< com::ubuntu::location::units::PlaneAngle > HeadingAccuracy
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Optional< T > &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Optional< T > &in)
com::ubuntu::location::Position::Accuracy::Horizontal HorizontalAccuracy
com::ubuntu::location::Position::Accuracy::Vertical VerticalAccuracy
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Position &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Position &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Provider::Features &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Provider::Features &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Provider::Requirements &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Provider::Requirements &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::SpaceVehicle &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::SpaceVehicle &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::SpaceVehicle::Key &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::SpaceVehicle::Key &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Update< T > &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Update< T > &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::WifiAndCellIdReportingState &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::WifiAndCellIdReportingState &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::service::State &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::service::State &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::units::Quantity< T > &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::units::Quantity< T > &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::wgs84::Coordinate< T, U > &in)
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::wgs84::Coordinate< T, U > &in)
static void encode_argument(Message::Writer &writer, const std::map< com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle > &arg)
static void decode_argument(Message::Reader &reader, std::map< com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle > &out)
constexpr static ArgumentType type_value()
static std::string signature()
constexpr static bool requires_signature()
constexpr static bool is_basic_type()
static std::string signature()
constexpr static bool is_basic_type()
constexpr static bool requires_signature()
constexpr static ArgumentType type_value()
static std::string signature()
constexpr static bool is_basic_type()
constexpr static ArgumentType type_value()
constexpr static bool requires_signature()
constexpr static bool requires_signature()
constexpr static bool is_basic_type()
static std::string signature()
constexpr static ArgumentType type_value()
constexpr static bool is_basic_type()
constexpr static bool requires_signature()
static std::string signature()
constexpr static ArgumentType type_value()
constexpr static bool is_basic_type()
constexpr static ArgumentType type_value()
constexpr static bool requires_signature()
static std::string signature()