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 of your plugin path. The plugin itself will be loaded once it's explicitly requested by the developer by using findServiceByInterface().

The manager can distinguish between Production and Simulation backends. For the recognition either the filename or the metaData is used.

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.

For more detailed information on which plugins are recognized, enable the "qt.ivi.servicemanagement" logging category.

See Dynamic Backend System for more information about how backend loading works.

Note: The QIviServiceManager will only accept plugins, which match the build configuration used for building qtivicore. This means qtivicore "release" build, doesn't accept plugins from a "debug" build.

Member Type Documentation

enum QIviServiceManager::BackendType

QIviServiceManager::ProductionBackend0A backend controlling a real automotive interface (e.g. a climate control connected over the CAN bus)
QIviServiceManager::SimulationBackend1A backend used for development as it's only returning simulation values and won't be deployed to the final hardware

enum QIviServiceManager::Roles

QIviServiceManager::NameRoleQt::DisplayRoleThe name of the backend e.g. MediaPlugin
QIviServiceManager::ServiceObjectRoleQt::UserRoleThe 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 will be loaded and instantiated.

QIviServiceManager::InterfacesRoleQt::UserRole +1A list of interefaces the backend implements.

enum QIviServiceManager::SearchFlag
flags QIviServiceManager::SearchFlags

QIviServiceManager::IncludeProductionBackends0x01Include production backends in the search result.
QIviServiceManager::IncludeSimulationBackends0x02Include simulation backends in the search result.
QIviServiceManager::IncludeAllIncludeProductionBackends | IncludeSimulationBackendsInclude 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 index and role.

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)

Register a backend. The provided serviceBackendInterface must implement the QIviServiceInterface else the registration will fail. interfaces is a list with interfaces (at least one) supported by the backend. The backendType indicates the type of the backend and has influence on whether the backend is found by the auto discovery of the Feature.

Returns true if the backend was successfully registered else 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.