~thomas-voss/location-service/fix-1347887

« back to all changes in this revision

Viewing changes to include/location_service/com/ubuntu/location/update.h

This MP consolidates multiple related changes together, with the goal of:

(1.) Make the service instance accessible via a cli. Useful for testing scenarios.
(2.) To cut down time-to-first-fix (ttff) by:
  (2.1) Leveraging SUPL and other supplementary data downloaded over ordinary data connections.
  (2.2) Enabling network-based positioning providers to acquire fast position estimates.

In more detail:

* Added tests for daemon and cli.
* Unified daemon and cli header and implementation files.
* Add a command-line interface to the service.
* Split up provider selection policy to rely on an interface ProviderEnumerator to ease in testing.
* Trimmed down on types.
* Removed connectivity API draft to prepare for simpler approach.
* Refactored includes.
* Added a configuration option to handle cell and wifi ID reporting.
* Add a mock for a connectivity API exposed to providers and reporters.
* Add units for connectivity api.
* Refactor cell class into namespace radio. Fixes: 1226204, 1248973, 1281817

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_
19
19
#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_
20
20
 
21
 
#include "com/ubuntu/location/clock.h"
 
21
#include <com/ubuntu/location/clock.h>
22
22
 
23
23
#include <ostream>
24
24
 
28
28
{
29
29
namespace location
30
30
{
 
31
/**
 
32
 * @brief Templated class that wraps a value and timestamp.
 
33
 * @tparam T The contained value.
 
34
 */
31
35
template<typename T>
32
36
struct Update
33
37
{
34
 
    Update(const T& value = T{}, const Clock::Timestamp& when = Clock::Timestamp{}) : value{value}, when{when}
 
38
    /**
 
39
      * @brief Constructs a valid update with the given value and timestamp.
 
40
      * @param [in] value The value delivered with this update.
 
41
      * @param [in] when The timestamp when the value was measured.
 
42
      */
 
43
    inline Update(const T& value = T{},
 
44
           const Clock::Timestamp& when = Clock::now())
 
45
        : value{value}, when{when}
35
46
    {
36
47
    }
37
48
 
38
 
    bool operator==(const Update<T>& rhs) const
 
49
    /**
 
50
     * @brief operator == checks if two updates are equal.
 
51
     * @param [in] rhs The update to check against.
 
52
     * @return true iff this instance equals rhs.
 
53
     */
 
54
    inline bool operator==(const Update<T>& rhs) const
39
55
    {
40
56
        return value == rhs.value && when == rhs.when;
41
57
    }
42
58
 
43
 
    bool operator!=(const Update<T>& rhs) const
 
59
    /**
 
60
     * @brief operator != checks if two updates are unequal.
 
61
     * @param [in] rhs The update to check against.
 
62
     * @return true iff this instance does not equal rhs.
 
63
     */
 
64
    inline bool operator!=(const Update<T>& rhs) const
44
65
    {
45
66
        return !(value == rhs.value && when == rhs.when);
46
67
    }
47
68
 
 
69
    /** The value delivered with this update. */
48
70
    T value;
49
 
    Clock::Timestamp when;
 
71
 
 
72
    /** Time when the updated value was measured. */
 
73
    Clock::Timestamp when = Clock::beginning_of_time();
50
74
};
51
75
 
 
76
/**
 
77
 * @brief Pretty-prints the update to the provided output stream.
 
78
 * @param out The stream to write to.
 
79
 * @param update The value to be printed.
 
80
 */
52
81
template<typename T>
53
82
inline std::ostream& operator<<(std::ostream& out, const Update<T>& update)
54
83
{