MouseScaffold.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_MOUSE_MOUSESCAFFOLD_H
17 #define SURGSIM_DEVICES_MOUSE_MOUSESCAFFOLD_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 MouseDevice;
34 class OsgMouseHandler;
35 
39 {
40  friend class MouseDevice;
41  friend class MouseDeviceTest;
42  friend class OsgMouseHandler;
43 
44 public:
48  explicit MouseScaffold(std::shared_ptr<SurgSim::Framework::Logger> logger = nullptr);
50  ~MouseScaffold();
51 
54  std::shared_ptr<SurgSim::Framework::Logger> getLogger() const;
55 
59  static std::shared_ptr<MouseScaffold> getOrCreateSharedInstance();
60 
64  static void setDefaultLogLevel(SurgSim::Framework::LogLevel logLevel);
65 
66 private:
68  struct DeviceData;
69 
74  bool registerDevice(MouseDevice* device);
78  bool unregisterDevice();
79 
87  bool updateDevice(int buttons, float x, float y, int scrollDeltaX, int scrollDeltaY);
88 
91  OsgMouseHandler* getMouseHandler() const;
92 
94  static SurgSim::DataStructures::DataGroup buildDeviceInputData();
95 
96 
98  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
102  std::unique_ptr<DeviceData> m_device;
103 };
104 
105 }; // namespace Device
106 }; // namespace SurgSim
107 
108 #endif // SURGSIM_DEVICES_MOUSE_MOUSESCAFFOLD_H
Definition: DriveElementFromInputBehavior.cpp:27
A class implementing the communication with a mouse.
Definition: MouseDevice.h:51
LogLevel
Logging levels.
Definition: Logger.h:36
A class that implements the behavior of MouseDevice objects.
Definition: MouseScaffold.h:38
Definition: OsgMouseHandler.h:30
static SurgSim::Framework::LogLevel m_defaultLogLevel
The default logging level.
Definition: MouseScaffold.h:100
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: MouseScaffold.h:98
A collection of NamedData objects.
Definition: DataGroup.h:66
std::unique_ptr< DeviceData > m_device
The mouse device managed by this scaffold.
Definition: MouseScaffold.h:102
Struct to hold a MouseDevice object, a OsgMouseHandler, and a mutex for data passing.
Definition: MouseScaffold.cpp:34