A class that implements some common management code on top of the DeviceInterface.
More...
#include <SurgSim/Input/CommonDevice.h>
A class that implements some common management code on top of the DeviceInterface.
Practically every class that implements DeviceInterface will likely want to inherit from CommonDevice.
SurgSim::Input::CommonDevice::CommonDevice |
( |
const std::string & |
name | ) |
|
|
explicit |
Constructor.
Sets the input data to an empty DataGroup.
- Parameters
-
name | The name associated with the input device. |
Constructor.
- Parameters
-
name | The name associated with the input device. |
inputData | An initial value for the application's input from the device (e.g. pose etc). The concrete device implementation should pass in a DataGroup whose contents has been set up, e.g. by using a DataGroupBuilder, to that device's supported values that it will push to the application. |
Constructor.
- Parameters
-
name | The name associated with the input device. |
inputData | An initial value for the application's input from the device (e.g. pose etc). The concrete device implementation should pass in a DataGroup whose contents has been set up, e.g. by using a DataGroupBuilder, to that device's supported values that it will push to the application. |
SurgSim::Input::CommonDevice::~CommonDevice |
( |
| ) |
|
|
virtual |
bool SurgSim::Input::CommonDevice::addInputConsumer |
( |
std::shared_ptr< InputConsumerInterface > |
inputConsumer | ) |
|
|
overridevirtual |
Getter for the input data DataGroup.
This function is typically called by friend scaffolds, to get a DataGroup they can modify then set back to the device to send to the device's input consumers.
- Returns
- A reference to the input data.
std::string SurgSim::Input::CommonDevice::getName |
( |
| ) |
const |
|
overridevirtual |
std::string SurgSim::Input::CommonDevice::getNameForCallback |
( |
| ) |
const |
Get the name used for calling the input consumers and output producer.
By default, this will be the same as the name of the device that was passed to the constructor.
- Returns
- The name being used.
Getter for the output data DataGroup.
This function is typically called by friend scaffolds, to get the data that the output producer wants to send to the device (and then send that data through the device's SDK). Note that a writable variant is not provided, an output producer registered via setOutputProducer will set the output data.
- Returns
- A reference to the output data.
bool SurgSim::Input::CommonDevice::hasOutputProducer |
( |
| ) |
|
|
overridevirtual |
bool SurgSim::Input::CommonDevice::pullOutput |
( |
| ) |
|
|
protectedvirtual |
Pull application output from a producer.
void SurgSim::Input::CommonDevice::pushInput |
( |
| ) |
|
|
protectedvirtual |
Push application input to consumers.
bool SurgSim::Input::CommonDevice::removeInputConsumer |
( |
std::shared_ptr< InputConsumerInterface > |
inputConsumer | ) |
|
|
overridevirtual |
bool SurgSim::Input::CommonDevice::removeOutputProducer |
( |
std::shared_ptr< OutputProducerInterface > |
outputProducer | ) |
|
|
overridevirtual |
void SurgSim::Input::CommonDevice::setNameForCallback |
( |
const std::string & |
name | ) |
|
Set the name used for calling the input consumers and output producer.
By default, this will be the same as the name of the device that was passed to the constructor.
- Parameters
-
The data the device is providing to its input consumers.
std::string SurgSim::Input::CommonDevice::m_nameForCallback |
|
private |
The name used for the callbacks, defaults to the device name.
The data the output producer (if any) is providing to the device.
std::unique_ptr<State> SurgSim::Input::CommonDevice::m_state |
|
private |
Struct to hide some of the private member variables, PImpl (Pointer to Implementation).
For CommonDevice, we are hiding:
- The list of input consumers,
- The output producer, if any, and
- The mutex that protects the consumers and the producer. The PImpl idiom is being used so that subclasses of CommonDevice will never store device-specific datatypes in member variables. Instead they would store them in the PImpl object, so that the device-specific include file(s) are only included by the subclass's .cpp file. A benefit of this idiom is that any change to the device's API/SDK will not force a recompile of any file including the subclass's .h file. For historical reasons we are not currently using the PImpl object to store all this class's private member variables, as is commonly recommended.
The documentation for this class was generated from the following files: