lomiri-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_LOMIRI_LOCATION_CONNECTIVITY_RADIO_CELL_H_
19#define LOCATION_SERVICE_COM_LOMIRI_LOCATION_CONNECTIVITY_RADIO_CELL_H_
20
22
23#include <core/signal.h>
24
25#include <limits>
26#include <memory>
27
28namespace com
29{
30namespace lomiri
31{
32namespace location
33{
34namespace connectivity
35{
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()
103 typedef LocationAreaCode
104 <
105 0,
106 65535,
107 std::numeric_limits<int>::max()
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
124
130 };
131
133 struct Umts
134 {
136 typedef MobileCountryCode
137 <
138 0,
139 999,
140 std::numeric_limits<int>::max()
143 typedef MobileNetworkCode
144 <
145 0,
146 999,
147 std::numeric_limits<int>::max()
150 typedef LocationAreaCode
151 <
152 0,
153 65535,
154 std::numeric_limits<int>::max()
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
170
176 };
177
179 struct Lte
180 {
182 typedef MobileCountryCode
183 <
184 0,
185 999,
186 std::numeric_limits<int>::max()
189 typedef MobileNetworkCode
190 <
191 0,
192 999,
193 std::numeric_limits<int>::max()
196 typedef TrackingAreaCode
197 <
198 0,
199 65535,
200 std::numeric_limits<int>::max()
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()
217 typedef ArbitraryStrengthUnit
218 <
219 0,
220 31,
221 99
223
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
255bool operator==(const RadioCell::Gsm& lhs, const RadioCell::Gsm& rhs);
256
258std::ostream& operator<<(std::ostream& out, const RadioCell::Gsm& gsm);
259
261bool operator==(const RadioCell::Umts& lhs, const RadioCell::Umts& rhs);
262
264std::ostream& operator<<(std::ostream& out, const RadioCell::Umts& umts);
265
267bool operator==(const RadioCell::Lte& lhs, const RadioCell::Lte& rhs);
268
270std::ostream& operator<<(std::ostream& out, const RadioCell::Lte& lte);
271
273bool operator==(const RadioCell& lhs, const RadioCell& rhs);
274
276std::ostream& operator<<(std::ostream& out, const RadioCell& cell);
277}
278}
279}
280}
281
282#endif // LOCATION_SERVICE_COM_LOMIRI_LOCATION_CONNECTIVITY_RADIO_CELL_H_
283
bool operator==(const RadioCell::Gsm &lhs, const RadioCell::Gsm &rhs)
Returns true iff lhs equals rhs.
std::ostream & operator<<(std::ostream &out, State state)
Pretty prints the given state to the given output stream.
Definition accuracy.h:24
ArbitraryStrengthUnit< 0, 31, 99 > SignalStrength
Definition radio_cell.h:123
MobileCountryCode< 0, 999, std::numeric_limits< int >::max() > MCC
Definition radio_cell.h:94
MobileNetworkCode< 0, 999, std::numeric_limits< int >::max() > MNC
Definition radio_cell.h:101
CellId< 0, 65535, std::numeric_limits< int >::max() > ID
Definition radio_cell.h:115
LocationAreaCode< 0, 65535, std::numeric_limits< int >::max() > LAC
Definition radio_cell.h:108
MobileNetworkCode< 0, 999, std::numeric_limits< int >::max() > MNC
Definition radio_cell.h:194
CellId< 0, 268435455, std::numeric_limits< int >::max() > ID
Definition radio_cell.h:208
ArbitraryStrengthUnit< 0, 31, 99 > SignalStrength
Definition radio_cell.h:222
PhysicalId< 0, 503, std::numeric_limits< int >::max() > PID
Definition radio_cell.h:215
MobileCountryCode< 0, 999, std::numeric_limits< int >::max() > MCC
Definition radio_cell.h:187
TrackingAreaCode< 0, 65535, std::numeric_limits< int >::max() > TAC
Definition radio_cell.h:201
CellId< 0, 268435455, std::numeric_limits< int >::max() > ID
Definition radio_cell.h:162
ArbitraryStrengthUnit< 0, 31, 99 > SignalStrength
Definition radio_cell.h:169
MobileNetworkCode< 0, 999, std::numeric_limits< int >::max() > MNC
Definition radio_cell.h:148
MobileCountryCode< 0, 999, std::numeric_limits< int >::max() > MCC
Definition radio_cell.h:141
LocationAreaCode< 0, 65535, std::numeric_limits< int >::max() > LAC
Definition radio_cell.h:155
Models a radio cell that one of the modems in the system is connected to.
Definition radio_cell.h:38
RadioCell(const RadioCell &rhs)=delete
RadioCell & operator=(const RadioCell &rhs)=delete
Type
Enumerates the known technologies.
Definition radio_cell.h:45
virtual const core::Signal & changed() const =0
Emitted when the cell details change.
virtual Type type() const =0
Returns the type of the radio cell.
virtual const Gsm & gsm() const =0
Returns GSM-specific details or throws std::runtime_error if this is not a GSM radiocell.
virtual const Umts & umts() const =0
Returns UMTS-specific details or throws std::runtime_error if this is not a UMTS radiocell.
virtual const Lte & lte() const =0
Returns LTE-specific details or throws std::runtime_error if this is not an LTE radiocell.