18#ifndef LOCATION_SERVICE_COM_LOMIRI_LOCATION_CODEC_H_
19#define LOCATION_SERVICE_COM_LOMIRI_LOCATION_CODEC_H_
34#include <core/dbus/codec.h>
45struct TypeMapper<
com::lomiri::location::service::State>
49 return ArgumentType::string;
63 static const std::string s = TypeMapper<std::string>::signature();
70struct Codec<
com::lomiri::location::service::State>
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;
87struct TypeMapper<
com::lomiri::location::units::Quantity<T>>
91 return ArgumentType::floating_point;
105 static const std::string s = TypeMapper<double>::signature();
112struct Codec<
com::lomiri::location::Optional<T>>
117 Codec<bool>::encode_argument(writer, has_value);
119 Codec<typename com::lomiri::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::lomiri::location::Optional<T>::value_type>::decode_argument(reader, value);
139struct Codec<
com::lomiri::location::units::Quantity<T>>
143 Codec<typename com::lomiri::location::units::Quantity<T>::value_type>::encode_argument(writer, in.value());
149 Codec<typename com::lomiri::location::units::Quantity<T>::value_type>::decode_argument(reader, value);
154template<
typename T,
typename U>
155struct Codec<
com::lomiri::location::wgs84::Coordinate<T,U>>
159 Codec<com::lomiri::location::units::Quantity<U>>::encode_argument(writer, in.
value);
164 Codec<com::lomiri::location::units::Quantity<U>>::decode_argument(reader, in.
value);
169struct Codec<
com::lomiri::location::Position>
176 Codec<com::lomiri::location::wgs84::Latitude>::encode_argument(writer, in.
latitude);
177 Codec<com::lomiri::location::wgs84::Longitude>::encode_argument(writer, in.
longitude);
178 Codec<com::lomiri::location::Optional<com::lomiri::location::wgs84::Altitude>>::encode_argument(writer, in.
altitude);
180 Codec<com::lomiri::location::Optional<HorizontalAccuracy>>::encode_argument(writer, in.
accuracy.
horizontal);
181 Codec<com::lomiri::location::Optional<VerticalAccuracy>>::encode_argument(writer, in.
accuracy.
vertical);
186 Codec<com::lomiri::location::wgs84::Latitude>::decode_argument(reader, in.
latitude);
187 Codec<com::lomiri::location::wgs84::Longitude>::decode_argument(reader, in.
longitude);
188 Codec<com::lomiri::location::Optional<com::lomiri::location::wgs84::Altitude>>::decode_argument(reader, in.
altitude);
190 Codec<com::lomiri::location::Optional<HorizontalAccuracy>>::decode_argument(reader, in.
accuracy.
horizontal);
191 Codec<com::lomiri::location::Optional<VerticalAccuracy>>::decode_argument(reader, in.
accuracy.
vertical);
199struct TypeMapper<
com::lomiri::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();
223struct TypeMapper<
com::lomiri::location::SpaceVehicle>
227 return ArgumentType::structure;
241 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +
242 helper::TypeMapper<com::lomiri::location::SpaceVehicle::Key>::signature() +
243 helper::TypeMapper<float>::signature() +
244 helper::TypeMapper<bool>::signature() +
245 helper::TypeMapper<bool>::signature() +
246 helper::TypeMapper<bool>::signature() +
247 helper::TypeMapper<com::lomiri::location::units::Quantity<com::lomiri::location::units::PlaneAngle>>::signature() +
248 helper::TypeMapper<com::lomiri::location::units::Quantity<com::lomiri::location::units::PlaneAngle>>::signature() +
249 DBUS_STRUCT_END_CHAR_AS_STRING;
256struct Codec<
com::lomiri::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();
272struct Codec<
com::lomiri::location::SpaceVehicle>
276 auto sub = writer.open_structure();
278 Codec<com::lomiri::location::SpaceVehicle::Key>::encode_argument(sub, in.
key);
279 sub.push_floating_point(in.
snr);
283 Codec<com::lomiri::location::units::Quantity<com::lomiri::location::units::PlaneAngle>>::encode_argument(sub, in.
azimuth);
284 Codec<com::lomiri::location::units::Quantity<com::lomiri::location::units::PlaneAngle>>::encode_argument(sub, in.
elevation);
286 writer.close_structure(std::move(sub));
291 auto sub = reader.pop_structure();
293 Codec<com::lomiri::location::SpaceVehicle::Key>::decode_argument(sub, in.
key);
294 in.
snr = sub.pop_floating_point();
298 Codec<com::lomiri::location::units::Quantity<com::lomiri::location::units::PlaneAngle>>::decode_argument(sub, in.
azimuth);
299 Codec<com::lomiri::location::units::Quantity<com::lomiri::location::units::PlaneAngle>>::decode_argument(sub, in.
elevation);
306struct TypeMapper<std::map<com::lomiri::location::SpaceVehicle::Key, com::lomiri::location::SpaceVehicle>>
310 return ArgumentType::array;
323 static const std::string s = DBUS_TYPE_ARRAY_AS_STRING + TypeMapper<com::lomiri::location::SpaceVehicle>::signature();
329struct Codec<std::map<com::lomiri::location::SpaceVehicle::Key, com::lomiri::location::SpaceVehicle>>
331 inline static void encode_argument(Message::Writer& writer,
const std::map<com::lomiri::location::SpaceVehicle::Key, com::lomiri::location::SpaceVehicle>& arg)
333 types::Signature signature(helper::TypeMapper<com::lomiri::location::SpaceVehicle>::signature());
334 auto sub = writer.open_array(signature);
336 for(
const auto& element : arg)
338 Codec<com::lomiri::location::SpaceVehicle>::encode_argument(sub, element.second);
341 writer.close_array(std::move(sub));
344 inline static void decode_argument(Message::Reader& reader, std::map<com::lomiri::location::SpaceVehicle::Key, com::lomiri::location::SpaceVehicle>& out)
346 auto sub = reader.pop_array();
347 while (sub.type() != ArgumentType::invalid)
350 Codec<com::lomiri::location::SpaceVehicle>::decode_argument(sub, sv);
351 out.insert(std::make_pair(sv.
key, sv));
357struct Codec<
com::lomiri::location::Criteria>
372 Codec<com::lomiri::location::Optional<VerticalAccuracy>>::encode_argument(writer, in.
accuracy.
vertical);
373 Codec<com::lomiri::location::Optional<VelocityAccuracy>>::encode_argument(writer, in.
accuracy.
velocity);
374 Codec<com::lomiri::location::Optional<HeadingAccuracy>>::encode_argument(writer, in.
accuracy.
heading);
385 Codec<com::lomiri::location::Optional<VerticalAccuracy>>::decode_argument(reader, in.
accuracy.
vertical);
386 Codec<com::lomiri::location::Optional<VelocityAccuracy>>::decode_argument(reader, in.
accuracy.
velocity);
387 Codec<com::lomiri::location::Optional<HeadingAccuracy>>::decode_argument(reader, in.
accuracy.
heading);
392struct Codec<
com::lomiri::location::Provider::Features>
396 writer.push_int32(
static_cast<std::int32_t
>(in));
406struct Codec<
com::lomiri::location::Provider::Requirements>
410 writer.push_int32(
static_cast<std::int32_t
>(in));
420struct Codec<
com::lomiri::location::WifiAndCellIdReportingState>
424 writer.push_int32(
static_cast<std::int32_t
>(in));
436struct TypeMapper<
com::lomiri::location::Update<T>>
440 return ArgumentType::structure;
453 static const std::string s =
454 helper::TypeMapper<T>::signature() +
455 helper::TypeMapper<uint64_t>::signature();
462struct Codec<
com::lomiri::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
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::Length > > vertical
The client requires measurements of at least this vertical accuracy.
Optional< units::Quantity< units::Velocity > > velocity
The client requires measurements of at least this velocity accuracy.
bool heading
The client needs heading measurements.
bool altitude
The client needs altitude measurements.
bool velocity
The client needs velocity measurments.
bool position
The client needs position measurements.
Summarizes criteria of a client session with respect to functionality and accuracy for position,...
struct com::lomiri::location::Criteria::Accuracy accuracy
struct com::lomiri::location::Criteria::Requires requires
units::Quantity< units::Length > Vertical
Optional< Vertical > vertical
units::Quantity< units::Length > Horizontal
Optional< Horizontal > horizontal
The Position struct models a position in the wgs84 coordinate system.
Optional< wgs84::Altitude > altitude
wgs84::Longitude longitude
Uniquely identifies a space vehicle, given its type and its id.
Id id
Unique id of the space vehicle.
Type type
The positioning system this vehicle belongs to.
A space-vehicle as visible to providers.
Type
Enumerates all known space-vehicle types.
Key key
Unique key identifying an instance.
units::Quantity< units::PlaneAngle > azimuth
Azimuth of SV.
bool has_almanac_data
Almanac data available for this vehicle.
units::Quantity< units::PlaneAngle > elevation
Elevation of SV.
bool used_in_fix
This vehicle has been used to obtain a fix.
bool has_ephimeris_data
Ephimeris data is available for this vehicle.
float snr
Signal to noise ratio;.
Templated class that wraps a value and timestamp.
static void encode_argument(Message::Writer &writer, const com::lomiri::location::Criteria &in)
com::lomiri::location::units::Quantity< com::lomiri::location::units::PlaneAngle > HeadingAccuracy
com::lomiri::location::units::Quantity< com::lomiri::location::units::Velocity > VelocityAccuracy
com::lomiri::location::units::Quantity< com::lomiri::location::units::Length > HorizontalAccuracy
static void decode_argument(Message::Reader &reader, com::lomiri::location::Criteria &in)
com::lomiri::location::units::Quantity< com::lomiri::location::units::Length > VerticalAccuracy
static void encode_argument(Message::Writer &writer, const com::lomiri::location::Optional< T > &in)
static void decode_argument(Message::Reader &reader, com::lomiri::location::Optional< T > &in)
com::lomiri::location::Position::Accuracy::Vertical VerticalAccuracy
static void encode_argument(Message::Writer &writer, const com::lomiri::location::Position &in)
com::lomiri::location::Position::Accuracy::Horizontal HorizontalAccuracy
static void decode_argument(Message::Reader &reader, com::lomiri::location::Position &in)
static void decode_argument(Message::Reader &reader, com::lomiri::location::Provider::Features &in)
static void encode_argument(Message::Writer &writer, const com::lomiri::location::Provider::Features &in)
static void decode_argument(Message::Reader &reader, com::lomiri::location::Provider::Requirements &in)
static void encode_argument(Message::Writer &writer, const com::lomiri::location::Provider::Requirements &in)
static void encode_argument(Message::Writer &writer, const com::lomiri::location::SpaceVehicle &in)
static void decode_argument(Message::Reader &reader, com::lomiri::location::SpaceVehicle &in)
static void decode_argument(Message::Reader &reader, com::lomiri::location::SpaceVehicle::Key &in)
static void encode_argument(Message::Writer &writer, const com::lomiri::location::SpaceVehicle::Key &in)
static void decode_argument(Message::Reader &reader, com::lomiri::location::Update< T > &in)
static void encode_argument(Message::Writer &writer, const com::lomiri::location::Update< T > &in)
static void encode_argument(Message::Writer &writer, const com::lomiri::location::WifiAndCellIdReportingState &in)
static void decode_argument(Message::Reader &reader, com::lomiri::location::WifiAndCellIdReportingState &in)
static void encode_argument(Message::Writer &writer, const com::lomiri::location::service::State &in)
static void decode_argument(Message::Reader &reader, com::lomiri::location::service::State &in)
static void decode_argument(Message::Reader &reader, com::lomiri::location::units::Quantity< T > &in)
static void encode_argument(Message::Writer &writer, const com::lomiri::location::units::Quantity< T > &in)
static void encode_argument(Message::Writer &writer, const com::lomiri::location::wgs84::Coordinate< T, U > &in)
static void decode_argument(Message::Reader &reader, com::lomiri::location::wgs84::Coordinate< T, U > &in)
static void encode_argument(Message::Writer &writer, const std::map< com::lomiri::location::SpaceVehicle::Key, com::lomiri::location::SpaceVehicle > &arg)
static void decode_argument(Message::Reader &reader, std::map< com::lomiri::location::SpaceVehicle::Key, com::lomiri::location::SpaceVehicle > &out)
static constexpr bool is_basic_type()
static constexpr ArgumentType type_value()
static std::string signature()
static constexpr bool requires_signature()
static constexpr ArgumentType type_value()
static constexpr bool is_basic_type()
static std::string signature()
static constexpr bool requires_signature()
static constexpr ArgumentType type_value()
static std::string signature()
static constexpr bool is_basic_type()
static constexpr bool requires_signature()
static std::string signature()
static constexpr bool is_basic_type()
static constexpr ArgumentType type_value()
static constexpr bool requires_signature()
static constexpr bool is_basic_type()
static constexpr ArgumentType type_value()
static std::string signature()
static constexpr bool requires_signature()
static constexpr ArgumentType type_value()
static constexpr bool is_basic_type()
static constexpr bool requires_signature()
static std::string signature()