QIviServiceManager Class
QIviServiceManager provides the backends to QIviAbstractFeature. More...
Header: | #include <QIviServiceManager> |
qmake: | QT += ivicore |
Instantiated By: | ServiceManager |
Inherits: | QAbstractListModel |
Public Types
enum | BackendType { ProductionBackend, SimulationBackend } |
enum | Roles { NameRole, ServiceObjectRole, InterfacesRole } |
enum | SearchFlag { IncludeProductionBackends, IncludeSimulationBackends, IncludeAll } |
flags | SearchFlags |
Public Functions
QList<QIviServiceObject *> | findServiceByInterface(const QString &interface, QIviServiceManager::SearchFlags searchFlags = IncludeAll) |
bool | hasInterface(const QString &interface) const |
bool | registerService(QObject *serviceBackendInterface, const QStringList &interfaces, QIviServiceManager::BackendType backendType = ProductionBackend) |
Reimplemented Public Functions
virtual QVariant | data(const QModelIndex &index, int role) const override |
virtual QHash<int, QByteArray> | roleNames() const override |
virtual int | rowCount(const QModelIndex &parent = QModelIndex()) const override |
Static Public Members
QIviServiceManager * | instance() |
Detailed Description
QIviServiceManager is the heart of QtIvi and provides you with an easy way to detect which backends and interfaces are available.
By default, QIviServiceManager reads the metaData of all plugins within the qtivi folder in your plugin path. The plugin itself is loaded when you request for it explicitly, using findServiceByInterface().
The manager can distinguish between Production and Simulation backends, using the filename or the metaData.
Simulation Backends can set the simulation
key in their plugin metadata to true
or use one of two supported plugin postfixes (_simulation, _simulator) in the plugin filename.
The registerService() function can be used to add Backend classes without putting them into a plugin.
The service manager is a process-wide singleton and can be accessed through the instance method.
If you require more detailed information on which plugins are recognized, make sure you enable the qt.ivi.servicemanagement
logging category.
For more information on how backends are loaded, see Dynamic Backend System.
Note: The QIviServiceManager only accepts plugins that match the build configuration used for building qtivicore. This means a qtivicore "release" build won't accept plugins from a "debug" build.
Member Type Documentation
enum QIviServiceManager::BackendType
Constant | Value | Description |
---|---|---|
QIviServiceManager::ProductionBackend | 0 | A backend controlling a real automotive interface, such as a climate control connected over the CAN bus. |
QIviServiceManager::SimulationBackend | 1 | A backend used for development, that only returns simulation values and won't be deployed to the final hardware. |
enum QIviServiceManager::Roles
Constant | Value | Description |
---|---|---|
QIviServiceManager::NameRole | Qt::DisplayRole | The backend's name, such as MediaPlugin. |
QIviServiceManager::ServiceObjectRole | Qt::UserRole | The actual QIviServiceObject, which can be used to connect a frontend API to this backend. |
Note: When using this role in the data() function, the backend plugin is loaded and instantiated.
Constant | Value | Description |
---|---|---|
QIviServiceManager::InterfacesRole | Qt::UserRole +1 | A list of interfaces that the backend implements. |
enum QIviServiceManager::SearchFlag
flags QIviServiceManager::SearchFlags
Constant | Value | Description |
---|---|---|
QIviServiceManager::IncludeProductionBackends | 0x01 | Include production backends in the search result. |
QIviServiceManager::IncludeSimulationBackends | 0x02 | Include simulation backends in the search result. |
QIviServiceManager::IncludeAll | IncludeProductionBackends | IncludeSimulationBackends | Include both production and simulation backends in the search result. |
The SearchFlags type is a typedef for QFlags<SearchFlag>. It stores an OR combination of SearchFlag values.
See also ProductionBackend and SimulationBackend.
Member Function Documentation
[override virtual]
QVariant QIviServiceManager::data(const QModelIndex &index, int role) const
Reimplements: QAbstractItemModel::data(const QModelIndex &index, int role) const.
Returns the data for the index and role specified.
See also QAbstractListModel::data().
QList<QIviServiceObject *> QIviServiceManager::findServiceByInterface(const QString &interface, QIviServiceManager::SearchFlags searchFlags = IncludeAll)
Returns a list of backends implementing the specified interface.
The searchFlags argument can be used to control which type of backends are included in the search result.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
bool QIviServiceManager::hasInterface(const QString &interface) const
Returns true
if the specified interface has been registered.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[static]
QIviServiceManager *QIviServiceManager::instance()
Returns the global service manager instance.
bool QIviServiceManager::registerService(QObject *serviceBackendInterface, const QStringList &interfaces, QIviServiceManager::BackendType backendType = ProductionBackend)
Registers a backend. The serviceBackendInterface specified must implement the QIviServiceInterface, otherwise the registration will fail. interfaces is a list of at least one interface, supported by the backend. The backendType indicates the type of the backend and influences whether the backend can be found by the Feature's auto discovery option.
Returns true
if the backend was successfully registered; otherwise false
.
See also QIviServiceInterface.
[override virtual]
QHash<int, QByteArray> QIviServiceManager::roleNames() const
Reimplements: QAbstractItemModel::roleNames() const.
[override virtual]
int QIviServiceManager::rowCount(const QModelIndex &parent = QModelIndex()) const
Reimplements: QAbstractItemModel::rowCount(const QModelIndex &parent) const.
Returns the number of rows for the given parent. Typically parent is an empty model index.
See also QAbstractListModel::data().
© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.