Mir
platform.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014-2015 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:
17  * Andreas Pokorny <andreas.pokorny@canonical.com>
18  */
19 
20 #ifndef MIR_INPUT_PLATFORM_H_
21 #define MIR_INPUT_PLATFORM_H_
22 
23 #include "mir/module_properties.h"
24 
25 #include <mir/options/option.h>
26 #include <mir/module_deleter.h>
27 
28 #include <boost/program_options/options_description.hpp>
29 
30 #include <memory>
31 
32 namespace mir
33 {
34 class EmergencyCleanupRegistry;
35 
36 namespace dispatch
37 {
38 class Dispatchable;
39 }
40 
41 namespace input
42 {
43 class InputDevice;
44 class InputReport;
45 class InputDeviceRegistry;
46 class InputPlatformPolicy;
47 
48 enum class PlatformPriority : uint32_t
49 {
50  unsupported = 0,
51  dummy = 1,
52  supported = 128,
53  best = 256,
54 };
55 
65 class Platform
66 {
67 public:
68  Platform() = default;
69  virtual ~Platform() = default;
70 
74  virtual std::shared_ptr<mir::dispatch::Dispatchable> dispatchable() = 0;
75 
79  virtual void start() = 0;
83  virtual void stop() = 0;
84 
85 private:
86  Platform(Platform const&) = delete;
87  Platform& operator=(Platform const&) = delete;
88 };
89 
90 typedef mir::UniqueModulePtr<Platform>(*CreatePlatform)(
91  options::Option const& options,
92  std::shared_ptr<EmergencyCleanupRegistry> const& emergency_cleanup_registry,
93  std::shared_ptr<InputDeviceRegistry> const& input_device_registry,
94  std::shared_ptr<InputReport> const& report);
95 
96 typedef void(*AddPlatformOptions)(
97  boost::program_options::options_description& config);
98 
100  options::Option const& options);
101 
102 typedef ModuleProperties const*(*DescribeModule)();
103 
104 }
105 }
106 
107 extern "C"
108 {
109 #if defined(__clang__)
110 #pragma clang diagnostic push
111 // These functions are given "C" linkage to avoid name-mangling, not for C compatibility.
112 // (We don't want a warning for doing this intentionally.)
113 #pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
114 #endif
115 
129  mir::options::Option const& options,
130  std::shared_ptr<mir::EmergencyCleanupRegistry> const& emergency_cleanup_registry,
131  std::shared_ptr<mir::input::InputDeviceRegistry> const& input_device_registry,
132  std::shared_ptr<mir::input::InputReport> const& report);
133 
143 void add_input_platform_options(boost::program_options::options_description& config);
144 
156 
165 
166 #if defined(__clang__)
167 #pragma clang diagnostic pop
168 #endif
169 }
170 #endif // MIR_INPUT_PLATFORM_H_
mir::ModuleProperties const * describe_input_module()
describe_input_module should return a description of the input platform.
Definition: as_render_target.h:27
PlatformPriority(* ProbePlatform)(options::Option const &options)
Definition: platform.h:99
PlatformPriority
Definition: platform.h:48
Input Platform is used to discover and access available input devices.
Definition: platform.h:65
std::unique_ptr< T, ModuleDeleter< T >> UniqueModulePtr
Use UniqueModulePtr to ensure that your loadable libray outlives instances created within it...
Definition: module_deleter.h:83
mir::input::PlatformPriority probe_input_platform(mir::options::Option const &options)
probe_platform should indicate whether the platform is able to work within the current environment...
void(* AddPlatformOptions)(boost::program_options::options_description &config)
Definition: platform.h:96
Describes a platform module.
Definition: module_properties.h:33
mir::UniqueModulePtr< mir::input::Platform > create_input_platform(mir::options::Option const &options, std::shared_ptr< mir::EmergencyCleanupRegistry > const &emergency_cleanup_registry, std::shared_ptr< mir::input::InputDeviceRegistry > const &input_device_registry, std::shared_ptr< mir::input::InputReport > const &report)
Function used to initialize an input platform.
void add_input_platform_options(boost::program_options::options_description &config)
Function used to add additional configuration options.
Definition: option.h:33

Copyright © 2012-2016 Canonical Ltd.
Generated on Wed May 10 10:41:27 UTC 2017