opensurgsim
DeviceInterface.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_INPUT_DEVICEINTERFACE_H
17 #define SURGSIM_INPUT_DEVICEINTERFACE_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "SurgSim/Input/InputConsumerInterface.h"
23 #include "SurgSim/Input/OutputProducerInterface.h"
24 #include "SurgSim/Framework/Accessible.h"
25 #include "SurgSim/Framework/ObjectFactory.h"
26 
27 namespace SurgSim
28 {
29 namespace Input
30 {
31 
32 
41 class DeviceInterface : public Framework::Accessible, public Framework::FactoryBase1<DeviceInterface, std::string>
42 {
43 public:
45  virtual ~DeviceInterface()
46  {
47  }
48 
50  virtual std::string getName() const = 0;
51 
55  virtual std::string getClassName() const = 0;
56 
61  virtual bool initialize() = 0;
62 
64  virtual bool isInitialized() const = 0;
65 
70  virtual bool addInputConsumer(std::shared_ptr<InputConsumerInterface> inputConsumer) = 0;
71 
74  virtual bool removeInputConsumer(std::shared_ptr<InputConsumerInterface> inputConsumer) = 0;
75 
77  virtual void clearInputConsumers() = 0;
78 
84  virtual bool setOutputProducer(std::shared_ptr<OutputProducerInterface> outputProducer) = 0;
85 
88  virtual bool removeOutputProducer(std::shared_ptr<OutputProducerInterface> outputProducer) = 0;
89 
92  virtual bool hasOutputProducer() = 0;
93 
95  virtual void clearOutputProducer() = 0;
96 
97 private:
99  virtual bool finalize() = 0;
100 };
101 
102 
103 }; // namespace Input
104 }; // namespace SurgSim
105 
106 #endif // SURGSIM_INPUT_DEVICEINTERFACE_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
virtual bool setOutputProducer(std::shared_ptr< OutputProducerInterface > outputProducer)=0
Sets an output producer that will be asked for application output state when the device needs it...
virtual ~DeviceInterface()
Virtual destructor (empty).
Definition: DeviceInterface.h:45
virtual bool addInputConsumer(std::shared_ptr< InputConsumerInterface > inputConsumer)=0
Adds an input consumer that will be notified when the application input state is updated.
CRTP Base class to implement Object Factory functionality on a base class, use this rather than writi...
Definition: ObjectFactory.h:140
virtual bool hasOutputProducer()=0
Query if this object has output producer.
virtual std::string getName() const =0
Return a (hopefully unique) device name.
virtual bool isInitialized() const =0
virtual std::string getClassName() const =0
The class name for this class.
virtual bool removeInputConsumer(std::shared_ptr< InputConsumerInterface > inputConsumer)=0
Removes an input consumer previously added via addInputConsumer.
virtual bool removeOutputProducer(std::shared_ptr< OutputProducerInterface > outputProducer)=0
Removes an output producer previously added via setOutputProducer.
virtual void clearOutputProducer()=0
Removes any OutputProducer.
Interface used to communicate with user-interface hardware devices.
Definition: DeviceInterface.h:41
Mixin class for enabling a property system on OSS classes, the instance still needs to initialize pro...
Definition: Accessible.h:37
virtual void clearInputConsumers()=0
Removes all InputConsumers.
virtual bool initialize()=0
Fully initialize the device.