KeyboardScaffold.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_DEVICES_KEYBOARD_KEYBOARDSCAFFOLD_H
17 #define SURGSIM_DEVICES_KEYBOARD_KEYBOARDSCAFFOLD_H
18 
19 #include <memory>
20 
22 
23 namespace SurgSim
24 {
25 
26 namespace DataStructures
27 {
28 class DataGroup;
29 }
30 
31 namespace Device
32 {
33 class KeyboardDevice;
34 class OsgKeyboardHandler;
35 
39 {
40  friend class KeyboardDevice;
41  friend class KeyboardDeviceTest;
42  friend class OsgKeyboardHandler;
43 
44 public:
48  explicit KeyboardScaffold(std::shared_ptr<SurgSim::Framework::Logger> logger = nullptr);
51 
54  std::shared_ptr<SurgSim::Framework::Logger> getLogger() const;
55 
59  static std::shared_ptr<KeyboardScaffold> getOrCreateSharedInstance();
60 
65 
66 private:
68  struct DeviceData;
69 
74  bool registerDevice(KeyboardDevice* device);
78  bool unregisterDevice();
79 
84  bool updateDevice(int key, int modifierMask);
85 
89 
92 
93 
95  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
99  std::unique_ptr<DeviceData> m_device;
100 };
101 
102 }; // namespace Device
103 }; // namespace SurgSim
104 
105 #endif // SURGSIM_DEVICES_KEYBOARD_KEYBOARDSCAFFOLD_H
Definition: DriveElementFromInputBehavior.cpp:27
std::unique_ptr< DeviceData > m_device
The keyboard device managed by this scaffold.
Definition: KeyboardScaffold.h:99
LogLevel
Logging levels.
Definition: Logger.h:36
~KeyboardScaffold()
Destructor.
Definition: KeyboardScaffold.cpp:66
A class that implements the behavior of KeyboardDevice objects.
Definition: KeyboardScaffold.h:38
Struct to hold a KeyboardDevice object, a KeyboardHandler object, and a mutex for data passing...
Definition: KeyboardScaffold.cpp:34
bool updateDevice(int key, int modifierMask)
Updates the device information for a single device.
Definition: KeyboardScaffold.cpp:93
static SurgSim::Framework::LogLevel m_defaultLogLevel
The default logging level.
Definition: KeyboardScaffold.h:97
static void setDefaultLogLevel(SurgSim::Framework::LogLevel logLevel)
Sets the default log level.
Definition: KeyboardScaffold.cpp:125
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: KeyboardScaffold.h:95
A class implementing the communication with a keyboard.
Definition: KeyboardDevice.h:44
std::shared_ptr< SurgSim::Framework::Logger > getLogger() const
Gets the logger used by this object and the devices it manages.
Definition: KeyboardScaffold.cpp:130
OsgKeyboardHandler * getKeyboardHandler() const
Get keyboard handler.
Definition: KeyboardScaffold.cpp:104
A collection of NamedData objects.
Definition: DataGroup.h:66
static SurgSim::DataStructures::DataGroup buildDeviceInputData()
Builds the data layout for the application input (i.e. device output).
Definition: KeyboardScaffold.cpp:111
Definition: OsgKeyboardHandler.h:30
bool unregisterDevice()
Unregisters the specified device object.
Definition: KeyboardScaffold.cpp:82
bool registerDevice(KeyboardDevice *device)
Registers the specified device object.
Definition: KeyboardScaffold.cpp:71
KeyboardScaffold(std::shared_ptr< SurgSim::Framework::Logger > logger=nullptr)
Constructor.
Definition: KeyboardScaffold.cpp:56
friend class KeyboardDeviceTest
Definition: KeyboardScaffold.h:41
static std::shared_ptr< KeyboardScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all KeyboardDevice instances.
Definition: KeyboardScaffold.cpp:119