TrackIRScaffold.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_TRACKIR_TRACKIRSCAFFOLD_H
17 #define SURGSIM_DEVICES_TRACKIR_TRACKIRSCAFFOLD_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 TrackIRDevice;
34 
39 {
40 public:
44  explicit TrackIRScaffold(std::shared_ptr<SurgSim::Framework::Logger> logger = nullptr);
45 
47  ~TrackIRScaffold();
48 
51  std::shared_ptr<SurgSim::Framework::Logger> getLogger() const;
52 
56  static std::shared_ptr<TrackIRScaffold> getOrCreateSharedInstance();
57 
61  static void setDefaultLogLevel(SurgSim::Framework::LogLevel logLevel);
62 
63 private:
65  struct StateData;
67  struct DeviceData;
68 
69  friend class TrackIRDevice;
70  friend class TrackIRThread;
71  friend struct StateData;
72 
78  bool registerDevice(TrackIRDevice* device);
84  bool unregisterDevice(const TrackIRDevice* device);
85 
89  void setPositionScale(const TrackIRDevice* device, double scale);
93  void setOrientationScale(const TrackIRDevice* device, double scale);
94 
97  bool initializeSdk();
100  bool finalizeSdk();
101 
105  bool startCamera(DeviceData* info);
109  bool stopCamera(DeviceData* info);
110 
115  bool runInputFrame(DeviceData* info);
116 
120  bool updateDevice(DeviceData* info);
121 
125  bool createPerDeviceThread(DeviceData* data);
129  bool destroyPerDeviceThread(DeviceData* data);
130 
132  static SurgSim::DataStructures::DataGroup buildDeviceInputData();
133 
135  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
136 
139 
141  std::unique_ptr<StateData> m_state;
142 };
143 
144 }; // namespace Device
145 }; // namespace SurgSim
146 
147 #endif // SURGSIM_DEVICES_TRACKIR_TRACKIRSCAFFOLD_H
Definition: DriveElementFromInputBehavior.cpp:27
LogLevel
Logging levels.
Definition: Logger.h:36
A class implementing the communication with Natural Point TrackIR camera.
Definition: TrackIRDevice.h:40
Definition: TrackIRScaffold.cpp:49
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: TrackIRScaffold.h:135
A class implementing the thread context for sampling TrackIR devices.
Definition: TrackIRThread.h:29
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: TrackIRScaffold.h:141
A collection of NamedData objects.
Definition: DataGroup.h:66
Definition: TrackIRScaffold.cpp:80
static SurgSim::Framework::LogLevel m_defaultLogLevel
The default logging level.
Definition: TrackIRScaffold.h:138
A class that manages Natural Point TRACKIR devices.
Definition: TrackIRScaffold.h:38