accuracy.h
Go to the documentation of this file.
/*
* Copyright © 2012-2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*/
#ifndef LOCATION_SERVICE_COM_LOMIRI_LOCATION_ACCURACY_H_
#define LOCATION_SERVICE_COM_LOMIRI_LOCATION_ACCURACY_H_
#include <ostream>
namespace com
{
namespace lomiri
{
namespace location
{
enum class AccuracyLevel
{
country,
region,
locality,
postalcode,
street,
detailed,
best = detailed,
worst = country
};
template<typename T>
struct AccuracyTraits
{
static AccuracyLevel classify(const T& instance);
static T best();
static T worst();
};
template<typename T>
struct Accuracy
{
typedef typename T::Unit Unit;
typedef typename T::Quantity Quantity;
static Accuracy<T> best() { return AccuracyTraits<T>::best(); }
static Accuracy<T> worst() { return AccuracyTraits<T>::worst(); }
AccuracyLevel classify() const
{
return AccuracyTraits<T>::classify(value);
}
T value;
};
template<typename T>
inline std::ostream& operator<<(std::ostream& out, const Accuracy<T>& update)
{
out << "Accuracy(" << update.value << ")";
return out;
}
}
}
}
#endif // LOCATION_SERVICE_COM_LOMIRI_LOCATION_ACCURACY_H_
com::lomiri::location
Definition accuracy.h:28
com::lomiri::location::operator<<
std::ostream & operator<<(std::ostream &out, const Accuracy< T > &update)
Definition accuracy.h:68
com::lomiri::location::AccuracyLevel
AccuracyLevel
Definition accuracy.h:30
com::lomiri::location::AccuracyLevel::locality
@ locality
Definition accuracy.h:33
com::lomiri::location::AccuracyLevel::street
@ street
Definition accuracy.h:35
com::lomiri::location::AccuracyLevel::region
@ region
Definition accuracy.h:32
com::lomiri::location::AccuracyLevel::postalcode
@ postalcode
Definition accuracy.h:34
com::lomiri::location::AccuracyLevel::best
@ best
Definition accuracy.h:38
com::lomiri::location::AccuracyLevel::country
@ country
Definition accuracy.h:31
com::lomiri::location::AccuracyLevel::detailed
@ detailed
Definition accuracy.h:36
com::lomiri::location::AccuracyLevel::worst
@ worst
Definition accuracy.h:39
com::lomiri
Definition accuracy.h:26
com
Definition accuracy.h:24
com::lomiri::location::AccuracyTraits
Definition accuracy.h:44
com::lomiri::location::AccuracyTraits::classify
static AccuracyLevel classify(const T &instance)
com::lomiri::location::AccuracyTraits::worst
static T worst()
com::lomiri::location::AccuracyTraits::best
static T best()
com::lomiri::location::Accuracy
Definition accuracy.h:52
com::lomiri::location::Accuracy::best
static Accuracy< T > best()
Definition accuracy.h:56
com::lomiri::location::Accuracy::classify
AccuracyLevel classify() const
Definition accuracy.h:59
com::lomiri::location::Accuracy::Unit
T::Unit Unit
Definition accuracy.h:53
com::lomiri::location::Accuracy::value
T value
Definition accuracy.h:64
com::lomiri::location::Accuracy::worst
static Accuracy< T > worst()
Definition accuracy.h:57
com::lomiri::location::Accuracy::Quantity
T::Quantity Quantity
Definition accuracy.h:54