All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InputComponent.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_INPUT_INPUTCOMPONENT_H
17 #define SURGSIM_INPUT_INPUTCOMPONENT_H
18 
19 #include <string>
20 #include <memory>
22 
23 namespace SurgSim
24 {
25 
26 namespace DataStructures
27 {
28 class DataGroup;
29 }
30 
31 namespace Input
32 {
33 class DeviceInterface;
34 class InputConsumer;
35 
36 SURGSIM_STATIC_REGISTRATION(InputComponent);
37 
42 {
43 public:
46  explicit InputComponent(const std::string& name);
47 
49  virtual ~InputComponent();
50 
52 
55  void setDeviceName(const std::string& deviceName);
56 
59  bool isDeviceConnected();
60 
64  void connectDevice(std::shared_ptr<SurgSim::Input::DeviceInterface> device);
65 
69  void disconnectDevice(std::shared_ptr<SurgSim::Input::DeviceInterface> device);
70 
75 
77  virtual bool doInitialize() override;
78 
80  virtual bool doWakeUp() override;
81 
84  std::string getDeviceName() const;
85 
86 private:
88  std::string m_deviceName;
92  std::shared_ptr<InputConsumer> m_input;
93 };
94 
95 }; // namespace Input
96 }; // namespace SurgSim
97 
98 
99 #endif
std::string getDeviceName() const
Gets device name.
Definition: InputComponent.cpp:114
InputComponent(const std::string &name)
Constructor.
Definition: InputComponent.cpp:73
void connectDevice(std::shared_ptr< SurgSim::Input::DeviceInterface > device)
Connect to a device This call will be made by the InputManager, and should generally not be called di...
Definition: InputComponent.cpp:119
SURGSIM_CLASSNAME(SurgSim::Input::InputComponent)
void disconnectDevice(std::shared_ptr< SurgSim::Input::DeviceInterface > device)
Disconnect from a device This call will be made by the InputManager, and should generally not be call...
Definition: InputComponent.cpp:125
void getData(SurgSim::DataStructures::DataGroup *dataGroup)
Gets the input data.
Definition: InputComponent.cpp:97
SURGSIM_STATIC_REGISTRATION(InputComponent)
Component is the main interface class to pass information to the system managers each will decide whe...
Definition: Component.h:43
InputComponent combines the Component interface and the InputConsumerInterface so that input devices ...
Definition: InputComponent.h:41
virtual bool doInitialize() override
Overridden from Component, do nothing.
Definition: InputComponent.cpp:104
std::string m_deviceName
Name of the device to which this input component connects.
Definition: InputComponent.h:88
A collection of NamedData objects.
Definition: DataGroup.h:66
std::shared_ptr< InputConsumer > m_input
Input consumer which brings in information from hardware device.
Definition: InputComponent.h:92
bool isDeviceConnected()
Is a device connected.
Definition: InputComponent.cpp:92
bool m_deviceConnected
Indicates if this input component is connected to a device.
Definition: InputComponent.h:90
void setDeviceName(const std::string &deviceName)
Set name of the device this input component connects to.
Definition: InputComponent.cpp:87
virtual ~InputComponent()
Destructor.
Definition: InputComponent.cpp:83
virtual bool doWakeUp() override
Overridden from Component, do nothing.
Definition: InputComponent.cpp:109