Go to the documentation of this file.
17 #ifndef GZ_SENSORS_SENSORFACTORY_HH_
18 #define GZ_SENSORS_SENSORFACTORY_HH_
22 #include <type_traits>
25 #include <gz/common/Console.hh>
26 #include <gz/common/PluginMacros.hh>
27 #include <gz/common/SuppressWarning.hh>
29 #include <gz/sensors/config.hh>
30 #include <gz/sensors/Export.hh>
39 inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
41 class SensorFactoryPrivate;
47 public: IGN_COMMON_SPECIALIZE_INTERFACE(gz::sensors::SensorPlugin)
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 gz::sensors::SensorTypePlugin<classname>, \
190 gz::sensors::SensorPlugin)
Definition: gz/sensors/AirPressureSensor.hh:32
SensorType * New() override
Definition: gz/sensors/SensorFactory.hh:60
Base sensor plugin interface.
Definition: gz/sensors/SensorFactory.hh:44
~SensorFactory()
Destructor.
std::unique_ptr< T > CreateSensor(sdf::ElementPtr _sdf)
Create a sensor from SDF with a known sensor type.
Definition: gz/sensors/SensorFactory.hh:122
SensorFactory()
Constructor.
void AddPluginPaths(const std::string &_path)
Add additional path to search for sensor plugins.
std::unique_ptr< T > CreateSensor(const sdf::Sensor &_sdf)
Create a sensor from a SDF DOM object with a known sensor type.
Definition: gz/sensors/SensorFactory.hh:90
Templated class for instantiating sensors of the specified type.
Definition: gz/sensors/SensorFactory.hh:57
A factory class for creating sensors This class wll load a sensor plugin based on the given sensor ty...
Definition: gz/sensors/SensorFactory.hh:70
a base sensor class
Definition: gz/sensors/Sensor.hh:60