lomiri-location-service ..
An aggregating location service providing positioning and geocoding capabilities to applications.
update.h
Go to the documentation of this file.
1/*
2 * Copyright © 2012-2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#ifndef LOCATION_SERVICE_COM_LOMIRI_LOCATION_UPDATE_H_
19#define LOCATION_SERVICE_COM_LOMIRI_LOCATION_UPDATE_H_
20
22
23#include <ostream>
24
25namespace com
26{
27namespace lomiri
28{
29namespace location
30{
35template<typename T>
36struct Update
37{
43 inline Update(const T& value = T{},
45 : value{value}, when{when}
46 {
47 }
48
54 inline bool operator==(const Update<T>& rhs) const
55 {
56 return value == rhs.value && when == rhs.when;
57 }
58
64 inline bool operator!=(const Update<T>& rhs) const
65 {
66 return !(value == rhs.value && when == rhs.when);
67 }
68
71
74};
75
81template<typename T>
82inline std::ostream& operator<<(std::ostream& out, const Update<T>& update)
83{
84 out << "Update(" << update.value << ", " << update.when.time_since_epoch().count() << ")";
85 return out;
86}
87
88}
89}
90}
91
92#endif // LOCATION_SERVICE_COM_LOMIRI_LOCATION_UPDATE_H_
std::ostream & operator<<(std::ostream &out, const Accuracy< T > &update)
Definition accuracy.h:68
Definition accuracy.h:24
static Timestamp now()
Samples a timestamp from the clock.
Definition clock.h:51
std::chrono::high_resolution_clock::time_point Timestamp
Timestamp type of the location service clock.
Definition clock.h:45
static Timestamp beginning_of_time()
Samples a timestamp from the clock.
Definition clock.h:60
Templated class that wraps a value and timestamp.
Definition update.h:37
bool operator!=(const Update< T > &rhs) const
operator != checks if two updates are unequal.
Definition update.h:64
bool operator==(const Update< T > &rhs) const
operator == checks if two updates are equal.
Definition update.h:54
Update(const T &value=T{}, const Clock::Timestamp &when=Clock::now())
Constructs a valid update with the given value and timestamp.
Definition update.h:43
Clock::Timestamp when
Definition update.h:73