SurgSim::Input::DeviceInterface Class Referenceabstract

Interface used to communicate with user-interface hardware devices. More...

`#include <SurgSim/Input/DeviceInterface.h>`

Inheritance diagram for SurgSim::Input::DeviceInterface:

## Public Member Functions

virtual | ~DeviceInterface ()
| Virtual destructor (empty). More...
virtual std::string | getName () const =0
| Return a (hopefully unique) device name. More...
virtual std::string | getClassName () const =0
| The class name for this class. More...
virtual bool | initialize ()=0
| Fully initialize the device. More...
virtual bool | isInitialized () const =0
virtual bool | addInputConsumer (std::shared_ptr< InputConsumerInterface > inputConsumer)=0
| Adds an input consumer that will be notified when the application input state is updated. More...
virtual bool | removeInputConsumer (std::shared_ptr< InputConsumerInterface > inputConsumer)=0
| Removes an input consumer previously added via addInputConsumer. More...
virtual void | clearInputConsumers ()=0
| Removes all InputConsumers. More...
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. More...
virtual bool | removeOutputProducer (std::shared_ptr< OutputProducerInterface > outputProducer)=0
| Removes an output producer previously added via setOutputProducer. More...
virtual bool | hasOutputProducer ()=0
| Query if this object has output producer. More...
virtual void | clearOutputProducer ()=0
| Removes any OutputProducer. More...
Public Member Functions inherited from SurgSim::Framework::Accessible
| Accessible ()
| Default Constructor. More...
| ~Accessible ()
| Destructor. More...
template<class T >
T | getValue (const std::string &name) const
| Retrieves the value with the name by executing the getter if it is found and tries to convert it to the given type. More...
boost::any | getValue (const std::string &name) const
| Retrieves the value with the name by executing the getter if it is found. More...
template<class T >
bool | getValue (const std::string &name, T *value) const
| Retrieves the value with the name by executing the getter if it is found, and converts it to the type of the output parameter. More...
void | setValue (const std::string &name, const boost::any &value)
| Sets a value of a property that has setter. More...
bool | isReadable (const std::string &name) const
| Check whether a property is readable. More...
bool | isWriteable (const std::string &name) const
| Check whether a property is writable. More...
void | setGetter (const std::string &name, GetterType func)
| Sets a getter for a given property. More...
void | setSetter (const std::string &name, SetterType func)
| Sets a setter for a given property. More...
void | setAccessors (const std::string &name, GetterType getter, SetterType setter)
| Sets the accessors getter and setter in one function. More...
void | removeAccessors (const std::string &name)
| Removes all the accessors (getter and setter) for a given property. More...
void | forwardProperty (const std::string &name, const Accessible &target, const std::string &targetProperty)
| Adds a property with the given name that uses the targets accessors, in effect forwarding the value to the target. More...
void | setSerializable (const std::string &name, EncoderType encoder, DecoderType decoder)
| Sets the functions used to convert data from and to a YAML::Node. More...
void | setDecoder (const std::string &name, DecoderType decoder)
| Sets the functions used to convert data from a YAML::Node. More...
YAML::Node | encode () const
| Encode this Accessible to a YAML::Node. More...
void | decode (const YAML::Node &node, const std::vector< std::string > &ignoredProperties=std::vector< std::string >())
| Decode this Accessible from a YAML::Node, will throw an exception if the data type cannot be converted. More...
template<>
boost::any | getValue (const std::string &name) const

## Private Member Functions

virtual bool | finalize ()=0
| Finalize (de-initialize) the device. More...

## Additional Inherited Members

Public Types inherited from SurgSim::Framework::Accessible
typedef std::function< boost::any(void)> | GetterType
typedef std::function< void(boost::any)> | SetterType
typedef std::function< YAML::Node(void)> | EncoderType
typedef std::function< void(const YAML::Node *)> | DecoderType
Public Types inherited from SurgSim::Framework::FactoryBase1< DeviceInterface, std::string >
typedef ObjectFactory1< DeviceInterface, std::string > | FactoryType
Static Public Member Functions inherited from SurgSim::Framework::FactoryBase1< DeviceInterface, std::string >
static FactoryType & | getFactory ()

## Detailed Description

Interface used to communicate with user-interface hardware devices.

Classes that implement communication with a hardware device implement this interface. This includes input/output devices (haptic devices are the most obvious example, but many other devices can, for example, display visual indicators such as LEDs, etc.), as well as input-only and output-only devices.

Derived classes will likely want to hide their constructor and only allow creation through a manager object for that type of device.

## Constructor & Destructor Documentation

## ~DeviceInterface()

virtual SurgSim::Input::DeviceInterface::~DeviceInterface | ( |  | ) |

inline virtual

Virtual destructor (empty).

## Member Function Documentation

## addInputConsumer()

virtual bool SurgSim::Input::DeviceInterface::addInputConsumer | ( | std::shared_ptr< InputConsumerInterface > | inputConsumer | ) |

pure virtual

Adds an input consumer that will be notified when the application input state is updated.

Parameters

  inputConsumer | The input consumer to be added.

Returns
  true on success, false on failure.

Implemented in SurgSim::Input::CommonDevice, and SurgSim::Devices::IdentityPoseDevice.

## clearInputConsumers()

virtual void SurgSim::Input::DeviceInterface::clearInputConsumers | ( |  | ) |

pure virtual

Removes all InputConsumers.

Implemented in SurgSim::Input::CommonDevice, and SurgSim::Devices::FilteredDevice.

## clearOutputProducer()

virtual void SurgSim::Input::DeviceInterface::clearOutputProducer | ( |  | ) |

pure virtual

Removes any OutputProducer.

Implemented in SurgSim::Input::CommonDevice, and SurgSim::Devices::FilteredDevice.

## finalize()

virtual bool SurgSim::Input::DeviceInterface::finalize | ( |  | ) |

private pure virtual

Finalize (de-initialize) the device.

Implemented in SurgSim::Devices::LabJackDevice, SurgSim::Devices::NovintDevice, SurgSim::Devices::LeapDevice, SurgSim::Devices::RawMultiAxisDevice, SurgSim::Devices::PhantomDevice, SurgSim::Devices::FilteredDevice, SurgSim::Devices::NimbleDevice, SurgSim::Devices::OculusDevice, SurgSim::Devices::TrackIRDevice, SurgSim::Devices::MouseDevice, SurgSim::Devices::DeviceFilter, SurgSim::Devices::ReplayPoseDevice, SurgSim::Devices::SixenseDevice, SurgSim::Devices::KeyboardDevice, SurgSim::Devices::OpenNIDevice, and SurgSim::Devices::IdentityPoseDevice.

## getClassName()

virtual std::string SurgSim::Input::DeviceInterface::getClassName | ( |  | ) | const

pure virtual

The class name for this class.

Note
  Use the SURGSIM_CLASSNAME macro in derived classes.

Returns
  The fully namespace qualified name of this class.

Implemented in SurgSim::Input::CommonDevice.

## getName()

virtual std::string SurgSim::Input::DeviceInterface::getName | ( |  | ) | const

pure virtual

Return a (hopefully unique) device name.

Implemented in SurgSim::Input::CommonDevice, and SurgSim::Devices::FilteredDevice.

## hasOutputProducer()

virtual bool SurgSim::Input::DeviceInterface::hasOutputProducer | ( |  | ) |

pure virtual

Query if this object has output producer.

Returns
  true if there is an output producer, false if not.

Implemented in SurgSim::Input::CommonDevice, and SurgSim::Devices::FilteredDevice.

## initialize()

virtual bool SurgSim::Input::DeviceInterface::initialize | ( |  | ) |

pure virtual

Fully initialize the device.

When the manager object creates the device, the internal state of the device usually isn't fully initialized yet. This method performs any needed initialization.

Implemented in SurgSim::Devices::LabJackDevice, SurgSim::Devices::LeapDevice, SurgSim::Devices::NovintDevice, SurgSim::Devices::PhantomDevice, SurgSim::Devices::NimbleDevice, SurgSim::Devices::RawMultiAxisDevice, SurgSim::Devices::ReplayPoseDevice, SurgSim::Devices::MouseDevice, SurgSim::Devices::SixenseDevice, SurgSim::Devices::KeyboardDevice, SurgSim::Devices::OculusDevice, SurgSim::Devices::TrackIRDevice, SurgSim::Devices::FilteredDevice, SurgSim::Devices::OpenNIDevice, SurgSim::Devices::IdentityPoseDevice, and SurgSim::Devices::DeviceFilter.

## isInitialized()

virtual bool SurgSim::Input::DeviceInterface::isInitialized | ( |  | ) | const

pure virtual

Returns
  true if the device has been initialized and has not yet been finalized.

Implemented in SurgSim::Devices::LabJackDevice, SurgSim::Devices::LeapDevice, SurgSim::Devices::NovintDevice, SurgSim::Devices::PhantomDevice, SurgSim::Devices::NimbleDevice, SurgSim::Devices::RawMultiAxisDevice, SurgSim::Devices::ReplayPoseDevice, SurgSim::Devices::MouseDevice, SurgSim::Devices::SixenseDevice, SurgSim::Devices::KeyboardDevice, SurgSim::Devices::OculusDevice, SurgSim::Devices::TrackIRDevice, SurgSim::Devices::FilteredDevice, SurgSim::Devices::OpenNIDevice, SurgSim::Devices::IdentityPoseDevice, and SurgSim::Devices::DeviceFilter.

## removeInputConsumer()

virtual bool SurgSim::Input::DeviceInterface::removeInputConsumer | ( | std::shared_ptr< InputConsumerInterface > | inputConsumer | ) |

pure virtual

Removes an input consumer previously added via addInputConsumer.

Parameters

  inputConsumer | The input consumer to be removed.

Implemented in SurgSim::Input::CommonDevice.

## removeOutputProducer()

virtual bool SurgSim::Input::DeviceInterface::removeOutputProducer | ( | std::shared_ptr< OutputProducerInterface > | outputProducer | ) |

pure virtual

Removes an output producer previously added via setOutputProducer.

Parameters

  outputProducer | The output producer to be removed.

Implemented in SurgSim::Input::CommonDevice.

## setOutputProducer()

virtual bool SurgSim::Input::DeviceInterface::setOutputProducer | ( | std::shared_ptr< OutputProducerInterface > | outputProducer | ) |

pure virtual

Sets an output producer that will be asked for application output state when the device needs it.

Any previously set output producer will be removed.

Parameters

  outputProducer | The output producer to be added.

Returns
  true on success, false on failure.

Implemented in SurgSim::Input::CommonDevice.

The documentation for this class was generated from the following file:

- SurgSim/Input/DeviceInterface.h