18 #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_ 19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_ 33 #include <core/dbus/codec.h> 46 return ArgumentType::floating_point;
60 static const std::string s = TypeMapper<double>::signature();
72 Codec<bool>::encode_argument(writer, has_value);
74 Codec<typename com::ubuntu::location::Optional<T>::value_type>::encode_argument(writer, *in);
79 bool has_value{
false};
80 Codec<bool>::decode_argument(reader, has_value);
84 Codec<typename com::ubuntu::location::Optional<T>::value_type>::decode_argument(reader, value);
98 Codec<typename com::ubuntu::location::units::Quantity<T>::value_type>::encode_argument(writer, in.value());
104 Codec<typename com::ubuntu::location::units::Quantity<T>::value_type>::decode_argument(reader, value);
109 template<
typename T,
typename U>
110 struct Codec<
com::ubuntu::location::wgs84::Coordinate<T,U>>
114 Codec<com::ubuntu::location::units::Quantity<U>>::encode_argument(writer, in.
value);
119 Codec<com::ubuntu::location::units::Quantity<U>>::decode_argument(reader, in.
value);
124 struct Codec<
com::ubuntu::location::Position>
131 Codec<com::ubuntu::location::wgs84::Latitude>::encode_argument(writer, in.
latitude);
132 Codec<com::ubuntu::location::wgs84::Longitude>::encode_argument(writer, in.
longitude);
133 Codec<com::ubuntu::location::Optional<com::ubuntu::location::wgs84::Altitude>>::encode_argument(writer, in.
altitude);
135 Codec<com::ubuntu::location::Optional<HorizontalAccuracy>>::encode_argument(writer, in.
accuracy.
horizontal);
136 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::encode_argument(writer, in.
accuracy.
vertical);
141 Codec<com::ubuntu::location::wgs84::Latitude>::decode_argument(reader, in.
latitude);
142 Codec<com::ubuntu::location::wgs84::Longitude>::decode_argument(reader, in.
longitude);
143 Codec<com::ubuntu::location::Optional<com::ubuntu::location::wgs84::Altitude>>::decode_argument(reader, in.
altitude);
145 Codec<com::ubuntu::location::Optional<HorizontalAccuracy>>::decode_argument(reader, in.
accuracy.
horizontal);
146 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::decode_argument(reader, in.
accuracy.
vertical);
154 struct TypeMapper<
com::ubuntu::location::SpaceVehicle::Key>
158 return ArgumentType::structure;
171 static const std::string s =
172 helper::TypeMapper<std::uint32_t>::signature() +
173 helper::TypeMapper<std::uint32_t>::signature();
178 struct TypeMapper<
com::ubuntu::location::SpaceVehicle>
182 return ArgumentType::structure;
196 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +
198 helper::TypeMapper<float>::signature() +
199 helper::TypeMapper<bool>::signature() +
200 helper::TypeMapper<bool>::signature() +
201 helper::TypeMapper<bool>::signature() +
202 helper::TypeMapper<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +
203 helper::TypeMapper<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +
204 DBUS_STRUCT_END_CHAR_AS_STRING;
211 struct Codec<
com::ubuntu::location::SpaceVehicle::Key>
215 writer.push_uint32(static_cast<std::uint32_t>(in.
type));
216 writer.push_uint32(in.
id);
222 in.
id = reader.pop_uint32();
227 struct Codec<
com::ubuntu::location::SpaceVehicle>
231 auto sub = writer.open_structure();
234 sub.push_floating_point(in.
snr);
238 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::encode_argument(sub, in.
azimuth);
239 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::encode_argument(sub, in.
elevation);
241 writer.close_structure(std::move(sub));
246 auto sub = reader.pop_structure();
249 in.
snr = sub.pop_floating_point();
253 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::decode_argument(sub, in.
azimuth);
254 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::decode_argument(sub, in.
elevation);
261 struct TypeMapper<
std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>>
265 return ArgumentType::array;
284 struct Codec<
std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>>
286 inline static void encode_argument(Message::Writer& writer,
const std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& arg)
289 auto sub = writer.open_array(signature);
291 for(
const auto& element : arg)
296 writer.close_array(std::move(sub));
299 inline static void decode_argument(Message::Reader& reader, std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& out)
301 auto sub = reader.pop_array();
302 while (sub.type() != ArgumentType::invalid)
306 out.insert(std::make_pair(sv.
key, sv));
312 struct Codec<
com::ubuntu::location::Criteria>
327 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::encode_argument(writer, in.
accuracy.
vertical);
328 Codec<com::ubuntu::location::Optional<VelocityAccuracy>>::encode_argument(writer, in.
accuracy.
velocity);
329 Codec<com::ubuntu::location::Optional<HeadingAccuracy>>::encode_argument(writer, in.
accuracy.
heading);
340 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::decode_argument(reader, in.
accuracy.
vertical);
341 Codec<com::ubuntu::location::Optional<VelocityAccuracy>>::decode_argument(reader, in.
accuracy.
velocity);
342 Codec<com::ubuntu::location::Optional<HeadingAccuracy>>::decode_argument(reader, in.
accuracy.
heading);
347 struct Codec<
com::ubuntu::location::Provider::Features>
351 writer.push_int32(static_cast<std::int32_t>(in));
361 struct Codec<
com::ubuntu::location::Provider::Requirements>
365 writer.push_int32(static_cast<std::int32_t>(in));
379 writer.push_int32(static_cast<std::int32_t>(in));
391 struct TypeMapper<
com::ubuntu::location::Update<T>>
395 return ArgumentType::structure;
408 static const std::string s =
409 helper::TypeMapper<T>::signature() +
410 helper::TypeMapper<uint64_t>::signature();
417 struct Codec<
com::ubuntu::location::Update<T>>
421 Codec<T>::encode_argument(writer, in.
value);
422 Codec<int64_t>::encode_argument(writer, in.
when.time_since_epoch().count());
427 Codec<T>::decode_argument(reader, in.
value);
434 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_ static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Optional< T > &in)
static constexpr ArgumentType type_value()
static constexpr bool requires_signature()
Requirements
Enumerates the requirements of a provider implementation.
com::ubuntu::location::Position::Accuracy::Horizontal HorizontalAccuracy
static void decode_argument(Message::Reader &reader, com::ubuntu::location::units::Quantity< T > &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Update< T > &in)
Templated class that wraps a value and timestamp.
bool has_almanac_data
Almanac data available for this vehicle.
static constexpr bool is_basic_type()
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Optional< T > &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::SpaceVehicle &in)
units::Quantity< units::Length > Vertical
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::wgs84::Coordinate< T, U > &in)
static std::string signature()
Features
Enumerates the known features that can be supported by providers.
Optional< wgs84::Altitude > altitude
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::units::Quantity< T > &in)
static void decode_argument(Message::Reader &reader, std::map< com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle > &out)
static constexpr ArgumentType type_value()
static constexpr bool requires_signature()
bool heading
The client needs heading measurements.
bool position
The client needs position measurements.
static constexpr bool is_basic_type()
units::Quantity< units::PlaneAngle > azimuth
Azimuth of SV.
boost::optional< T > Optional
Optional< units::Quantity< units::Velocity > > velocity
The client requires measurements of at least this velocity accuracy.
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Criteria &in)
Type type
The positioning system this vehicle belongs to.
WifiAndCellIdReportingState
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::SpaceVehicle &in)
std::chrono::high_resolution_clock::time_point Timestamp
Timestamp type of the location service clock.
wgs84::Longitude longitude
static void encode_argument(Message::Writer &writer, const std::map< com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle > &arg)
static std::string signature()
float snr
Signal to noise ratio;.
com::ubuntu::location::units::Quantity< com::ubuntu::location::units::Length > VerticalAccuracy
boost::units::quantity< Unit, double > Quantity
Optional< units::Quantity< units::Length > > vertical
The client requires measurements of at least this vertical accuracy.
static void decode_argument(Message::Reader &reader, com::ubuntu::location::WifiAndCellIdReportingState &in)
static std::string signature()
units::Quantity< units::Length > Horizontal
The Position struct models a position in the wgs84 coordinate system.
bool velocity
The client needs velocity measurments.
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Criteria &in)
static constexpr bool is_basic_type()
bool has_ephimeris_data
Ephimeris data is available for this vehicle.
std::chrono::high_resolution_clock::duration Duration
Duration type of the location service clock.
static constexpr bool requires_signature()
units::Quantity< units::Length > horizontal
The client requires measurements of at least this horizontal accuracy.
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::SpaceVehicle::Key &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::Provider::Features &in)
static std::string signature()
Optional< Horizontal > horizontal
Uniquely identifies a space vehicle, given its type and its id.
Optional< Vertical > vertical
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Provider::Features &in)
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Position &in)
static constexpr bool requires_signature()
static void decode_argument(Message::Reader &reader, com::ubuntu::location::Provider::Requirements &in)
static std::string signature()
Id id
Unique id of the space vehicle.
A space-vehicle as visible to providers.
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Update< T > &in)
bool altitude
The client needs altitude measurements.
Summarizes criteria of a client session with respect to functionality and accuracy for position...
static constexpr ArgumentType type_value()
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Position &in)
com::ubuntu::location::Position::Accuracy::Vertical VerticalAccuracy
com::ubuntu::location::units::Quantity< com::ubuntu::location::units::Velocity > VelocityAccuracy
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::WifiAndCellIdReportingState &in)
static constexpr bool requires_signature()
static void decode_argument(Message::Reader &reader, com::ubuntu::location::SpaceVehicle::Key &in)
static constexpr bool is_basic_type()
units::Quantity< units::PlaneAngle > elevation
Elevation of SV.
com::ubuntu::location::units::Quantity< com::ubuntu::location::units::Length > HorizontalAccuracy
bool used_in_fix
This vehicle has been used to obtain a fix.
struct com::ubuntu::location::Criteria::Requires requires
struct com::ubuntu::location::Criteria::Accuracy accuracy
static constexpr bool is_basic_type()
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::Provider::Requirements &in)
static constexpr ArgumentType type_value()
Key key
Unique key identifying an instance.
Type
Enumerates all known space-vehicle types.
com::ubuntu::location::units::Quantity< com::ubuntu::location::units::PlaneAngle > HeadingAccuracy
Optional< units::Quantity< units::PlaneAngle > > heading
The client requires measurements of at least this heading accuracy.
static constexpr ArgumentType type_value()