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

ubuntu-location-service .. An aggregating location service providing positioning and geocoding capabilities to applications.

accuracy.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_ACCURACY_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_ACCURACY_H_
20
21 #include <ostream>
22
23 namespace com
24 {
25 namespace ubuntu
26 {
27 namespace location
28 {
29 enum class AccuracyLevel
30 {
31 country,
32 region,
33 locality,
34 postalcode,
35 street,
36 detailed,
37
38 best = detailed,
39 worst = country
40 };
41
42 template<typename T>
43 struct AccuracyTraits
44 {
45 static AccuracyLevel classify(const T& instance);
46 static T best();
47 static T worst();
48 };
49
50 template<typename T>
51 struct Accuracy
52 {
53 typedef typename T::Unit Unit;
54 typedef typename T::Quantity Quantity;
55
56 static Accuracy<T> best() { return AccuracyTraits<T>::best(); }
57 static Accuracy<T> worst() { return AccuracyTraits<T>::worst(); }
58
59 AccuracyLevel classify() const
60 {
61 return AccuracyTraits<T>::classify(value);
62 }
63
64 T value;
65 };
66
67 template<typename T>
68 inline std::ostream& operator<<(std::ostream& out, const Accuracy<T>& update)
69 {
70 out << "Accuracy(" << update.value << ")";
71 return out;
72 }
73
74 }
75 }
76 }
77
78 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_ACCURACY_H_
com::ubuntu::location::units::Quantity
boost::units::quantity< Unit, double > Quantity
Definition: units.h:53
com::ubuntu::location::AccuracyLevel
AccuracyLevel
Definition: accuracy.h:30
com::ubuntu::location::AccuracyLevel::locality
@ locality
com::ubuntu::location::AccuracyLevel::street
@ street
com::ubuntu::location::AccuracyLevel::region
@ region
com::ubuntu::location::AccuracyLevel::postalcode
@ postalcode
com::ubuntu::location::AccuracyLevel::best
@ best
com::ubuntu::location::AccuracyLevel::country
@ country
com::ubuntu::location::AccuracyLevel::detailed
@ detailed
com::ubuntu::location::AccuracyLevel::worst
@ worst
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::AccuracyTraits
Definition: accuracy.h:44
com::ubuntu::location::AccuracyTraits::best
static T best()
com::ubuntu::location::AccuracyTraits::classify
static AccuracyLevel classify(const T &instance)
com::ubuntu::location::AccuracyTraits::worst
static T worst()
com::ubuntu::location::Accuracy
Definition: accuracy.h:52
com::ubuntu::location::Accuracy::Quantity
T::Quantity Quantity
Definition: accuracy.h:54
com::ubuntu::location::Accuracy::Unit
T::Unit Unit
Definition: accuracy.h:53
com::ubuntu::location::Accuracy::value
T value
Definition: accuracy.h:64
com::ubuntu::location::Accuracy::worst
static Accuracy< T > worst()
Definition: accuracy.h:57
com::ubuntu::location::Accuracy::classify
AccuracyLevel classify() const
Definition: accuracy.h:59
com::ubuntu::location::Accuracy::best
static Accuracy< T > best()
Definition: accuracy.h:56