InputComponent.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2016, 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_INPUT_INPUTCOMPONENT_H
17 #define SURGSIM_INPUT_INPUTCOMPONENT_H
18 
19 #include <atomic>
20 #include <memory>
21 #include <string>
22 
27 
28 namespace SurgSim
29 {
30 namespace Input
31 {
32 class DeviceInterface;
33 
34 SURGSIM_STATIC_REGISTRATION(InputComponent);
35 
39 {
40 public:
43  explicit InputComponent(const std::string& name);
44 
46  virtual ~InputComponent();
47 
49 
52  void setDeviceName(const std::string& deviceName);
53 
56  std::string getDeviceName() const;
57 
62 
63  bool doInitialize() override;
64 
65  bool doWakeUp() override;
66 
67  void initializeInput(const std::string& device, const SurgSim::DataStructures::DataGroup& initialData) override;
68 
69  void handleInput(const std::string& device, const SurgSim::DataStructures::DataGroup& inputData) override;
70 
71 private:
73  std::string m_deviceName;
74 
77 
78  std::atomic<bool> m_hasInput;
79 };
80 
81 }; // namespace Input
82 }; // namespace SurgSim
83 
84 
85 #endif
SurgSim::Input::InputComponent::m_deviceName
std::string m_deviceName
Name of the device to which this input component connects.
Definition: InputComponent.h:73
SurgSim::Input::InputComponent::handleInput
void handleInput(const std::string &device, const SurgSim::DataStructures::DataGroup &inputData) override
Notifies the consumer that the application input coming from the device has been updated.
Definition: InputComponent.cpp:74
SurgSim::Input::InputComponent
InputComponents connect devices to SceneElements, facilitating data transfer from a device to SceneEl...
Definition: InputComponent.h:38
LockedContainer.h
InputConsumerInterface.h
SurgSim::Input::InputComponent::m_lastInput
SurgSim::Framework::LockedContainer< SurgSim::DataStructures::DataGroup > m_lastInput
Thread safe container of most recent input data.
Definition: InputComponent.h:76
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Input::InputComponent::setDeviceName
void setDeviceName(const std::string &deviceName)
Set name of the device this input component connects to.
Definition: InputComponent.cpp:39
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
SurgSim::Framework::LockedContainer< SurgSim::DataStructures::DataGroup >
SurgSim::Input::InputComponent::~InputComponent
virtual ~InputComponent()
Destructor.
Definition: InputComponent.cpp:35
SurgSim::Input::InputComponent::doWakeUp
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: InputComponent.cpp:62
SurgSim::Framework::Representation
Representations are manifestations of a SceneElement.
Definition: Representation.h:33
SurgSim::Input::InputComponent::getDeviceName
std::string getDeviceName() const
Gets device name.
Definition: InputComponent.cpp:44
SurgSim::Input::InputConsumerInterface
Interface for a consumer that monitors device and signal state updates (pose, buttons,...
Definition: InputConsumerInterface.h:33
SurgSim::Input::InputComponent::InputComponent
InputComponent(const std::string &name)
Constructor.
Definition: InputComponent.cpp:27
SurgSim::Input::InputComponent::initializeInput
void initializeInput(const std::string &device, const SurgSim::DataStructures::DataGroup &initialData) override
Set the initial input data group.
Definition: InputComponent.cpp:67
Representation.h
SurgSim::Input::InputComponent::m_hasInput
std::atomic< bool > m_hasInput
Definition: InputComponent.h:78
SurgSim::Input::InputComponent::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Input::InputComponent)
DataGroup.h
SurgSim::Input::InputComponent::getData
void getData(SurgSim::DataStructures::DataGroup *dataGroup)
Gets the input data.
Definition: InputComponent.cpp:49
SurgSim::Input::InputComponent::doInitialize
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: InputComponent.cpp:57