opensurgsim
Public Member Functions | Protected Member Functions | List of all members
SurgSim::Input::CommonDevice Class Reference

A class that implements some common management code on top of the DeviceInterface. More...

#include <CommonDevice.h>

Inheritance diagram for SurgSim::Input::CommonDevice:
SurgSim::Input::DeviceInterface SurgSim::Framework::Accessible SurgSim::Framework::FactoryBase1< DeviceInterface, std::string > SurgSim::Devices::DeviceFilter SurgSim::Devices::IdentityPoseDevice SurgSim::Devices::KeyboardDevice SurgSim::Devices::LabJackDevice SurgSim::Devices::LeapDevice SurgSim::Devices::MouseDevice SurgSim::Devices::NimbleDevice SurgSim::Devices::NovintDevice SurgSim::Devices::OculusDevice SurgSim::Devices::OpenNIDevice SurgSim::Devices::PhantomDevice SurgSim::Devices::RawMultiAxisDevice SurgSim::Devices::ReplayPoseDevice SurgSim::Devices::SixenseDevice SurgSim::Devices::TrackIRDevice SurgSim::Devices::TrakstarDevice TestDevice

Public Member Functions

 CommonDevice (const std::string &name)
 Constructor. More...
 
 CommonDevice (const std::string &name, const DataStructures::DataGroup &inputData)
 Constructor. More...
 
 CommonDevice (const std::string &name, DataStructures::DataGroup &&inputData)
 Constructor. More...
 
virtual ~CommonDevice ()
 Destructor.
 
std::string getName () const override
 Return a (hopefully unique) device name.
 
std::string getClassName () const override
 The class name for this class. More...
 
void setNameForCallback (const std::string &name)
 Set the name used for calling the input consumers and output producer. More...
 
std::string getNameForCallback () const
 Get the name used for calling the input consumers and output producer. More...
 
bool addInputConsumer (std::shared_ptr< InputConsumerInterface > inputConsumer) override
 Adds an input consumer that will be notified when the application input state is updated. More...
 
bool removeInputConsumer (std::shared_ptr< InputConsumerInterface > inputConsumer) override
 Removes an input consumer previously added via addInputConsumer. More...
 
void clearInputConsumers () override
 Removes all InputConsumers.
 
bool setOutputProducer (std::shared_ptr< OutputProducerInterface > outputProducer) override
 Sets an output producer that will be asked for application output state when the device needs it. More...
 
bool removeOutputProducer (std::shared_ptr< OutputProducerInterface > outputProducer) override
 Removes an output producer previously added via setOutputProducer. More...
 
bool hasOutputProducer () override
 Query if this object has output producer. More...
 
void clearOutputProducer () override
 Removes any OutputProducer.
 
- Public Member Functions inherited from SurgSim::Input::DeviceInterface
virtual ~DeviceInterface ()
 Virtual destructor (empty).
 
virtual bool initialize ()=0
 Fully initialize the device. More...
 
virtual bool isInitialized () const =0
 
- Public Member Functions inherited from SurgSim::Framework::Accessible
 Accessible ()
 Default Constructor.
 
 ~Accessible ()
 Destructor.
 
template<class 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...
 
std::vector< std::string > getProperties ()
 
template<>
boost::any getValue (const std::string &name) const
 

Protected Member Functions

virtual void pushInput ()
 Push application input to consumers.
 
virtual bool pullOutput ()
 Pull application output from a producer.
 
DataStructures::DataGroupgetInputData ()
 Getter for the input data DataGroup. More...
 
const DataStructures::DataGroupgetOutputData () const
 Getter for the output data DataGroup. 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 FactoryTypegetFactory ()
 

Detailed Description

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.

Constructor & Destructor Documentation

§ CommonDevice() [1/3]

SurgSim::Input::CommonDevice::CommonDevice ( const std::string &  name)
explicit

Constructor.

Sets the input data to an empty DataGroup.

Parameters
nameThe name associated with the input device.

§ CommonDevice() [2/3]

SurgSim::Input::CommonDevice::CommonDevice ( const std::string &  name,
const DataStructures::DataGroup inputData 
)

Constructor.

Parameters
nameThe name associated with the input device.
inputDataAn 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.

§ CommonDevice() [3/3]

SurgSim::Input::CommonDevice::CommonDevice ( const std::string &  name,
DataStructures::DataGroup &&  inputData 
)

Constructor.

Parameters
nameThe name associated with the input device.
inputDataAn 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.

Member Function Documentation

§ addInputConsumer()

bool SurgSim::Input::CommonDevice::addInputConsumer ( std::shared_ptr< InputConsumerInterface inputConsumer)
overridevirtual

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

Parameters
inputConsumerThe input consumer to be added.
Returns
true on success, false on failure.

Implements SurgSim::Input::DeviceInterface.

§ getClassName()

std::string SurgSim::Input::CommonDevice::getClassName ( ) const
overridevirtual

The class name for this class.

Note
Use the SURGSIM_CLASSNAME macro in derived classes.
Returns
The fully namespace qualified name of this class.

Implements SurgSim::Input::DeviceInterface.

§ getInputData()

DataStructures::DataGroup & SurgSim::Input::CommonDevice::getInputData ( )
protected

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.

§ getNameForCallback()

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.

§ getOutputData()

const DataStructures::DataGroup & SurgSim::Input::CommonDevice::getOutputData ( ) const
protected

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.

§ hasOutputProducer()

bool SurgSim::Input::CommonDevice::hasOutputProducer ( )
overridevirtual

Query if this object has output producer.

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

Implements SurgSim::Input::DeviceInterface.

§ removeInputConsumer()

bool SurgSim::Input::CommonDevice::removeInputConsumer ( std::shared_ptr< InputConsumerInterface inputConsumer)
overridevirtual

Removes an input consumer previously added via addInputConsumer.

Parameters
inputConsumerThe input consumer to be removed.

Implements SurgSim::Input::DeviceInterface.

§ removeOutputProducer()

bool SurgSim::Input::CommonDevice::removeOutputProducer ( std::shared_ptr< OutputProducerInterface outputProducer)
overridevirtual

Removes an output producer previously added via setOutputProducer.

Parameters
outputProducerThe output producer to be removed.

Implements SurgSim::Input::DeviceInterface.

§ setNameForCallback()

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
nameThe name to be used.

§ setOutputProducer()

bool SurgSim::Input::CommonDevice::setOutputProducer ( std::shared_ptr< OutputProducerInterface outputProducer)
overridevirtual

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
outputProducerThe output producer to be added.
Returns
true on success, false on failure.

Implements SurgSim::Input::DeviceInterface.


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