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);
479 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_ State
State enumerates the known states of the service.
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.
static std::string signature()
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)
static constexpr bool requires_signature()
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 constexpr bool is_basic_type()
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()
static void encode_argument(Message::Writer &writer, const com::ubuntu::location::service::State &in)
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.
static constexpr ArgumentType type_value()
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 decode_argument(Message::Reader &reader, com::ubuntu::location::service::State &in)
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()
State
Enumerates all known system connectivity states.
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()