24#include "moc_qgssensorregistry.cpp"
33 qDeleteAll( mMetadata );
38 if ( !mMetadata.isEmpty() )
43#if defined( HAVE_QTSERIALPORT )
52 return mMetadata.value( type );
57 if ( !metadata || mMetadata.contains( metadata->
type() ) )
60 mMetadata[metadata->
type()] = metadata;
67 if ( !mMetadata.contains( type ) )
74 if ( sensor->type() == type )
80 delete mMetadata.take( type );
86 if ( !mMetadata.contains( type ) )
89 return mMetadata[type]->createSensor( parent );
94 QMap<QString, QString> types;
95 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
97 types.insert( it.key(), it.value()->visibleName() );
An abstract base class for sensors.
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.