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> 27 #include <ignition/common/SuppressWarning.hh> 29 #include <ignition/sensors/config.hh> 30 #include <ignition/sensors/Export.hh> 39 inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
41 class SensorFactoryPrivate;
50 public:
virtual Sensor *New() = 0;
56 template<
class SensorType>
60 public: SensorType *
New()
override 62 return new SensorType();
89 public:
template<
typename T>
97 dynamic_cast<T *>(sensor.release()));
100 ignerr <<
"SDF sensor type does not match template type\n";
105 ignerr <<
"Failed to create sensor of type[" 106 << _sdf.TypeStr() <<
"]\n";
121 public:
template<
typename T>
129 dynamic_cast<T *>(sensor.release()));
132 ignerr <<
"SDF sensor type does not match template type\n";
137 ignerr <<
"Failed to create sensor of type[" 172 public:
void AddPluginPaths(
const std::string &_path);
180 IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
183 IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
187 #define IGN_SENSORS_REGISTER_SENSOR(classname) \ 188 IGN_COMMON_REGISTER_SINGLE_PLUGIN(\ 189 ignition::sensors::SensorTypePlugin<classname>, \ 190 ignition::sensors::SensorPlugin) std::unique_ptr< T > CreateSensor(sdf::ElementPtr _sdf)
Create a sensor from SDF with a known sensor type.
Definition: SensorFactory.hh:122
A factory class for creating sensors This class wll load a sensor plugin based on the given sensor ty...
Definition: SensorFactory.hh:70
a base sensor class
Definition: Sensor.hh:60
SensorType * New() override
Definition: SensorFactory.hh:60
Base sensor plugin interface.
Definition: SensorFactory.hh:44
Templated class for instantiating sensors of the specified type.
Definition: SensorFactory.hh:57
Definition: AirPressureSensor.hh:32
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:90