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/utils/SuppressWarning.hh>
28 #include <gz/sensors/config.hh>
29 #include <gz/sensors/Export.hh>
38 inline namespace GZ_SENSORS_VERSION_NAMESPACE {
40 class SensorFactoryPrivate;
49 public:
virtual Sensor GZ_DEPRECATED(6) * New() = 0;
56 template<
class SensorType>
60 public: SensorType GZ_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 gzerr <<
"Failed to create sensor [" << _sdf.Name()
99 <<
"] of type[" << _sdf.TypeStr() <<
"]" <<
std::endl;
103 if (!sensor->Load(_sdf))
105 gzerr <<
"Failed to load sensor [" << _sdf.Name()
106 <<
"] of type[" << _sdf.TypeStr() <<
"]" <<
std::endl;
112 gzerr <<
"Failed to initialize sensor [" << _sdf.Name()
113 <<
"] of type[" << _sdf.TypeStr() <<
"]" <<
std::endl;
126 public:
template<
typename SensorType>
131 gzerr <<
"Failed to create sensor, received null SDF "
136 auto sensor = std::make_unique<SensorType>();
141 if (
nullptr == sensor)
143 gzerr <<
"Failed to create sensor [" << name
144 <<
"] of type[" << type <<
"]" <<
std::endl;
148 if (!sensor->Load(_sdf))
150 gzerr <<
"Failed to load sensor [" << name
151 <<
"] of type[" << type <<
"]" <<
std::endl;
157 gzerr <<
"Failed to initialize sensor [" << name
158 <<
"] of type[" << type <<
"]" <<
std::endl;
179 sdf::ElementPtr _sdf);
197 public:
std::unique_ptr<
Sensor> GZ_DEPRECATED(6) CreateSensor(
203 public:
void GZ_DEPRECATED(6) AddPluginPaths(const
std::
string &_path);
205 GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
207 private:
std::unique_ptr<SensorFactoryPrivate> dataPtr;
208 GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING