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

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

radio_cell.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_CONNECTIVITY_RADIO_CELL_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_RADIO_CELL_H_
20
21 #include <com/ubuntu/location/connectivity/bounded_integer.h>
22
23 #include <core/signal.h>
24
25 #include <limits>
26 #include <memory>
27
28 namespace com
29 {
30 namespace ubuntu
31 {
32 namespace location
33 {
34 namespace connectivity
35 {
37 struct RadioCell
38 {
40 typedef std::shared_ptr<RadioCell> Ptr;
44 enum class Type
45 {
46 unknown,
47 gsm,
48 umts,
49 lte
50 };
51
53 struct Mcc {};
54 struct Mnc {};
55 struct Lac {};
56 struct Id {};
57 struct Psc {};
58 struct Pid {};
59 struct Rss {};
60 struct Asu {};
61 struct Ta {};
62
63 template<int min, int max, int invalid = min-1>
64 using MobileCountryCode = BoundedInteger<Mcc, min, max, invalid>;
65 template<int min, int max, int invalid = min-1>
66 using MobileNetworkCode = BoundedInteger<Mnc, min, max, invalid>;
67 template<int min, int max, int invalid = min-1>
68 using LocationAreaCode = BoundedInteger<Lac, min, max, invalid>;
69 template<int min, int max, int invalid = min-1>
70 using TrackingAreaCode = BoundedInteger<Lac, min, max, invalid>;
71 template<int min, int max, int invalid = min-1>
72 using CellId = BoundedInteger<Id, min, max, invalid>;
73 template<int min, int max, int invalid = min-1>
74 using PrimaryScramblingCode = BoundedInteger<Psc, min, max, invalid>;
75 template<int min, int max, int invalid = min-1>
76 using PhysicalId = BoundedInteger<Pid, min, max, invalid>;
77 template<int min, int max, int invalid = min-1>
78 using ReceivedSignalStrength = BoundedInteger<Rss, min, max, invalid>;
79 template<int min, int max, int invalid = min-1>
80 using ArbitraryStrengthUnit = BoundedInteger<Asu, min, max, invalid>;
81 template<int min, int max, int invalid = min-1>
82 using TimingAdvance = BoundedInteger<Ta, min, max, invalid>;
86 struct Gsm
87 {
89 typedef MobileCountryCode
90 <
91 0,
92 999,
93 std::numeric_limits<int>::max()
94 > MCC;
96 typedef MobileNetworkCode
97 <
98 0,
99 999,
100 std::numeric_limits<int>::max()
101 > MNC;
103 typedef LocationAreaCode
104 <
105 0,
106 65535,
107 std::numeric_limits<int>::max()
108 > LAC;
110 typedef CellId
111 <
112 0,
113 65535,
114 std::numeric_limits<int>::max()
115 > ID;
116
118 typedef ArbitraryStrengthUnit
119 <
120 0,
121 31,
122 99
123 > SignalStrength;
124
125 MCC mobile_country_code;
126 MNC mobile_network_code;
127 LAC location_area_code;
128 ID id;
129 SignalStrength strength;
130 };
131
133 struct Umts
134 {
136 typedef MobileCountryCode
137 <
138 0,
139 999,
140 std::numeric_limits<int>::max()
141 > MCC;
143 typedef MobileNetworkCode
144 <
145 0,
146 999,
147 std::numeric_limits<int>::max()
148 > MNC;
150 typedef LocationAreaCode
151 <
152 0,
153 65535,
154 std::numeric_limits<int>::max()
155 > LAC;
157 typedef CellId
158 <
159 0,
160 268435455,
161 std::numeric_limits<int>::max()
162 > ID;
164 typedef ArbitraryStrengthUnit
165 <
166 0,
167 31,
168 99
169 > SignalStrength;
170
171 MCC mobile_country_code;
172 MNC mobile_network_code;
173 LAC location_area_code;
174 ID id;
175 SignalStrength strength;
176 };
177
179 struct Lte
180 {
182 typedef MobileCountryCode
183 <
184 0,
185 999,
186 std::numeric_limits<int>::max()
187 > MCC;
189 typedef MobileNetworkCode
190 <
191 0,
192 999,
193 std::numeric_limits<int>::max()
194 > MNC;
196 typedef TrackingAreaCode
197 <
198 0,
199 65535,
200 std::numeric_limits<int>::max()
201 > TAC;
203 typedef CellId
204 <
205 0,
206 268435455,
207 std::numeric_limits<int>::max()
208 > ID;
210 typedef PhysicalId
211 <
212 0,
213 503,
214 std::numeric_limits<int>::max()
215 > PID;
217 typedef ArbitraryStrengthUnit
218 <
219 0,
220 31,
221 99
222 > SignalStrength;
223
224 MCC mobile_country_code;
225 MNC mobile_network_code;
226 TAC tracking_area_code;
227 ID id;
228 PID physical_id;
229 SignalStrength strength;
230 };
231
232 RadioCell() = default;
233 virtual ~RadioCell() = default;
234
235 RadioCell(const RadioCell& rhs) = delete;
236 RadioCell& operator=(const RadioCell& rhs) = delete;
237
239 virtual const core::Signal<>& changed() const = 0;
240
242 virtual Type type() const = 0;
243
245 virtual const Gsm& gsm() const = 0;
246
248 virtual const Umts& umts() const = 0;
249
251 virtual const Lte& lte() const = 0;
252 };
253
255 bool operator==(const RadioCell::Gsm& lhs, const RadioCell::Gsm& rhs);
256
258 std::ostream& operator<<(std::ostream& out, const RadioCell::Gsm& gsm);
259
261 bool operator==(const RadioCell::Umts& lhs, const RadioCell::Umts& rhs);
262
264 std::ostream& operator<<(std::ostream& out, const RadioCell::Umts& umts);
265
267 bool operator==(const RadioCell::Lte& lhs, const RadioCell::Lte& rhs);
268
270 std::ostream& operator<<(std::ostream& out, const RadioCell::Lte& lte);
271
273 bool operator==(const RadioCell& lhs, const RadioCell& rhs);
274
276 std::ostream& operator<<(std::ostream& out, const RadioCell& cell);
277 }
278 }
279 }
280 }
281
282 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_RADIO_CELL_H_
283
bounded_integer.h
com::ubuntu::location::connectivity::operator<<
std::ostream & operator<<(std::ostream &out, State state)
Pretty prints the given state to the given output stream.
com::ubuntu::location::connectivity::operator==
bool operator==(const RadioCell::Gsm &lhs, const RadioCell::Gsm &rhs)
Returns true iff lhs equals rhs.
com
Definition: accuracy.h:24
com::ubuntu::location::connectivity::RadioCell::Gsm
Models a GSM radio cell.
Definition: radio_cell.h:87
com::ubuntu::location::connectivity::RadioCell::Gsm::strength
SignalStrength strength
Definition: radio_cell.h:129
com::ubuntu::location::connectivity::RadioCell::Gsm::LAC
LocationAreaCode< 0, 65535, std::numeric_limits< int >::max() > LAC
Definition: radio_cell.h:108
com::ubuntu::location::connectivity::RadioCell::Gsm::location_area_code
LAC location_area_code
Definition: radio_cell.h:127
com::ubuntu::location::connectivity::RadioCell::Gsm::id
ID id
Definition: radio_cell.h:128
com::ubuntu::location::connectivity::RadioCell::Gsm::MNC
MobileNetworkCode< 0, 999, std::numeric_limits< int >::max() > MNC
Definition: radio_cell.h:101
com::ubuntu::location::connectivity::RadioCell::Gsm::mobile_country_code
MCC mobile_country_code
Definition: radio_cell.h:125
com::ubuntu::location::connectivity::RadioCell::Gsm::MCC
MobileCountryCode< 0, 999, std::numeric_limits< int >::max() > MCC
Definition: radio_cell.h:94
com::ubuntu::location::connectivity::RadioCell::Gsm::ID
CellId< 0, 65535, std::numeric_limits< int >::max() > ID
Definition: radio_cell.h:115
com::ubuntu::location::connectivity::RadioCell::Gsm::mobile_network_code
MNC mobile_network_code
Definition: radio_cell.h:126
com::ubuntu::location::connectivity::RadioCell::Gsm::SignalStrength
ArbitraryStrengthUnit< 0, 31, 99 > SignalStrength
Definition: radio_cell.h:123
com::ubuntu::location::connectivity::RadioCell::Lte
Models an LTE radio cell.
Definition: radio_cell.h:180
com::ubuntu::location::connectivity::RadioCell::Lte::MNC
MobileNetworkCode< 0, 999, std::numeric_limits< int >::max() > MNC
Definition: radio_cell.h:194
com::ubuntu::location::connectivity::RadioCell::Lte::ID
CellId< 0, 268435455, std::numeric_limits< int >::max() > ID
Definition: radio_cell.h:208
com::ubuntu::location::connectivity::RadioCell::Lte::id
ID id
Definition: radio_cell.h:227
com::ubuntu::location::connectivity::RadioCell::Lte::mobile_country_code
MCC mobile_country_code
Definition: radio_cell.h:224
com::ubuntu::location::connectivity::RadioCell::Lte::TAC
TrackingAreaCode< 0, 65535, std::numeric_limits< int >::max() > TAC
Definition: radio_cell.h:201
com::ubuntu::location::connectivity::RadioCell::Lte::tracking_area_code
TAC tracking_area_code
Definition: radio_cell.h:226
com::ubuntu::location::connectivity::RadioCell::Lte::SignalStrength
ArbitraryStrengthUnit< 0, 31, 99 > SignalStrength
Definition: radio_cell.h:222
com::ubuntu::location::connectivity::RadioCell::Lte::mobile_network_code
MNC mobile_network_code
Definition: radio_cell.h:225
com::ubuntu::location::connectivity::RadioCell::Lte::physical_id
PID physical_id
Definition: radio_cell.h:228
com::ubuntu::location::connectivity::RadioCell::Lte::MCC
MobileCountryCode< 0, 999, std::numeric_limits< int >::max() > MCC
Definition: radio_cell.h:187
com::ubuntu::location::connectivity::RadioCell::Lte::strength
SignalStrength strength
Definition: radio_cell.h:229
com::ubuntu::location::connectivity::RadioCell::Lte::PID
PhysicalId< 0, 503, std::numeric_limits< int >::max() > PID
Definition: radio_cell.h:215
com::ubuntu::location::connectivity::RadioCell::Umts
Models a UMTS radio cell.
Definition: radio_cell.h:134
com::ubuntu::location::connectivity::RadioCell::Umts::MNC
MobileNetworkCode< 0, 999, std::numeric_limits< int >::max() > MNC
Definition: radio_cell.h:148
com::ubuntu::location::connectivity::RadioCell::Umts::id
ID id
Definition: radio_cell.h:174
com::ubuntu::location::connectivity::RadioCell::Umts::ID
CellId< 0, 268435455, std::numeric_limits< int >::max() > ID
Definition: radio_cell.h:162
com::ubuntu::location::connectivity::RadioCell::Umts::mobile_country_code
MCC mobile_country_code
Definition: radio_cell.h:171
com::ubuntu::location::connectivity::RadioCell::Umts::MCC
MobileCountryCode< 0, 999, std::numeric_limits< int >::max() > MCC
Definition: radio_cell.h:141
com::ubuntu::location::connectivity::RadioCell::Umts::mobile_network_code
MNC mobile_network_code
Definition: radio_cell.h:172
com::ubuntu::location::connectivity::RadioCell::Umts::location_area_code
LAC location_area_code
Definition: radio_cell.h:173
com::ubuntu::location::connectivity::RadioCell::Umts::LAC
LocationAreaCode< 0, 65535, std::numeric_limits< int >::max() > LAC
Definition: radio_cell.h:155
com::ubuntu::location::connectivity::RadioCell::Umts::strength
SignalStrength strength
Definition: radio_cell.h:175
com::ubuntu::location::connectivity::RadioCell::Umts::SignalStrength
ArbitraryStrengthUnit< 0, 31, 99 > SignalStrength
Definition: radio_cell.h:169
com::ubuntu::location::connectivity::RadioCell
Models a radio cell that one of the modems in the system is connected to.
Definition: radio_cell.h:38
com::ubuntu::location::connectivity::RadioCell::type
virtual Type type() const =0
Returns the type of the radio cell.
com::ubuntu::location::connectivity::RadioCell::umts
virtual const Umts & umts() const =0
Returns UMTS-specific details or throws std::runtime_error if this is not a UMTS radiocell.
com::ubuntu::location::connectivity::RadioCell::lte
virtual const Lte & lte() const =0
Returns LTE-specific details or throws std::runtime_error if this is not an LTE radiocell.
com::ubuntu::location::connectivity::RadioCell::Type
Type
Enumerates the known technologies.
Definition: radio_cell.h:45
com::ubuntu::location::connectivity::RadioCell::Type::lte
@ lte
com::ubuntu::location::connectivity::RadioCell::Type::gsm
@ gsm
com::ubuntu::location::connectivity::RadioCell::Type::umts
@ umts
com::ubuntu::location::connectivity::RadioCell::Type::unknown
@ unknown
com::ubuntu::location::connectivity::RadioCell::changed
virtual const core::Signal & changed() const =0
Emitted when the cell details change.
com::ubuntu::location::connectivity::RadioCell::operator=
RadioCell & operator=(const RadioCell &rhs)=delete
com::ubuntu::location::connectivity::RadioCell::gsm
virtual const Gsm & gsm() const =0
Returns GSM-specific details or throws std::runtime_error if this is not a GSM radiocell.
com::ubuntu::location::connectivity::RadioCell::RadioCell
RadioCell(const RadioCell &rhs)=delete
com::ubuntu::location::connectivity::RadioCell::~RadioCell
virtual ~RadioCell()=default
com::ubuntu::location::connectivity::RadioCell::RadioCell
RadioCell()=default