ubuntu-location-service: /build/location-service-git/src/location-service/include/location_service/com/ubuntu/location/update.h Source File

ubuntu-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_UBUNTU_LOCATION_UPDATE_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_
20
21 #include <com/ubuntu/location/clock.h>
22
23 #include <ostream>
24
25 namespace com
26 {
27 namespace ubuntu
28 {
29 namespace location
30 {
35 template<typename T>
36 struct Update
37 {
43 inline Update(const T& value = T{},
44 const Clock::Timestamp& when = Clock::now())
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
70 T value;
71
73 Clock::Timestamp when = Clock::beginning_of_time();
74 };
75
81 template<typename T>
82 inline 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_UBUNTU_LOCATION_UPDATE_H_
clock.h
com::ubuntu::location::operator<<
std::ostream & operator<<(std::ostream &out, const Accuracy< T > &update)
Definition: accuracy.h:68
com
Definition: accuracy.h:24
com::ubuntu::location::Clock::Timestamp
std::chrono::high_resolution_clock::time_point Timestamp
Timestamp type of the location service clock.
Definition: clock.h:45
com::ubuntu::location::Clock::now
static Timestamp now()
Samples a timestamp from the clock.
Definition: clock.h:51
com::ubuntu::location::Clock::beginning_of_time
static Timestamp beginning_of_time()
Samples a timestamp from the clock.
Definition: clock.h:60
com::ubuntu::location::Update
Templated class that wraps a value and timestamp.
Definition: update.h:37
com::ubuntu::location::Update::operator==
bool operator==(const Update< T > &rhs) const
operator == checks if two updates are equal.
Definition: update.h:54
com::ubuntu::location::Update::when
Clock::Timestamp when
Definition: update.h:73
com::ubuntu::location::Update::value
T value
Definition: update.h:70
com::ubuntu::location::Update::operator!=
bool operator!=(const Update< T > &rhs) const
operator != checks if two updates are unequal.
Definition: update.h:64
com::ubuntu::location::Update::Update
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