diff options
| author | Dominik Holland <dominik.holland@qt.io> | 2023-09-20 17:24:54 +0200 |
|---|---|---|
| committer | Dominik Holland <dominik.holland@qt.io> | 2023-09-29 09:33:36 +0200 |
| commit | 174c70b7efdd50866a69c9795bf55ae6ce54e7d8 (patch) | |
| tree | e866ae4cf5ba7429dbc2ce9d549002015a085382 /src/interfaceframework/qiffeatureinterface.cpp | |
| parent | 9c4b8e84c05deda94c1334e8d98e88632c884d6d (diff) | |
Documentation update
* Make the documentation less automotive specific
* Give more examples where the zones concept is useful
* Add a better overview documentation to:
QIfAbstractZonedFeature
QIfZonedFeatureInterface
QIFeatureInterface
Task-number: QTBUG-99004
Task-number: QTBUG-116203
Pick-to: 6.6 6.6.0
Change-Id: Icef354f97c5bf504abb3b93886e9866ed185e3d9
Reviewed-by: Robert Griebl <robert.griebl@qt.io>
Diffstat (limited to 'src/interfaceframework/qiffeatureinterface.cpp')
| -rw-r--r-- | src/interfaceframework/qiffeatureinterface.cpp | 65 |
1 files changed, 56 insertions, 9 deletions
diff --git a/src/interfaceframework/qiffeatureinterface.cpp b/src/interfaceframework/qiffeatureinterface.cpp index 5eff9f66..260bd962 100644 --- a/src/interfaceframework/qiffeatureinterface.cpp +++ b/src/interfaceframework/qiffeatureinterface.cpp @@ -14,17 +14,64 @@ QT_BEGIN_NAMESPACE \brief QIfFeatureInterface defines the base class for all backends. - To implement a backend for a specific feature you need to derive from this class. - There's a one-to-one mapping between a spezialized feature API and its corresponding feature interface + To implement a backend for a specific feature, you need to derive from this class. There's a + one-to-one mapping between a specialized feature API and its corresponding feature interface class. - The feature interface class specifies which functions and signals need to be implemented by a backend - to work with a specific feature. - - This base class contains the generic error handling, which is common between all interfaces. - - See the full example backend implementation from \c {src/plugins/ifvehiclefunctions/climate_simulator}. - \sa QIfAbstractFeature, QIfServiceInterface + The feature interface class specifies which functions and signals need to be implemented by a + backend to work with a specific feature. + + This base class contains the initialization logic and the generic error handling, which is + common between all interfaces. + + A feature interface for coffee machine could look like this: + \code + class CoffeMachineInterface : public QIfFeatureInterface + { + void setTargetTemperature(int targetTemperature) = 0; + ... + + signals: + void currentTemperatureChanged(int currentTemperature); + void targetTemperatureChanged(int targetTemperature); + ... + } + \endcode + + A backend implementation providing the actual functionality needs to implement all pure-virtual + functions and the logic to provide property updates and their initial state. Once the feature + knows which backend implementation needs to be used, it will request the initial state of all + properties by calling the \l initialize() function. The implementation needs to emit the changed + signals with the initial values and once it is done, emit the \l initializationDone signal. + + In the coffee machine example the implementation could look like this: + + \code + class CoffeMachineImplementation : public CoffeMachineInterface + { + void initialize() + { + emit currentTemperature(0); + emit targetTemperature(0); + emit initializationDone(); + } + + void setTargetTemperature(int targetTemperature) + { + if (m_targetTemperature == targetTemperature) + return; + + // adjust the heating element to the new target temperature + emit targetTemperatureChanged(targetTemperature) + } + } + \endcode + + The implementation for \e setTargetTemperature() controls the internal heating element and once + that is done, the change signal is emitted to inform the feature about the new state of the + property. + + \sa QIfAbstractFeature */ QIfFeatureInterface::QIfFeatureInterface(QObject *parent) |
