~xnox/location-service/drop-sys-events

« back to all changes in this revision

Viewing changes to include/location_service/com/ubuntu/location/connectivity/wireless_network.h

  • Committer: thomas-voss
  • Date: 2014-05-20 09:16:20 UTC
  • mto: This revision was merged to the branch mainline in revision 66.
  • Revision ID: thomas.voss@canonical.com-20140520091620-tiecez6hjvuiloel
Add standalone example for using the connectivity API.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <com/ubuntu/location/connectivity/bounded_integer.h>
22
22
 
 
23
#include <iosfwd>
23
24
#include <string>
24
25
 
25
26
namespace com
32
33
{
33
34
struct WirelessNetwork
34
35
{
 
36
    /** @brief Enumerates all known operational modes of networks/aps. */
35
37
    enum class Mode
36
38
    {
37
39
        /** Mode is unknown. */
42
44
        infrastructure = 2
43
45
    };
44
46
 
45
 
    inline friend std::ostream& operator<<(std::ostream& out, Mode mode)
46
 
    {
47
 
        switch (mode)
48
 
        {
49
 
        case Mode::unknown: out << "Mode::unknown"; break;
50
 
        case Mode::adhoc: out << "Mode::adhoc"; break;
51
 
        case Mode::infrastructure: out << "Mode::infrastructure"; break;
52
 
        }
53
 
 
54
 
        return out;
55
 
    }
56
 
 
 
47
    /** @cond */
57
48
    struct Tag
58
49
    {
59
50
        /** @brief Tags a frequency measurement for a wireless network. */
61
52
        /** @brief Tags the signal strength of a wireless network. */
62
53
        struct SignalStrength {};
63
54
    };
 
55
    /** @endcond */
64
56
 
65
57
    /** Frequency that an individual AP operates on. */
66
58
    typedef BoundedInteger
78
70
        100
79
71
    > SignalStrength;
80
72
 
81
 
    bool operator==(const WirelessNetwork& rhs) const
82
 
    {
83
 
        return bssid == rhs.bssid &&
84
 
               ssid == rhs.ssid &&
85
 
               mode == rhs.mode &&
86
 
               frequency == rhs.frequency &&
87
 
               signal_strength == rhs.signal_strength;
88
 
    }
89
 
 
90
 
    friend std::ostream& operator<<(std::ostream& out, const WirelessNetwork& wifi)
91
 
    {
92
 
        return out << "("
93
 
                   << "bssid: " << wifi.bssid << ", "
94
 
                   << "ssid: " << wifi.ssid << ", "
95
 
                   << "mode: " << wifi.mode << ", "
96
 
                   << "frequency: " << wifi.frequency << ", "
97
 
                   << "strength: " << wifi.signal_strength
98
 
                   << ")";
99
 
    }
100
 
 
101
73
    std::string bssid; ///< The BSSID of the network.
102
74
    std::string ssid; ///< The SSID of the network.
103
75
    Mode mode; ///< The mode of the network.
104
76
    Frequency frequency; ///< Frequency of the network/AP.
105
77
    SignalStrength signal_strength; ///< Signal quality of the network/AP in percent.
106
78
};
 
79
 
 
80
/** @brief Returns true iff lhs equals rhs. */
 
81
bool operator==(const WirelessNetwork& lhs, const WirelessNetwork& rhs);
 
82
 
 
83
/** @brief Pretty-prints the given mode to the given output stream. */
 
84
std::ostream& operator<<(std::ostream& out, WirelessNetwork::Mode mode);
 
85
 
 
86
/** @brief Pretty-prints the given wireless network to the given output stream. */
 
87
std::ostream& operator<<(std::ostream& out, const WirelessNetwork& wifi);
107
88
}
108
89
}
109
90
}