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/SuppressWarning.hh> 
   28 #include <gz/sensors/config.hh> 
   29 #include <gz/sensors/Export.hh> 
   38     inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
 
   40     class SensorFactoryPrivate;
 
   49       public: 
virtual Sensor IGN_DEPRECATED(6) * New() = 0;
 
   56     template<
class SensorType>
 
   60       public: SensorType IGN_DEPRECATED(6) * 
New()
 override 
   62                 return new SensorType();
 
   91       public: 
template<
typename SensorType>
 
   94                 auto sensor = std::make_unique<SensorType>();
 
   96                 if (
nullptr == sensor)
 
   98                   ignerr << 
"Failed to create sensor [" << _sdf.Name()
 
   99                          << 
"] of type[" << _sdf.TypeStr() << 
"]" << 
std::endl;
 
  103                 if (!sensor->Load(_sdf))
 
  105                   ignerr << 
"Failed to load sensor [" << _sdf.Name()
 
  106                          << 
"] of type[" << _sdf.TypeStr() << 
"]" << 
std::endl;
 
  112                   ignerr << 
"Failed to initialize sensor [" << _sdf.Name()
 
  113                          << 
"] of type[" << _sdf.TypeStr() << 
"]" << 
std::endl;
 
  126       public: 
template<
typename SensorType>
 
  131                   ignerr << 
"Failed to create sensor, received null SDF " 
  136                 auto sensor = std::make_unique<SensorType>();
 
  141                 if (
nullptr == sensor)
 
  143                   ignerr << 
"Failed to create sensor [" << name
 
  144                          << 
"] of type[" << type << 
"]" << 
std::endl;
 
  148                 if (!sensor->Load(_sdf))
 
  150                   ignerr << 
"Failed to load sensor [" << name
 
  151                          << 
"] of type[" << type << 
"]" << 
std::endl;
 
  157                   ignerr << 
"Failed to initialize sensor [" << name
 
  158                          << 
"] of type[" << type << 
"]" << 
std::endl;
 
  179           sdf::ElementPtr _sdf);
 
  197       public: 
std::unique_ptr<
Sensor> IGN_DEPRECATED(6) CreateSensor(
 
  203       public: 
void IGN_DEPRECATED(6) AddPluginPaths(const 
std::
string &_path);
 
  205       IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
 
  207       private: 
std::unique_ptr<SensorFactoryPrivate> dataPtr;
 
  208       IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
 
  
Definition: gz/sensors/AirPressureSensor.hh:31
 
SensorType * New() override
Instantiate new sensor.
Definition: gz/sensors/SensorFactory.hh:60
 
std::unique_ptr< SensorType > CreateSensor(sdf::ElementPtr _sdf)
Create a sensor from an SDF element with a known sensor type.
Definition: gz/sensors/SensorFactory.hh:127
 
Base sensor plugin interface.
Definition: gz/sensors/SensorFactory.hh:45
 
~SensorFactory()
Destructor.
 
virtual Sensor * New()=0
Instantiate new sensor.
 
SensorFactory()
Constructor.
 
void AddPluginPaths(const std::string &_path)
Add additional path to search for sensor plugins.
 
Templated class for instantiating sensors of the specified type.
Definition: gz/sensors/SensorFactory.hh:57
 
A factory class for creating sensors This class instantiates sensor objects based on the sensor type ...
Definition: gz/sensors/SensorFactory.hh:72
 
a base sensor class
Definition: gz/sensors/Sensor.hh:59
 
std::unique_ptr< SensorType > CreateSensor(const sdf::Sensor &_sdf)
Create a sensor from a SDF DOM object with a known sensor type.
Definition: gz/sensors/SensorFactory.hh:92