|
A DeviceInterface connected in series with one or more DeviceFilters. Useful for serialization. More...
#include <SurgSim/Devices/DeviceFilters/FilteredDevice.h>
Public Member Functions | |
| FilteredDevice (const std::string &name) | |
| Constructor. More... | |
| SURGSIM_CLASSNAME (SurgSim::Devices::FilteredDevice) | |
| virtual | ~FilteredDevice () |
| Destructor. More... | |
| std::string | getName () const override |
| Return a (hopefully unique) device name. More... | |
| bool | initialize () override |
| Fully initialize the device. More... | |
| bool | isInitialized () const override |
| bool | addInputConsumer (std::shared_ptr< Input::InputConsumerInterface > inputConsumer) override |
| Adds an input consumer that will be notified when the application input state is updated. More... | |
| bool | removeInputConsumer (std::shared_ptr< Input::InputConsumerInterface > inputConsumer) override |
| Removes an input consumer previously added via addInputConsumer. More... | |
| void | clearInputConsumers () override |
| Removes all InputConsumers. More... | |
| bool | setOutputProducer (std::shared_ptr< Input::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< Input::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. More... | |
| 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). More... | |
| virtual std::string | getClassName () const =0 |
| The class name for this class. 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 | |
| bool | finalize () override |
| Finalize (de-initialize) the device. More... | |
| void | doFinalize () |
| Implements the finalize functionality. More... | |
Private Attributes | |
| std::string | m_name |
| The name of this device. More... | |
| bool | m_initialized |
| true if initialized and not finalized. More... | |
| std::vector< std::shared_ptr< Input::DeviceInterface > > | m_devices |
| The devices. More... | |
| boost::shared_mutex | m_deviceMutex |
| The mutex to protect access to the devices. More... | |
| std::shared_ptr< Framework::Logger > | m_logger |
| The logger. 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 () |
A DeviceInterface connected in series with one or more DeviceFilters. Useful for serialization.
|
explicit |
Constructor.
| name | Name of this device. |
|
virtual |
Destructor.
| 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.
| filter | A DeviceFilter. |
|
overridevirtual |
Adds an input consumer that will be notified when the application input state is updated.
| inputConsumer | The input consumer to be added. |
Implements SurgSim::Input::DeviceInterface.
|
overridevirtual |
Removes all InputConsumers.
Implements SurgSim::Input::DeviceInterface.
|
overridevirtual |
Removes any OutputProducer.
Implements SurgSim::Input::DeviceInterface.
|
private |
Implements the finalize functionality.
|
overrideprivatevirtual |
Finalize (de-initialize) the device.
Implements SurgSim::Input::DeviceInterface.
| const std::vector< std::shared_ptr< Input::DeviceInterface > > & SurgSim::Devices::FilteredDevice::getDevices | ( | ) | const |
|
overridevirtual |
Return a (hopefully unique) device name.
Implements SurgSim::Input::DeviceInterface.
|
overridevirtual |
Query if this object has output producer.
Implements SurgSim::Input::DeviceInterface.
|
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.
|
overridevirtual |
Implements SurgSim::Input::DeviceInterface.
|
overridevirtual |
Removes an input consumer previously added via addInputConsumer.
| inputConsumer | The input consumer to be removed. |
Implements SurgSim::Input::DeviceInterface.
|
overridevirtual |
Removes an output producer previously added via setOutputProducer.
| outputProducer | The output producer to be removed. |
Implements SurgSim::Input::DeviceInterface.
| void SurgSim::Devices::FilteredDevice::setDevice | ( | std::shared_ptr< Input::DeviceInterface > | device | ) |
Sets the raw/base device.
| device | The device connected to the filter(s). |
| bool SurgSim::Devices::FilteredDevice::setDevices | ( | const std::vector< std::shared_ptr< Input::DeviceInterface >> & | devices | ) |
Sets the devices.
| devices | All the devices. |
|
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.
| outputProducer | The output producer to be added. |
Implements SurgSim::Input::DeviceInterface.
| SurgSim::Devices::FilteredDevice::SURGSIM_CLASSNAME | ( | SurgSim::Devices::FilteredDevice | ) |
|
private |
The mutex to protect access to the devices.
|
private |
The devices.
m_devices.back() will be connected to any InputComponent or OutputComponent. m_devices.front() is the raw/base device to be filtered. If this contains more than one element, all but the front element are DeviceFilters.
|
private |
true if initialized and not finalized.
|
private |
The logger.
|
private |
The name of this device.
1.8.16