opensurgsim
FilteredDevice.h
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_DEVICEFILTERS_FILTEREDDEVICE_H
17 #define SURGSIM_DEVICES_DEVICEFILTERS_FILTEREDDEVICE_H
18 
19 #include <boost/thread/shared_mutex.hpp>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "SurgSim/Input/DeviceInterface.h"
25 
26 namespace SurgSim
27 {
28 namespace Input
29 {
30 class InputConsumerInterface;
31 class OutputProducerInterface;
32 }
33 
34 namespace Devices
35 {
36 class DeviceFilter;
37 
40 {
41 public:
44  explicit FilteredDevice(const std::string& name);
45 
46  SURGSIM_CLASSNAME(SurgSim::Devices::FilteredDevice);
47 
49  virtual ~FilteredDevice();
50 
51  std::string getName() const override;
52 
53  bool initialize() override;
54 
55  bool isInitialized() const override;
56 
57  bool addInputConsumer(std::shared_ptr<Input::InputConsumerInterface> inputConsumer) override;
58  bool removeInputConsumer(std::shared_ptr<Input::InputConsumerInterface> inputConsumer) override;
59  void clearInputConsumers() override;
60  bool setOutputProducer(std::shared_ptr<Input::OutputProducerInterface> outputProducer) override;
61  bool removeOutputProducer(std::shared_ptr<Input::OutputProducerInterface> outputProducer) override;
62  bool hasOutputProducer() override;
63  void clearOutputProducer() override;
64 
67  void setDevice(std::shared_ptr<Input::DeviceInterface> device);
68 
73  void addFilter(std::shared_ptr<DeviceFilter> filter);
74 
76  const std::vector<std::shared_ptr<Input::DeviceInterface>>& getDevices() const;
77 
81  bool setDevices(const std::vector<std::shared_ptr<Input::DeviceInterface>>& devices);
82 
83 private:
84  bool finalize() override;
85 
87  void doFinalize();
88 
90  std::string m_name;
91 
93  bool m_initialized;
94 
98  std::vector<std::shared_ptr<Input::DeviceInterface>> m_devices;
99 
101  boost::shared_mutex m_deviceMutex;
102 
104  std::shared_ptr<Framework::Logger> m_logger;
105 };
106 
107 }; // namespace Devices
108 }; // namespace SurgSim
109 
110 #endif // SURGSIM_DEVICES_DEVICEFILTERS_FILTEREDDEVICE_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
A DeviceInterface connected in series with one or more DeviceFilters. Useful for serialization.
Definition: FilteredDevice.h:39
Interface used to communicate with user-interface hardware devices.
Definition: DeviceInterface.h:41