radio_cell.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_CONNECTIVITY_RADIO_CELL_H_
#define LOCATION_SERVICE_COM_LOMIRI_LOCATION_CONNECTIVITY_RADIO_CELL_H_
#include <com/lomiri/location/connectivity/bounded_integer.h>
#include <core/signal.h>
#include <limits>
#include <memory>
namespace com
{
namespace lomiri
{
namespace location
{
namespace connectivity
{
struct RadioCell
{
typedef std::shared_ptr<RadioCell> Ptr;
enum class Type
{
unknown,
gsm,
umts,
lte
};
struct Mcc {};
struct Mnc {};
struct Lac {};
struct Id {};
struct Psc {};
struct Pid {};
struct Rss {};
struct Asu {};
struct Ta {};
template<int min, int max, int invalid = min-1>
using MobileCountryCode = BoundedInteger<Mcc, min, max, invalid>;
template<int min, int max, int invalid = min-1>
using MobileNetworkCode = BoundedInteger<Mnc, min, max, invalid>;
template<int min, int max, int invalid = min-1>
using LocationAreaCode = BoundedInteger<Lac, min, max, invalid>;
template<int min, int max, int invalid = min-1>
using TrackingAreaCode = BoundedInteger<Lac, min, max, invalid>;
template<int min, int max, int invalid = min-1>
using CellId = BoundedInteger<Id, min, max, invalid>;
template<int min, int max, int invalid = min-1>
using PrimaryScramblingCode = BoundedInteger<Psc, min, max, invalid>;
template<int min, int max, int invalid = min-1>
using PhysicalId = BoundedInteger<Pid, min, max, invalid>;
template<int min, int max, int invalid = min-1>
using ReceivedSignalStrength = BoundedInteger<Rss, min, max, invalid>;
template<int min, int max, int invalid = min-1>
using ArbitraryStrengthUnit = BoundedInteger<Asu, min, max, invalid>;
template<int min, int max, int invalid = min-1>
using TimingAdvance = BoundedInteger<Ta, min, max, invalid>;
struct Gsm
{
typedef MobileCountryCode
<
0,
999,
std::numeric_limits<int>::max()
> MCC;
typedef MobileNetworkCode
<
0,
999,
std::numeric_limits<int>::max()
> MNC;
typedef LocationAreaCode
<
0,
65535,
std::numeric_limits<int>::max()
> LAC;
typedef CellId
<
0,
65535,
std::numeric_limits<int>::max()
> ID;
typedef ArbitraryStrengthUnit
<
0,
31,
99
> SignalStrength;
MCC mobile_country_code;
MNC mobile_network_code;
LAC location_area_code;
ID id;
SignalStrength strength;
};
struct Umts
{
typedef MobileCountryCode
<
0,
999,
std::numeric_limits<int>::max()
> MCC;
typedef MobileNetworkCode
<
0,
999,
std::numeric_limits<int>::max()
> MNC;
typedef LocationAreaCode
<
0,
65535,
std::numeric_limits<int>::max()
> LAC;
typedef CellId
<
0,
268435455,
std::numeric_limits<int>::max()
> ID;
typedef ArbitraryStrengthUnit
<
0,
31,
99
> SignalStrength;
MCC mobile_country_code;
MNC mobile_network_code;
LAC location_area_code;
ID id;
SignalStrength strength;
};
struct Lte
{
typedef MobileCountryCode
<
0,
999,
std::numeric_limits<int>::max()
> MCC;
typedef MobileNetworkCode
<
0,
999,
std::numeric_limits<int>::max()
> MNC;
typedef TrackingAreaCode
<
0,
65535,
std::numeric_limits<int>::max()
> TAC;
typedef CellId
<
0,
268435455,
std::numeric_limits<int>::max()
> ID;
typedef PhysicalId
<
0,
503,
std::numeric_limits<int>::max()
> PID;
typedef ArbitraryStrengthUnit
<
0,
31,
99
> SignalStrength;
MCC mobile_country_code;
MNC mobile_network_code;
TAC tracking_area_code;
ID id;
PID physical_id;
SignalStrength strength;
};
RadioCell() = default;
virtual ~RadioCell() = default;
RadioCell(const RadioCell& rhs) = delete;
RadioCell& operator=(const RadioCell& rhs) = delete;
virtual const core::Signal<>& changed() const = 0;
virtual Type type() const = 0;
virtual const Gsm& gsm() const = 0;
virtual const Umts& umts() const = 0;
virtual const Lte& lte() const = 0;
};
bool operator==(const RadioCell::Gsm& lhs, const RadioCell::Gsm& rhs);
std::ostream& operator<<(std::ostream& out, const RadioCell::Gsm& gsm);
bool operator==(const RadioCell::Umts& lhs, const RadioCell::Umts& rhs);
std::ostream& operator<<(std::ostream& out, const RadioCell::Umts& umts);
bool operator==(const RadioCell::Lte& lhs, const RadioCell::Lte& rhs);
std::ostream& operator<<(std::ostream& out, const RadioCell::Lte& lte);
bool operator==(const RadioCell& lhs, const RadioCell& rhs);
std::ostream& operator<<(std::ostream& out, const RadioCell& cell);
}
}
}
}
#endif // LOCATION_SERVICE_COM_LOMIRI_LOCATION_CONNECTIVITY_RADIO_CELL_H_
bounded_integer.h
com::lomiri::location::connectivity
Definition bounded_integer.h:31
com::lomiri::location::connectivity::operator==
bool operator==(const RadioCell::Gsm &lhs, const RadioCell::Gsm &rhs)
Returns true iff lhs equals rhs.
com::lomiri::location::connectivity::operator<<
std::ostream & operator<<(std::ostream &out, State state)
Pretty prints the given state to the given output stream.
com::lomiri::location
Definition accuracy.h:28
com::lomiri
Definition accuracy.h:26
com
Definition accuracy.h:24
com::lomiri::location::connectivity::RadioCell::Gsm
Models a GSM radio cell.
Definition radio_cell.h:87
com::lomiri::location::connectivity::RadioCell::Gsm::SignalStrength
ArbitraryStrengthUnit< 0, 31, 99 > SignalStrength
Definition radio_cell.h:123
com::lomiri::location::connectivity::RadioCell::Gsm::MCC
MobileCountryCode< 0, 999, std::numeric_limits< int >::max() > MCC
Definition radio_cell.h:94
com::lomiri::location::connectivity::RadioCell::Gsm::mobile_network_code
MNC mobile_network_code
Definition radio_cell.h:126
com::lomiri::location::connectivity::RadioCell::Gsm::MNC
MobileNetworkCode< 0, 999, std::numeric_limits< int >::max() > MNC
Definition radio_cell.h:101
com::lomiri::location::connectivity::RadioCell::Gsm::strength
SignalStrength strength
Definition radio_cell.h:129
com::lomiri::location::connectivity::RadioCell::Gsm::location_area_code
LAC location_area_code
Definition radio_cell.h:127
com::lomiri::location::connectivity::RadioCell::Gsm::id
ID id
Definition radio_cell.h:128
com::lomiri::location::connectivity::RadioCell::Gsm::mobile_country_code
MCC mobile_country_code
Definition radio_cell.h:125
com::lomiri::location::connectivity::RadioCell::Gsm::ID
CellId< 0, 65535, std::numeric_limits< int >::max() > ID
Definition radio_cell.h:115
com::lomiri::location::connectivity::RadioCell::Gsm::LAC
LocationAreaCode< 0, 65535, std::numeric_limits< int >::max() > LAC
Definition radio_cell.h:108
com::lomiri::location::connectivity::RadioCell::Lte
Models an LTE radio cell.
Definition radio_cell.h:180
com::lomiri::location::connectivity::RadioCell::Lte::MNC
MobileNetworkCode< 0, 999, std::numeric_limits< int >::max() > MNC
Definition radio_cell.h:194
com::lomiri::location::connectivity::RadioCell::Lte::mobile_country_code
MCC mobile_country_code
Definition radio_cell.h:224
com::lomiri::location::connectivity::RadioCell::Lte::ID
CellId< 0, 268435455, std::numeric_limits< int >::max() > ID
Definition radio_cell.h:208
com::lomiri::location::connectivity::RadioCell::Lte::mobile_network_code
MNC mobile_network_code
Definition radio_cell.h:225
com::lomiri::location::connectivity::RadioCell::Lte::tracking_area_code
TAC tracking_area_code
Definition radio_cell.h:226
com::lomiri::location::connectivity::RadioCell::Lte::physical_id
PID physical_id
Definition radio_cell.h:228
com::lomiri::location::connectivity::RadioCell::Lte::SignalStrength
ArbitraryStrengthUnit< 0, 31, 99 > SignalStrength
Definition radio_cell.h:222
com::lomiri::location::connectivity::RadioCell::Lte::id
ID id
Definition radio_cell.h:227
com::lomiri::location::connectivity::RadioCell::Lte::strength
SignalStrength strength
Definition radio_cell.h:229
com::lomiri::location::connectivity::RadioCell::Lte::PID
PhysicalId< 0, 503, std::numeric_limits< int >::max() > PID
Definition radio_cell.h:215
com::lomiri::location::connectivity::RadioCell::Lte::MCC
MobileCountryCode< 0, 999, std::numeric_limits< int >::max() > MCC
Definition radio_cell.h:187
com::lomiri::location::connectivity::RadioCell::Lte::TAC
TrackingAreaCode< 0, 65535, std::numeric_limits< int >::max() > TAC
Definition radio_cell.h:201
com::lomiri::location::connectivity::RadioCell::Umts
Models a UMTS radio cell.
Definition radio_cell.h:134
com::lomiri::location::connectivity::RadioCell::Umts::mobile_network_code
MNC mobile_network_code
Definition radio_cell.h:172
com::lomiri::location::connectivity::RadioCell::Umts::ID
CellId< 0, 268435455, std::numeric_limits< int >::max() > ID
Definition radio_cell.h:162
com::lomiri::location::connectivity::RadioCell::Umts::SignalStrength
ArbitraryStrengthUnit< 0, 31, 99 > SignalStrength
Definition radio_cell.h:169
com::lomiri::location::connectivity::RadioCell::Umts::id
ID id
Definition radio_cell.h:174
com::lomiri::location::connectivity::RadioCell::Umts::MNC
MobileNetworkCode< 0, 999, std::numeric_limits< int >::max() > MNC
Definition radio_cell.h:148
com::lomiri::location::connectivity::RadioCell::Umts::MCC
MobileCountryCode< 0, 999, std::numeric_limits< int >::max() > MCC
Definition radio_cell.h:141
com::lomiri::location::connectivity::RadioCell::Umts::strength
SignalStrength strength
Definition radio_cell.h:175
com::lomiri::location::connectivity::RadioCell::Umts::mobile_country_code
MCC mobile_country_code
Definition radio_cell.h:171
com::lomiri::location::connectivity::RadioCell::Umts::location_area_code
LAC location_area_code
Definition radio_cell.h:173
com::lomiri::location::connectivity::RadioCell::Umts::LAC
LocationAreaCode< 0, 65535, std::numeric_limits< int >::max() > LAC
Definition radio_cell.h:155
com::lomiri::location::connectivity::RadioCell
Models a radio cell that one of the modems in the system is connected to.
Definition radio_cell.h:38
com::lomiri::location::connectivity::RadioCell::RadioCell
RadioCell(const RadioCell &rhs)=delete
com::lomiri::location::connectivity::RadioCell::operator=
RadioCell & operator=(const RadioCell &rhs)=delete
com::lomiri::location::connectivity::RadioCell::Type
Type
Enumerates the known technologies.
Definition radio_cell.h:45
com::lomiri::location::connectivity::RadioCell::Type::unknown
@ unknown
Definition radio_cell.h:46
com::lomiri::location::connectivity::RadioCell::~RadioCell
virtual ~RadioCell()=default
com::lomiri::location::connectivity::RadioCell::changed
virtual const core::Signal & changed() const =0
Emitted when the cell details change.
com::lomiri::location::connectivity::RadioCell::type
virtual Type type() const =0
Returns the type of the radio cell.
com::lomiri::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::lomiri::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::lomiri::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::lomiri::location::connectivity::RadioCell::RadioCell
RadioCell()=default