opensurgsim
Public Member Functions | List of all members
SurgSim::Devices::FilteredDevice Class Reference

A DeviceInterface connected in series with one or more DeviceFilters. Useful for serialization. More...

#include <FilteredDevice.h>

Inheritance diagram for SurgSim::Devices::FilteredDevice:
SurgSim::Input::DeviceInterface SurgSim::Framework::Accessible SurgSim::Framework::FactoryBase1< DeviceInterface, std::string > SurgSim::Devices::MultiAxisDevice

Public Member Functions

 FilteredDevice (const std::string &name)
 Constructor. More...
 
 SURGSIM_CLASSNAME (SurgSim::Devices::FilteredDevice)
 
virtual ~FilteredDevice ()
 Destructor.
 
std::string getName () const override
 Return a (hopefully unique) device name.
 
bool initialize () override
 Fully initialize the device. More...
 
bool isInitialized () const override
 
bool addInputConsumer (std::shared_ptr< Input::InputConsumerInterface > inputConsumer) override
 
bool removeInputConsumer (std::shared_ptr< Input::InputConsumerInterface > inputConsumer) override
 
void clearInputConsumers () override
 Removes all InputConsumers.
 
bool setOutputProducer (std::shared_ptr< Input::OutputProducerInterface > outputProducer) override
 
bool removeOutputProducer (std::shared_ptr< Input::OutputProducerInterface > outputProducer) override
 
bool hasOutputProducer () override
 Query if this object has output producer. More...
 
void clearOutputProducer () override
 Removes any OutputProducer.
 
void setDevice (std::shared_ptr< Input::DeviceInterface > device)
 Sets the raw/base device. More...
 
void addFilter (std::shared_ptr< DeviceFilter > filter)
 Adds a DeviceFilter. More...
 
const std::vector< std::shared_ptr< Input::DeviceInterface > > & getDevices () const
 
bool setDevices (const std::vector< std::shared_ptr< Input::DeviceInterface >> &devices)
 Sets the devices. More...
 
- Public Member Functions inherited from SurgSim::Input::DeviceInterface
virtual ~DeviceInterface ()
 Virtual destructor (empty).
 
virtual std::string getClassName () const =0
 The class name for this class. More...
 
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 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...
 
- 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
 

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 DeviceInterface connected in series with one or more DeviceFilters. Useful for serialization.

Constructor & Destructor Documentation

§ FilteredDevice()

SurgSim::Devices::FilteredDevice::FilteredDevice ( const std::string &  name)
explicit

Constructor.

Parameters
nameName of this device.

Member Function Documentation

§ addFilter()

void SurgSim::Devices::FilteredDevice::addFilter ( std::shared_ptr< DeviceFilter filter)

Adds a DeviceFilter.

The first filter that is added will be connected to the raw/base device. The last filter that is added will interface with InputConsumers and/or an OutputProducer. Any filters added in-between will be connected in order.

Parameters
filterA DeviceFilter.

§ getDevices()

const std::vector< std::shared_ptr< Input::DeviceInterface > > & SurgSim::Devices::FilteredDevice::getDevices ( ) const
Returns
All devices.

§ hasOutputProducer()

bool SurgSim::Devices::FilteredDevice::hasOutputProducer ( )
overridevirtual

Query if this object has output producer.

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

Implements SurgSim::Input::DeviceInterface.

§ initialize()

bool SurgSim::Devices::FilteredDevice::initialize ( )
overridevirtual

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.

Implements SurgSim::Input::DeviceInterface.

§ isInitialized()

bool SurgSim::Devices::FilteredDevice::isInitialized ( ) const
overridevirtual
Returns
true if the device has been initialized and has not yet been finalized.

Implements SurgSim::Input::DeviceInterface.

§ setDevice()

void SurgSim::Devices::FilteredDevice::setDevice ( std::shared_ptr< Input::DeviceInterface device)

Sets the raw/base device.

Parameters
deviceThe device connected to the filter(s).

§ setDevices()

bool SurgSim::Devices::FilteredDevice::setDevices ( const std::vector< std::shared_ptr< Input::DeviceInterface >> &  devices)

Sets the devices.

Parameters
devicesAll the devices.
Returns
true on success

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