20#include "moc_qgssensorregistry.cpp"
32 qDeleteAll( mMetadata );
37 if ( !mMetadata.isEmpty() )
42#if defined( HAVE_QTSERIALPORT )
51 return mMetadata.value( type );
56 if ( !metadata || mMetadata.contains( metadata->
type() ) )
59 mMetadata[metadata->
type()] = metadata;
66 if ( !mMetadata.contains( type ) )
73 if ( sensor->type() == type )
79 delete mMetadata.take( type );
85 if ( !mMetadata.contains( type ) )
88 return mMetadata[type]->createSensor( parent );
93 QMap<QString, QString> types;
94 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
96 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.