17 #ifndef IGNITION_SENSORS_SENSORFACTORY_HH_ 18 #define IGNITION_SENSORS_SENSORFACTORY_HH_ 22 #include <type_traits> 25 #include <ignition/common/Console.hh> 26 #include <ignition/common/PluginMacros.hh> 28 #include <ignition/sensors/config.hh> 29 #include <ignition/sensors/Export.hh> 38 inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
40 class SensorFactoryPrivate;
49 public:
virtual Sensor *New() = 0;
55 template<
class SensorType>
59 public: SensorType *
New()
override 61 return new SensorType();
88 public:
template<
typename T>
96 dynamic_cast<T *>(sensor.release()));
99 ignerr <<
"SDF sensor type does not match template type\n";
104 ignerr <<
"Failed to create sensor of type[" 105 << _sdf.TypeStr() <<
"]\n";
120 public:
template<
typename T>
128 dynamic_cast<T *>(sensor.release()));
131 ignerr <<
"SDF sensor type does not match template type\n";
136 ignerr <<
"Failed to create sensor of type[" 171 public:
void AddPluginPaths(
const std::string &_path);
184 #define IGN_SENSORS_REGISTER_SENSOR(classname) \ 185 IGN_COMMON_REGISTER_SINGLE_PLUGIN(\ 186 ignition::sensors::SensorTypePlugin<classname>, \ 187 ignition::sensors::SensorPlugin) std::unique_ptr< T > CreateSensor(sdf::ElementPtr _sdf)
Create a sensor from SDF with a known sensor type.
Definition: SensorFactory.hh:121
A factory class for creating sensors This class wll load a sensor plugin based on the given sensor ty...
Definition: SensorFactory.hh:69
a base sensor class
Definition: Sensor.hh:50
SensorType * New() override
Definition: SensorFactory.hh:59
Base sensor plugin interface.
Definition: SensorFactory.hh:43
Templated class for instantiating sensors of the specified type.
Definition: SensorFactory.hh:56
Definition: AirPressureSensor.hh:31
std::unique_ptr< T > CreateSensor(const sdf::Sensor &_sdf)
Create a sensor from a SDF DOM object with a known sensor type.
Definition: SensorFactory.hh:89