~thomas-voss/location-service/enable-gnd-messages

« back to all changes in this revision

Viewing changes to src/location/service/state.cpp

  • Committer: Thomas Voß
  • Date: 2016-06-26 21:17:03 UTC
  • mto: This revision was merged to the branch mainline in revision 259.
  • Revision ID: thomas.voss@canonical.com-20160626211703-aptpytiwrjdr1snn
Simplify namespaces.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17
17
 */
18
18
 
19
 
#include <com/ubuntu/location/service/state.h>
 
19
#include <location/service/state.h>
20
20
 
21
21
#include <map>
22
22
#include <type_traits>
23
23
 
24
 
namespace culs = com::ubuntu::location::service;
25
 
 
26
24
namespace
27
25
{
28
 
typedef typename std::underlying_type<culs::State>::type UT;
 
26
typedef typename std::underlying_type<location::service::State>::type UT;
29
27
 
30
 
typedef std::pair<std::map<culs::State, std::string>, std::map<std::string, culs::State>> Lut;
 
28
typedef std::pair<std::map<location::service::State, std::string>, std::map<std::string, location::service::State>> Lut;
31
29
 
32
30
const Lut& lut()
33
31
{
34
32
    static const Lut instance
35
33
    {
36
34
        {
37
 
            {culs::State::disabled, "disabled"},
38
 
            {culs::State::enabled, "enabled"},
39
 
            {culs::State::active, "active"}
 
35
            {location::service::State::disabled, "disabled"},
 
36
            {location::service::State::enabled, "enabled"},
 
37
            {location::service::State::active, "active"}
40
38
        },
41
39
        {
42
 
            {"disabled", culs::State::disabled},
43
 
            {"enabled", culs::State::enabled},
44
 
            {"active", culs::State::active}
 
40
            {"disabled", location::service::State::disabled},
 
41
            {"enabled", location::service::State::enabled},
 
42
            {"active", location::service::State::active}
45
43
        }
46
44
    };
47
45
 
49
47
}
50
48
}
51
49
 
52
 
bool culs::operator==(culs::State lhs, culs::State rhs)
 
50
bool location::service::operator==(location::service::State lhs, location::service::State rhs)
53
51
{
54
52
    return static_cast<UT>(lhs) == static_cast<UT>(rhs);
55
53
}
56
54
 
57
 
bool culs::operator!=(culs::State lhs, culs::State rhs)
 
55
bool location::service::operator!=(location::service::State lhs, location::service::State rhs)
58
56
{
59
57
    return static_cast<UT>(lhs) != static_cast<UT>(rhs);
60
58
}
61
59
 
62
 
std::ostream& culs::operator<<(std::ostream& out, culs::State state)
 
60
std::ostream& location::service::operator<<(std::ostream& out, location::service::State state)
63
61
{
64
62
    return out << lut().first.at(state);
65
63
}
66
64
 
67
 
std::istream& culs::operator>>(std::istream& in, culs::State& state)
 
65
std::istream& location::service::operator>>(std::istream& in, location::service::State& state)
68
66
{
69
67
    std::string s; in >> s; state = lut().second.at(s);
70
68
    return in;