ubuntu-location-service  ..
An aggregating location service providing positioning and geocoding capabilities to applications.
engine.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_ENGINE_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_ENGINE_H_
20 
27 
28 #include <core/property.h>
29 
30 #include <mutex>
31 #include <set>
32 
33 namespace com
34 {
35 namespace ubuntu
36 {
37 namespace location
38 {
39 struct Criteria;
40 class ProviderSelectionPolicy;
45 class Engine : public ProviderEnumerator
46 {
47 public:
48  typedef std::shared_ptr<Engine> Ptr;
49 
53  enum class Status
54  {
55  off,
56  on,
57  active
58  };
59 
64  {
66  core::Property<SatelliteBasedPositioningState> satellite_based_positioning_state
67  {
69  };
71  core::Property<WifiAndCellIdReportingState> wifi_and_cell_id_reporting_state
72  {
74  };
76  core::Property<Engine::Status> engine_state
77  {
79  };
80  };
81 
83  struct Updates
84  {
86  core::Property<Update<Position>> reference_location{};
88  core::Property<Update<Velocity>> reference_velocity{};
90  core::Property<Update<Heading>> reference_heading{};
92  core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>> visible_space_vehicles{};
93  };
94 
95  Engine(const std::shared_ptr<ProviderSelectionPolicy>& provider_selection_policy);
96  Engine(const Engine&) = delete;
97  Engine& operator=(const Engine&) = delete;
98  virtual ~Engine();
99 
106 
111  virtual bool has_provider(const Provider::Ptr& provider) noexcept;
112 
117  virtual void add_provider(const Provider::Ptr& provider);
118 
123  virtual void remove_provider(const Provider::Ptr& provider) noexcept;
124 
129  virtual void for_each_provider(const std::function<void(const Provider::Ptr&)>& enumerator) const noexcept;
130 
133 
136 
137 private:
138  struct ProviderConnections
139  {
140  core::ScopedConnection reference_location_updates;
141  core::ScopedConnection reference_velocity_updates;
142  core::ScopedConnection reference_heading_updates;
143  core::ScopedConnection wifi_and_cell_id_reporting_state_updates;
144  core::ScopedConnection space_vehicle_visibility_updates;
145  core::ScopedConnection provider_position_updates;
146  };
147 
148  mutable std::mutex guard;
149  std::map<Provider::Ptr, ProviderConnections> providers;
150  std::shared_ptr<ProviderSelectionPolicy> provider_selection_policy;
151 };
152 }
153 }
154 }
155 
156 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_ENGINE_H_
Status
The State enum models the current state of the engine.
Definition: engine.h:53
The Engine class encapsulates a positioning engine, relying on a set of providers and reporters to ac...
Definition: engine.h:45
virtual void for_each_provider(const std::function< void(const Provider::Ptr &)> &enumerator) const noexcept
Iterates all known providers and invokes the provided enumerator for each of them.
core::Property< Update< Position > > reference_location
Definition: engine.h:86
Definition: accuracy.h:23
core::Property< Update< Heading > > reference_heading
Definition: engine.h:90
Engine(const std::shared_ptr< ProviderSelectionPolicy > &provider_selection_policy)
The engine and providers are powered on but not navigating.
core::Property< Update< Velocity > > reference_velocity
Definition: engine.h:88
core::Property< SatelliteBasedPositioningState > satellite_based_positioning_state
Definition: engine.h:67
core::Property< WifiAndCellIdReportingState > wifi_and_cell_id_reporting_state
Definition: engine.h:72
core::Property< std::map< SpaceVehicle::Key, SpaceVehicle > > visible_space_vehicles
Definition: engine.h:92
The Configuration struct summarizes the state of the engine.
Definition: engine.h:63
virtual bool has_provider(const Provider::Ptr &provider) noexcept
Checks if the engine knows about a specific provider.
core::Property< Engine::Status > engine_state
Definition: engine.h:77
Engine & operator=(const Engine &)=delete
std::shared_ptr< Provider > Ptr
Definition: provider.h:48
Configuration configuration
The engine's configuration.
Definition: engine.h:132
Wifi and Cell Ids are not reported. This is the default value.
The engine and providers are powered on and navigating.
The engine is currently offline.
Updates updates
All updates distributed via the engine.
Definition: engine.h:135
Satellite assisted positioning is on.
virtual void remove_provider(const Provider::Ptr &provider) noexcept
Removes a provider from the engine.
Summarizes criteria of a client session with respect to functionality and accuracy for position...
Definition: criteria.h:34
std::shared_ptr< Engine > Ptr
Definition: engine.h:48
virtual void add_provider(const Provider::Ptr &provider)
Makes a provider known to the engine.
virtual ProviderSelection determine_provider_selection_for_criteria(const Criteria &criteria)
Calculates a set of providers that satisfies the given criteria.
Summarizes all updates delivered via the engine.
Definition: engine.h:83