QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgssensormanager.h
Go to the documentation of this file.
1/***************************************************************************
2 qgssensormanager.h
3 ------------------
4 Date : March 2023
5 Copyright : (C) 2023 Mathieu Pellerin
6 Email : mathieu at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSSENSORMANAGER_H
17#define QGSSENSORMANAGER_H
18
19#include "qgis.h"
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgsabstractsensor.h"
23
24#include <QDomElement>
25#include <QObject>
26
27class QgsProject;
28
41class CORE_EXPORT QgsSensorManager : public QObject
42{
43 Q_OBJECT
44
45 public:
46
50 explicit QgsSensorManager( QObject *parent SIP_TRANSFERTHIS = nullptr );
51
52 ~QgsSensorManager() override;
53
57 void clear();
58
62 QList<QgsAbstractSensor *> sensors() const;
63
68 QgsAbstractSensor *sensor( const QString &id ) const;
69
79
84 bool removeSensor( const QString &id );
85
89 QStringList sensorNames() const;
90
94 QgsAbstractSensor::SensorData sensorData( const QString &name ) const;
95
99 QMap<QString, QgsAbstractSensor::SensorData> sensorsData() const;
100
106 bool readXml( const QDomElement &element, const QDomDocument &document );
107
112 QDomElement writeXml( QDomDocument &document ) const;
113
114 signals:
115
117 void sensorAdded( const QString &id );
118
120 void sensorAboutToBeRemoved( const QString &id );
121
123 void sensorRemoved( const QString &id );
124
126 void sensorNameChanged( const QString &id );
127
129 void sensorStatusChanged( const QString &id );
130
132 void sensorDataCaptured( const QString &id );
133
135 void sensorErrorOccurred( const QString &id );
136
137 private slots:
138
139 void handleSensorNameChanged();
140 void handleSensorStatusChanged();
141 void captureSensorData();
142 void handleSensorErrorOccurred( const QString &errorMessage );
143
144 private:
145
146 QList<QgsAbstractSensor *> mSensors;
147 QMap<QString, QgsAbstractSensor::SensorData> mSensorsData;
148
149};
150
151#endif // QGSSENSORMANAGER_H
An abstract base class for sensors.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
void addSensor(QgsAbstractSensor *sensor)
Registers a new sensor.
void sensorRemoved(const QString &id)
Emitted when a sensor has been removed.
bool removeSensor(const QString &id)
Removes a registered sensor matching a given id.
void sensorErrorOccurred(const QString &id)
Emitted when a sensor error has occurred.
QgsSensorManager(QObject *parent=nullptr)
Constructor for QgsSensorManager, with the specified parent object.
QMap< QString, QgsAbstractSensor::SensorData > sensorsData() const
Returns the last captured data of all registered sensors.
void sensorNameChanged(const QString &id)
Emitted when a sensor name has changed.
QList< QgsAbstractSensor * > sensors() const
Returns a list of pointers to all registered sensors.
void sensorDataCaptured(const QString &id)
Emitted when newly captured data from a sensor has occurred.
QDomElement writeXml(QDomDocument &document) const
Returns a DOM element representing the state of the manager.
QgsAbstractSensor * sensor(const QString &id) const
Returns a registered sensor pointer matching a given id.
QStringList sensorNames() const
Returns a list of registered sensor names.
QgsAbstractSensor::SensorData sensorData(const QString &name) const
Returns the last captured data from a registered sensor matching a given name.
void clear()
Deregisters and removes all sensors from the manager.
void sensorAdded(const QString &id)
Emitted when a sensor has been registered.
void sensorAboutToBeRemoved(const QString &id)
Emitted when a sensor is about to be removed.
void sensorStatusChanged(const QString &id)
Emitted when a sensor status has changed.
bool readXml(const QDomElement &element, const QDomDocument &document)
Reads the manager's state from a DOM element, restoring all sensors present in the XML document.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_TRANSFER
Definition qgis_sip.h:36
Contains details of a sensor data capture.