26#include "moc_qgssensorregistry.cpp"
28using namespace Qt::StringLiterals;
37 qDeleteAll( mMetadata );
42 if ( !mMetadata.isEmpty() )
47#if defined( HAVE_QTSERIALPORT )
56 return mMetadata.value( type );
61 if ( !metadata || mMetadata.contains( metadata->
type() ) )
64 mMetadata[metadata->
type()] = metadata;
71 if ( !mMetadata.contains( type ) )
78 if ( sensor->type() == type )
84 delete mMetadata.take( type );
90 if ( !mMetadata.contains( type ) )
93 return mMetadata[type]->createSensor( parent );
98 QMap<QString, QString> types;
99 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
101 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.