31 qDeleteAll( mMetadata );
36 if ( !mMetadata.isEmpty() )
41#if defined( HAVE_QTSERIALPORT )
50 return mMetadata.value( type );
55 if ( !metadata || mMetadata.contains( metadata->
type() ) )
58 mMetadata[metadata->
type()] = metadata;
65 if ( !mMetadata.contains( type ) )
72 if ( sensor->type() == type )
78 delete mMetadata.take( type );
84 if ( !mMetadata.contains( type ) )
87 return mMetadata[type]->createSensor( parent );
92 QMap<QString, QString> types;
93 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
95 types.insert( it.key(), it.value()->visibleName() );
An abstract base class for sensor classes.
static QgsProject * instance()
Returns the QgsProject singleton instance.
const QgsSensorManager * sensorManager() const
Returns the project's sensor manager, which manages sensors within the project.
bool removeSensor(const QString &id)
Removes a registered sensor matching a given id.
QList< QgsAbstractSensor * > sensors() const
Returns a list of pointers to all registered sensors.
~QgsSensorRegistry() override
bool addSensorType(QgsSensorAbstractMetadata *metadata)
Registers a new sensor type.
bool populate()
Populates the registry with standard sensor types.
QgsSensorRegistry(QObject *parent=nullptr)
Creates a new empty item registry.
void sensorAdded(const QString &type, const QString &name)
Emitted whenever a new sensor type is added to the registry, with the specified type and visible name...
bool removeSensorType(const QString &type)
Removes a new a sensor type from the registry.
QgsSensorAbstractMetadata * sensorMetadata(const QString &type) const
Returns the metadata for the specified sensor type.
QgsAbstractSensor * createSensor(const QString &type, QObject *parent=nullptr) const
Creates a new instance of a sensor given the type.
QMap< QString, QString > sensorTypes() const
Returns a map of available sensor types to translated name.
static QgsTcpSocketSensor * create(QObject *parent)
Returns a new TCP socket sensor.
static QgsUdpSocketSensor * create(QObject *parent)
Returns a new UDP socket sensor.