aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKavindra Palaraja <kpalaraja@luxoft.com>2019-06-26 13:52:43 +0200
committerKavindra Palaraja <kpalaraja@luxoft.com>2019-07-12 11:39:09 +0200
commit825fe968b90a711dae4d6303a7177f2983dcade1 (patch)
treeecaa525f07162068c764b41ff8c98073cc4db0f2
parent626321034c47beb18c3d63fc7fc69da320ea77db (diff)
[docs] Review of API Reference
Change-Id: Icfe75b3f01adc33bf7376bb16fd7c762fe2df741 Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r--src/ivicore/qiviabstractfeature.cpp148
-rw-r--r--src/ivicore/qiviserviceinterface.cpp11
-rw-r--r--src/ivicore/qiviservicemanager.cpp100
-rw-r--r--src/ivicore/qiviserviceobject.cpp16
-rw-r--r--src/ivicore/qivisimulationengine.cpp125
5 files changed, 209 insertions, 191 deletions
diff --git a/src/ivicore/qiviabstractfeature.cpp b/src/ivicore/qiviabstractfeature.cpp
index d5e20e9..906ac5f 100644
--- a/src/ivicore/qiviabstractfeature.cpp
+++ b/src/ivicore/qiviabstractfeature.cpp
@@ -88,12 +88,12 @@ bool QIviAbstractFeaturePrivate::notify(const QByteArray &propertyName, const QV
\internal Returns the backend object retrieved from calling interfaceInstance() with the
interfaceName of this private class.
- This is the is a sane default for most classes and provides a convenient way to get the backend
- interface and also allow manually overwritting it to something else.
+ For most classes, this is the sane default and it provides a convenient way to get the backend
+ interface and also allow for manually overwriting it with something else.
- If the derived class needs to connect to a different interface than defined by interfaceName or
- to an additional interface, it can still manually ask for the needed interfaceInstance using
- the QIviServiceObject directly.
+ If the derived class needs to connect to a different interface than the one defined by
+ \c interfaceName or to an additional interface, it can still manually ask for the required
+ \c interfaceInstance using the QIviServiceObject directly.
*/
QIviFeatureInterface *QIviAbstractFeaturePrivate::backend() const
{
@@ -133,27 +133,30 @@ void QIviAbstractFeaturePrivate::onInitializationDone()
\inmodule QtIviCore
\brief The QIviAbstractFeature is the base class for all QtIvi Features.
- QIviAbstractFeature is the base class for the front facing API towards the developer.
- The QIviAbstractFeature provides you with a way to automatically connect to a backend implementing
- the interface needed. This discovery is started by using the startAutoDiscovery() function.
+ QIviAbstractFeature is the base class for the front-facing API towards the developer.
+ The QIviAbstractFeature provides you with a way to automatically connect to a backend
+ implementing the interface needed. To discover a backend, we start it using the
+ startAutoDiscovery() function.
- Once the auto discovery is done, it can be checked whether a backend has been found by using the
- isValid function.
+ Once the auto discovery is complete, you can check whether a backend was found using the
+ isValid() function.
- The auto discovery gives you an easy way to automatically connect to the right backend implementation.
- If you don't want to use the auto discovery, it's also possible to use QIviServiceManager to retrieve
- all Backends and search manually for the right one and connect it to the QIviAbstractFeature by calling
- setServiceObject().
+ The auto discovery gives you an easy way to automatically connect to the right backend
+ implementation. If you don't want to use the auto discovery, it's also possible to use
+ QIviServiceManager to retrieve all backends. Then, manually search for the right backend
+ and call setServiceObject() to connect it to the QIviAbstractFeature.
- The type of backend to be loaded can be controlled by setting the auto discovery mode. By default,
- it is set to AutoDiscovery, which indicates that a production backend will be preferred over a simulation backend.
+ The type of backend to load can be controlled by setting the \c discvoeryMode to
+ \c AutoDiscovery. This mode is enabled by default, which indicates that a production backend
+ is always preferred over a simulation backend.
- QIviAbstractFeature is an abstract base class that needs to be subclassed to create an API for your
- Feature.
+ QIviAbstractFeature is an abstract base class that you need to subclass to create an API
+ for your feature.
- \section1 Subclassing
+ \section1 Write a Subclass
+
+ Your QIviAbstractFeature subclass must provide implementations for the following functions:
- When subclassing QIviAbstractFeature, you must provide implementations of the following functions:
\list
\li acceptServiceObject()
\li connectToServiceObject()
@@ -161,57 +164,61 @@ void QIviAbstractFeaturePrivate::onInitializationDone()
\li clearServiceObject()
\endlist
- Once a QIviServiceObject has been set, either by auto discovery or by manually setting it, the acceptServiceObject()
- function will be called to make sure the QIviServiceObject provides everything needed by the Feature.
+ Once a QIviServiceObject has been set, either via startAutoDiscovery() or setServiceObject(),
+ the acceptServiceObject() function is then called to make sure that the implemented feature
+ can work with the QIviServiceObject and, in turn, the QIviServiceObject provides the required
+ interface.
- If the interface provides signals, you need to do all the connect statements in connectToServiceObject() and
- disconnect them again in disconnectFromServiceObject().
+ If the interface provides signals, you need to make all the connect statements in
+ connectToServiceObject(); then disconnect them in disconnectFromServiceObject().
- clearServiceObject() will be called once the Feature doesn't have a connection to a ServiceObject anymore and should
- reset its state to sane defaults.
+ clearServiceObject() is called once the feature doesn't have a connection to a ServiceObject
+ anymore and needs to reset its state to feasible defaults.
*/
/*!
\enum QIviAbstractFeature::Error
\value NoError
- No error
+ No error
\value PermissionDenied
- Permission for the operation is denied
+ Permission for the operation is denied
\value InvalidOperation
- Operation is invalid
+ Operation is invalid
\value Timeout
- Operation timeout
+ Operation timeout
\value InvalidZone
- Zone is not available for the operation
+ Zone is not available for the operation
\value Unknown
- Unknown error
+ Unknown error
*/
/*!
\enum QIviAbstractFeature::DiscoveryMode
\value NoAutoDiscovery
- No auto discovery is done and the ServiceObject needs to be set manually
+ No auto discovery is done and the ServiceObject needs to be set manually.
\value AutoDiscovery
- Tries to first find a production backend with a matching interface and falls back to a simulation backend if not found
+ The feature first tries to find a production backend with a matching interface. If it's
+ not available, then the feature falls back to a simulation backend.
\value LoadOnlyProductionBackends
- Only tries to load a production backend with a matching interface
+ The feature tries to load a production backend with a matching interface only.
\value LoadOnlySimulationBackends
- Only tries to load a simulation backend with a matching interface
+ The feature tries to load a simulation backend with a matching interface only.
*/
/*!
\enum QIviAbstractFeature::DiscoveryResult
\value NoResult
- Indicates that no auto discovery was started because the feature has already assigned a valid ServiceObject
+ Indicates that no auto discovery was started because the feature already has a valid
+ ServiceObject assigned.
\value ErrorWhileLoading
- An error has happened while searching for a backend with a matching interface
+ An error has occurred while searching for a backend with a matching interface.
\value ProductionBackendLoaded
- As a result of the auto discovery a production backend was loaded
+ A production backend was loaded, as a result of auto discovery.
\value SimulationBackendLoaded
- As a result of the auto discovery a simulation backend was loaded
+ A simulation backend was loaded, as a result of auto discovery.
*/
/*!
@@ -263,11 +270,11 @@ QIviAbstractFeature::QIviAbstractFeature(const QString &interface, QObject *pare
\qmlproperty ServiceObject AbstractFeature::serviceObject
\brief Sets the service object for the feature.
- As features only expose the front API facing the developer, a service object implementing the
+ As Features only expose the front API facing the developer, a service object implementing the
actual function is required. This is usually retrieved through the auto discovery mechanism.
- The setter for this property returns false if the \e {Service Object} is already set to exactly this instance
- or the \e {Service Object} doesn't get accepted by the feature.
+ The setter for this property returns false if the \c QIviServiceObject is already set to this
+ particular instance or the QIviServiceObject isn't accepted by the feature.
\sa discoveryMode
*/
@@ -275,11 +282,11 @@ QIviAbstractFeature::QIviAbstractFeature(const QString &interface, QObject *pare
\property QIviAbstractFeature::serviceObject
\brief Sets the service object for the feature.
- As features only expose the front API facing the developer, a service object implementing the
+ As Features only expose the front API facing the developer, a service object implementing the
actual function is required. This is usually retrieved through the auto discovery mechanism.
- The setter for this property returns false if the \e {Service Object} is already set to exactly this instance
- or the \e {Service Object} doesn't get accepted by the feature.
+ The setter for this property returns false if the \c QIviServiceObject is already set to this
+ particular instance or the QIviServiceObject isn't accepted by the feature.
\sa discoveryMode
*/
@@ -337,24 +344,25 @@ bool QIviAbstractFeature::setServiceObject(QIviServiceObject *so)
\value NoAutoDiscovery
No auto discovery is done and the ServiceObject needs to be set manually.
\value AutoDiscovery
- Tries to find a production backend with a matching interface and falls back to a simulation backend if not found.
+ Tries to find a production backend with a matching interface and falls back to a
+ simulation backend if not found.
\value LoadOnlyProductionBackends
Only tries to load a production backend with a matching interface.
\value LoadOnlySimulationBackends
Only tries to load a simulation backend with a matching interface.
- If needed the auto discovery will be started once the Feature creation is completed.
+ If necessary, auto discovery is started once the feature creation is completed.
- \note If you change this property after the Feature is instantiated you need to call startAutoDiscovery() to search for
- a new Service Object
+ \note If you change this property after the feature is instantiated, make sure to call
+ startAutoDiscovery() to search for a new service object.
*/
/*!
\property QIviAbstractFeature::discoveryMode
\brief Holds the mode that is used for the autoDiscovery
- \note If you change this property after the Feature is instantiated you need to call startAutoDiscovery() to search for
- a new Service Object
+ \note If you change this property after the feature is instantiated, make sure to call
+ startAutoDiscovery() to search for a new service object.
*/
void QIviAbstractFeature::setDiscoveryMode(QIviAbstractFeature::DiscoveryMode discoveryMode)
{
@@ -387,9 +395,10 @@ void QIviAbstractFeature::componentComplete()
}
/*!
- Returns the interface name this Feature is implementing.
+ Returns the interface name this feature is implementing.
- When the Feature discovers a matching backend, this interface name needs to be supported by the Service Object the Feature is connecting to.
+ When the feature discovers a matching backend, this interface's name needs to be supported by
+ the service object that the feature is connecting to.
See \l {Extending Qt IVI} for more information.
*/
@@ -417,13 +426,14 @@ QIviAbstractFeature::DiscoveryMode QIviAbstractFeature::discoveryMode() const
Available values are:
\value NoResult
- Indicates that no auto discovery was started because the feature has already assigned a valid ServiceObject.
+ Indicates that no auto discovery was started because the feature has already assigned a
+ valid ServiceObject.
\value ErrorWhileLoading
An error has happened while searching for a backend with a matching interface.
\value ProductionBackendLoaded
- As a result of the auto discovery a production backend was loaded.
+ A production backend was loaded, as a result of auto discovery.
\value SimulationBackendLoaded
- As a result of the auto discovery a simulation backend was loaded.
+ A simulation backend was loaded, as a result of auto discovery.s
*/
/*!
@@ -503,25 +513,27 @@ QString QIviAbstractFeature::errorText() const
Performs an automatic discovery attempt.
- The feature will try to locate a single service object implementing the required interface.
+ The feature tries to locate a single ServiceObject that implements the required interface.
- If no service object is found, the feature will stay invalid. If more than one service object
- is found, the first instance is used.
+ If no ServiceObject is found, the feature remains invalid. If more than one ServiceObject
+ is found, the \b first instance is used.
- Either the type of the backend which was loaded or an error is returned.
+ This function returns either the type of the backend that was loaded; or an error.
- If the discoveryMode is set to QIviAbstractFeature::NoAutoDiscovery this function will
- do nothing and return QIviAbstractFeature::NoResult.
+ If the \c discoveryMode is set to QIviAbstractFeature::NoAutoDiscovery, this function does
+ nothing and returns QIviAbstractFeature::NoResult.
Return values are:
\value NoResult
- Indicates that no auto discovery was started because the feature has already assigned a valid ServiceObject.
+ Indicates that no auto discovery was started because the feature already has
+ a valid ServiceObject assigned.
\value ErrorWhileLoading
- An error has happened while searching for a backend with a matching interface.
+ Indicates an error has occurred while searching for a backend with a matching
+ interface.
\value ProductionBackendLoaded
- As a result of the auto discovery a production backend was loaded.
+ A production backend was loaded, as a result of auto discovery.
\value SimulationBackendLoaded
- As a result of the auto discovery a simulation backend was loaded.
+ A simulation backend was loaded, as a result of auto discovery.
\sa {Dynamic Backend System} QIviServiceManager
*/
@@ -773,7 +785,7 @@ bool QIviAbstractFeature::isInitialized() const
/*!
Updates \a error and \a message from the backend.
- This slot can be used when implementing a new Feature to report generic errors.
+ Use this slot when you implement a new feature to report generic errors.
*/
void QIviAbstractFeature::onErrorChanged(QIviAbstractFeature::Error error, const QString &message)
{
diff --git a/src/ivicore/qiviserviceinterface.cpp b/src/ivicore/qiviserviceinterface.cpp
index fd602aa..79cd83e 100644
--- a/src/ivicore/qiviserviceinterface.cpp
+++ b/src/ivicore/qiviserviceinterface.cpp
@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
Casts the given \a backend to the interface type T.
- When implementing a QtIvi Feature this function should be used, as it shows a meaningful error
- message when the cast fails.
+ When implementing a QtIvi Feature, use this function as it shows a meaningful error message
+ when the cast fails.
\sa qobject_cast
*/
@@ -59,11 +59,12 @@ QT_BEGIN_NAMESPACE
/*!
\class QIviServiceInterface
\inmodule QtIviCore
- \brief Interface class for services.
+ \brief Defines the interface for services.
- The QIviServiceInterface class defines the interface of services registered with QIviServiceManager.
+ The QIviServiceInterface class defines the interface for services registered with QIviServiceManager.
- Commonly, service objects inherit the concrete class QIviServiceObject instead of using QIviServiceInterface directly.
+ Typically, service objects inherit the concrete class, QIviServiceObject, instead of using
+ QIviServiceInterface directly.
\sa QIviServiceObject
*/
diff --git a/src/ivicore/qiviservicemanager.cpp b/src/ivicore/qiviservicemanager.cpp
index 552a1a4..b5d835f 100644
--- a/src/ivicore/qiviservicemanager.cpp
+++ b/src/ivicore/qiviservicemanager.cpp
@@ -394,100 +394,106 @@ QIviServiceInterface *QIviServiceManagerPrivate::loadServiceBackendInterface(str
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().
+ By default, QIviServiceManager reads the metaData of all plugins within the \e qtivi folder
+ in your plugin path. The plugin itself is loaded when you request for it explicitly, using
+ findServiceByInterface().
- The manager can distinguish between \e Production and \e Simulation backends. For the recognition
- either the filename or the metaData is used.
+ The manager can distinguish between \e Production and \e Simulation backends, using the
+ filename or the metaData.
- Simulation Backends can set the \e simulation key in their plugin metadata to \e true or use
+ Simulation Backends can set the \c simulation key in their plugin metadata to \c 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 \l instance method.
+ The service manager is a process-wide singleton and can be accessed through the \l instance
+ method.
- For more detailed information on which plugins are recognized, enable the "qt.ivi.servicemanagement"
- logging category.
+ If you require more detailed information on which plugins are recognized, make sure you enable
+ the \c{qt.ivi.servicemanagement} logging category.
- See \l {Dynamic Backend System} for more information about how backend loading works.
+ For more information on how backends are loaded, see \l {Dynamic Backend System}.
- \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.
+ \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.
*/
/*!
\enum QIviServiceManager::Roles
+
\value NameRole
- The name of the backend e.g. MediaPlugin
+ The backend's name, such as MediaPlugin.
\value ServiceObjectRole
- 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 will be loaded and instantiated.
+ 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.
\value InterfacesRole
- A list of interefaces the backend implements.
+ A list of interfaces that the backend implements.
*/
/*!
\enum QIviServiceManager::SearchFlag
\value IncludeProductionBackends
- Include production backends in the search result. \sa ProductionBackend
+ Include production backends in the search result. \sa ProductionBackend
\value IncludeSimulationBackends
- Include simulation backends in the search result. \sa SimulationBackend
+ Include simulation backends in the search result. \sa SimulationBackend
\value IncludeAll
- Include production and simulation backends in the search result
+ Include both production and simulation backends in the search result.
*/
/*!
\enum QIviServiceManager::BackendType
\value ProductionBackend
- A backend controlling a real automotive interface (e.g. a climate control connected over the CAN bus)
+ A backend controlling a real automotive interface, such as a climate control connected
+ over the CAN bus.
\value SimulationBackend
- A backend used for development as it's only returning simulation values and won't be deployed to the final hardware
+ A backend used for development, that only returns simulation values and won't be
+ deployed to the final hardware.
*/
/*!
\qmltype ServiceManager
\instantiates QIviServiceManager
\inqmlmodule QtIvi
-
- \brief The ServiceManager is the central instance loading the backends and providing ServiceObjects.
+ \brief The central instance that loads the backends and provides ServiceObjects.
The ServiceManager singleton provides a model which can be used to list all available backends
and their interfaces.
- This can be useful when you want to query all available backends for a specific interface.
- E.g. showing a list of all available backends which implement the MediaPlayer interface. This
- could be used to provide the user the options, to select between multiple options. e.g. local
- playback, or playback using a bluetooth device.
+ This class can be useful when you want to query all available backends for a specific interface.
+ For example, to show a list of all available backends which implement the MediaPlayer interface.
+ The use can then be presented with an option to select between local playback, or playback using
+ a bluetooth device.
The ServiceManager implements the QAbstractListModel interface and provides the following roles:
\table
\header
- \li Role name
+ \li Role Name
\li Type
\li Description
\row
\li \c name
\li string
- \li The name of the backend e.g. MediaPlugin
+ \li The backend's name, such as MediaPlugin.
\row
\li \c serviceObject
\li ServiceObject
\li 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 will be loaded and instantiated.
+ \note When using this role in the data() function, the backend plugin is loaded and
+ instantiated.
\row
\li \c interfaces
\li list<string>
\li A list of interfaces implemented by the backend.
\endtable
- \note Please see the \l{QIviServiceManager}{C++ documentation} for more information about what the QIviServiceManager is and
- how it works.
+ For more information about QIviServiceManager and how it works, see its \l{QIviServiceManager}{C++ documentation}.
*/
QIviServiceManager::QIviServiceManager()
@@ -512,19 +518,21 @@ QIviServiceManager *QIviServiceManager::instance()
Returns a list of backends implementing the specified \a interface.
- The \a searchFlags argument can be used to control which type of backends are included in the search result:
+ The \a searchFlags argument can be used to control which type of backends are included in the
+ search result:
\value IncludeProductionBackends
- Include production backends in the search result. See also \l {QIviServiceManager::}{ProductionBackend}
+ Include production backends in the search result. See also \l {QIviServiceManager::}{ProductionBackend}
\value IncludeSimulationBackends
- Include simulation backends in the search result. See also \l {QIviServiceManager::}{SimulationBackend}
+ Include simulation backends in the search result. See also \l {QIviServiceManager::}{SimulationBackend}
\value IncludeAll
- Include production and simulation backends in the search result
+ Include both production and simulation backends in the search result.
*/
/*!
Returns a list of backends implementing the specified \a interface.
- The \a searchFlags argument can be used to control which type of backends are included in the search result.
+ The \a searchFlags argument can be used to control which type of backends are included in the
+ search result.
*/
QList<QIviServiceObject *> QIviServiceManager::findServiceByInterface(const QString &interface, SearchFlags searchFlags)
{
@@ -533,13 +541,12 @@ QList<QIviServiceObject *> QIviServiceManager::findServiceByInterface(const QStr
}
/*!
- Register a backend. The provided \a serviceBackendInterface must implement the
- QIviServiceInterface else the registration will fail. \a interfaces is a list
- with interfaces (at least one) supported by the backend. The \a backendType
- indicates the type of the backend and has influence on whether the backend is
- found by the auto discovery of the Feature.
+ Registers a backend. The \a serviceBackendInterface specified must implement the
+ QIviServiceInterface, otherwise the registration will fail. \a interfaces is a list of at least
+ one interface, supported by the backend. The \a 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 else false.
+ Returns \c true if the backend was successfully registered; otherwise \c false.
\sa QIviServiceInterface
*/
@@ -552,7 +559,7 @@ bool QIviServiceManager::registerService(QObject *serviceBackendInterface, const
/*!
\internal
- Unloads all currently loaded backends. Commonly only used for unit testing.
+ Unloads all backends currently loaded . Commonly only used for unit testing.
*/
void QIviServiceManager::unloadAllBackends()
{
@@ -575,7 +582,8 @@ bool QIviServiceManager::hasInterface(const QString &interface) const
}
/*!
- Returns the number of rows for the given \a parent. Typically \a parent is an empty model index.
+ Returns the number of rows for the given \a parent. Typically \a parent is an empty model
+ index.
\sa QAbstractListModel::data()
*/
@@ -586,7 +594,7 @@ int QIviServiceManager::rowCount(const QModelIndex &parent) const
}
/*!
- Returns the data for \a index and \a role.
+ Returns the data for the \a index and \a role specified.
\sa QAbstractListModel::data()
*/
diff --git a/src/ivicore/qiviserviceobject.cpp b/src/ivicore/qiviserviceobject.cpp
index 63f17f9..56e27e2 100644
--- a/src/ivicore/qiviserviceobject.cpp
+++ b/src/ivicore/qiviserviceobject.cpp
@@ -49,13 +49,13 @@ QT_BEGIN_NAMESPACE
/*!
\class QIviServiceObject
\inmodule QtIviCore
- \brief QIviServiceObject is the connection point to a Backend Service.
+ \brief Provides the connection point to a Backend Service.
- QIviServiceObject provides you with a list of interfaces the Backend implements.
+ QIviServiceObject provides you with a list of interfaces that the Backend implements.
- By using interfaceInstance() a QObject implementing this interface will be returned.
- The returned interface can contain signals that need to be connected to by the Feature
- implementing this interface.
+ Use interfaceInstance() to obtain a QObject that implements this interface. The
+ interface returned may contain signals that a Feature implementing this interface
+ needs to be connected to.
\sa QIviAbstractFeature
*/
@@ -77,12 +77,12 @@ QIviServiceObject::QIviServiceObject(QObject *parent)
\brief A unique ID for the service object instance.
Each service object has a unique ID. When subclassing, the id()
- function can be overloaded to control the generation of the ID.
+ function can be overloaded to modify how this ID is generated.
*/
/*!
- The id() function can be overloaded to control the generation of
- the unique ID used by this service object.
+ The id() function can be overloaded to modify how the unique ID is generated,
+ for use by this service object.
By default, QUuid::createUuid() is used.
*/
diff --git a/src/ivicore/qivisimulationengine.cpp b/src/ivicore/qivisimulationengine.cpp
index bfefab0..52cfb04 100644
--- a/src/ivicore/qivisimulationengine.cpp
+++ b/src/ivicore/qivisimulationengine.cpp
@@ -117,24 +117,22 @@ using namespace qtivi_helper;
/*!
\class QIviSimulationEngine
\inmodule QtIviCore
- \brief QIviSimulationEngine provides a way to script a simulation backend from QML.
+ \brief Provides a way to script a simulation backend from QML.
This class is an extended QQmlApplicationEngine which can be used to load QML files. It is made
- especially for \l {Dynamic Backend System}{simulation backends} to script the behavior of a
- simulation backend from QML. An overview of the functionality is also provided in
- \l{Qt IVI Simulation System}.
+ especially for \l {Dynamic Backend System}{simulation backends} to script its behavior from
+ QML. For an overview of its functionality, see \l{Qt IVI Simulation System}.
- In contrast to a normal QQmlEngine the QIviSimulationEngine provides an extra template function
- called registerSimulationInstance().
- Using this function it is possible to register an class instance as a QML type. Inside a QML
- file this QML type can be used to define the behavior for function calls, update properties or
- emit signals.
+ Compared to a normal QQmlEngine, the QIviSimulationEngine provides an extra template function
+ called registerSimulationInstance(). Use this function to register a class instance as a QML
+ type. Within a QML file, this QML type can be used to define the behavior for function calls,
+ update properties, or emit signals.
- \section1 Registering an instance
+ \section1 Register an Instance
- Any instance of a class derived from QObject can be registered to the QIviSimulationEngine by
- calling the registerSimulationInstance function. Similar to qmlRegisterTypes, the provided uri,
- version and name is used for importing the type from within QML.
+ You can register any instance of a class derived from QObject to the QIviSimulationEngine by
+ calling registerSimulationInstance(). Similar to qmlRegisterTypes, the URI, version, and name
+ provided are used to import the type from within QML.
\code
class MyClass : public QObject
@@ -155,10 +153,10 @@ using namespace qtivi_helper;
engine.loadSimulation("simulation.qml")
\endcode
- The registered instance has the same constraints as other C++ classes exposed to QML and needs
- to use Q_PROPERTY, Q_INVOKABLE or slots to make the functionality available to QML.
+ The registered instance has the same constraints as any other C++ classes exposed to QML and
+ needs to use Q_PROPERTY, Q_INVOKABLE, or slots to make the functionality available to QML.
- \section1 Using the type from QML
+ \section1 Use the Type from QML
Once an instance is registered to the engine, the type can be used like any other QML element
in a declarative form:
@@ -183,11 +181,12 @@ using namespace qtivi_helper;
}
\endqml
- This QML file will initialize the \c currentTemperature of \c myClass with a value of \e 10 and
- increase it every second.
+ This QML file initializes the \c currentTemperature of \c myClass with a value of \c 10 and
+ increases it every second.
- In the same way values can be updated from the C++ side and the QML side can react to the
- change. E.g. the following QML prints the \c currentTemperature whenever it changed:
+ In the same way, values can be updated from the C++ side and the QML side can react to the
+ change. For example, the following QML snippet prints the \c currentTemperature whenever it
+ changes:
\qml
import QtQuick 2.0
@@ -198,7 +197,7 @@ using namespace qtivi_helper;
}
\endqml
- The slot will be called once the myClass variable is updated:
+ The slot is called once the \c myClass variable is updated:
\code
QIviSimulationEngine engine;
@@ -209,12 +208,11 @@ using namespace qtivi_helper;
myClass.setCurrentTemperature(100);
\endcode
- \section1 Forwarding calls from the instance to the engine
+ \section1 Forward Calls from the Instance to the Engine
- Providing the behavior for invokable functions in QML can be done as well, but for this the
- exposed class needs to be extended.
-
- E.g. by adding the following line to the \c setCurrentTemperature setter:
+ You can also provide the behavior for invokable functions in QML as well, but this use case
+ requires you to extend the exposed class. For example, by adding the following line to the
+ \c setCurrentTemperature setter:
\code
void MyClass::setCurrentTemperature(int currentTemperature)
@@ -228,12 +226,12 @@ using namespace qtivi_helper;
}
\endcode
- Calling the setCurrentTemperature() function will now try to forward the call to the QML
- instance if a function matching the signature is defined in QML and when successful, use its
- returned value and skip the execution of the original C++ function.
+ Calling \c setCurrentTemperature() now tries to forward the call to the QML instance, if a
+ function matching the signature is defined in QML. When successful, \c setCurrentTemperature()
+ uses its returned value and avoids running the original C++ function.
- By using the following QML snippet the execution of the C++ setter is skipped and only an error
- is emitted on the console:
+ By using the following QML snippet, the C++ setter is skipped and only an error is emitted on
+ the console:
\qml
import QtQuick 2.0
@@ -246,14 +244,14 @@ using namespace qtivi_helper;
}
\endqml
- \section1 Reusing existing behavior in the instance
+ \section1 Reuse Existing Behavior in the Instance
- Replacing the C++ functionality with a QML behavior is not always what is desired. Because of
- this, it is also possible to call the original C++ behavior from QML. For this the original C++
- function needs to be a Q_INVOKABLE or a slot and the functionality works like function
- overriding in C++. In the C++ world the functionality of the overridden function can be
+ Replacing the C++ functionality with a QML behavior is not always desired. However, it's also
+ possible to call the original C++ behavior from QML. In this case, the original C++ function
+ needs to be a Q_INVOKABLE or a slot. Additionally, the functionality works in a similar manner
+ to function overriding in C++, where the functionality of the overridden function can be
accessed by calling \c <BaseClass>::<function>. In the exposed QML type this is possible by
- calling the function in the \e Base object.
+ calling the function in the \c Base object.
\qml
import QtQuick 2.0
@@ -267,14 +265,14 @@ using namespace qtivi_helper;
}
\endqml
- This QML code overrides the setCurrentTemperature behavior in QML and prints an debug message
- for the new value. The original C++ behavior is called by using \c
- Base.setCurrentTemperature(temperature).
+ This QML snippet overrides the setCurrentTemperature() behavior in QML and prints a debug
+ message for the new value. The original C++ behavior is called using
+ \c{Base.setCurrentTemperature(temperature)}.
- \section1 Multiple QML instances
+ \section1 Multiple QML Instances
The registered instance is exposed as a normal QML type. This makes it possible to have
- multiple declarations in QML and by that have multiple QML instances linked to the same C++
+ multiple declarations in QML, and in turn, have multiple QML instances linked to the same C++
instance. Updating and reacting to property changes and signal emissions is possible in all
instances, but should be used with care as this can result in property update loops and other
issues.
@@ -283,9 +281,9 @@ using namespace qtivi_helper;
instance as the return value is used from this call. If multiple QML instances define the same
method, the C++ call is always forwarded to the first registered QML instance.
- \section1 Runtime overriding
+ \section1 Runtime Override
- Every QIviSimulationEngine can take an extra identifier which can be used to override the
+ Each QIviSimulationEngine can take an extra identifier which can be used to override the
simulation QML file or the simulation data file at runtime. The environment variables need to
be in the following format:
@@ -317,15 +315,15 @@ QIviSimulationEngine::QIviSimulationEngine(const QString &identifier, QObject *p
/*!
Loads the simulation data file provided as \a dataFile.
- The given file needs to be in the JSON format and is parsed here for errors before it is passed
- to the IviSimulator global object where it can be accessed from QML. The file can be overridden
+ The given file must be in JSON format and is parsed here for errors before it's passed to the
+ IviSimulator global object where it can be accessed from QML. This file can be overridden
at runtime using the following environment variable:
\badcode
QTIVI_SIMULATION_DATA_OVERRIDE=<identifier>=<file>[;<identifier>=<file>]
\endcode
- The identifier of the simulation engine can be set in its constructor.
+ The simulation engine's identifier can be set in its constructor.
\sa IviSimulator
*/
@@ -359,13 +357,13 @@ void QIviSimulationEngine::loadSimulationData(const QString &dataFile)
Loads the QML \a file as the simulation behavior.
In addition to QQmlApplicationEngine::load(), this function provides functionality to change
- the used simulation file by using an environment variable in the following format.
+ the simulation file used via an environment variable in the following format:
\badcode
QTIVI_SIMULATION_OVERRIDE=<identifier>=<file>[;<identifier>=<file>]
\endcode
- The identifier of the simulation engine can be set in its constructor.
+ The simulation engine's identifier can be set in its constructor.
*/
void QIviSimulationEngine::loadSimulation(const QUrl &file)
{
@@ -383,12 +381,11 @@ void QIviSimulationEngine::loadSimulation(const QUrl &file)
/*!
\fn template <typename T> void QIviSimulationEngine::registerSimulationInstance(T* instance, const char *uri, int versionMajor, int versionMinor, const char *qmlName)
- Registers the provided \a instance in the QML system with the name \a qmlName, in the library
- imported from \a uri having the version number composed from \a versionMajor and \a
- versionMinor.
+ Registers the specified \a instance in the QML system with the name \a qmlName, in the library
+ imported from \a uri, with a version number composed from \a versionMajor and \a versionMinor.
- \note The registered instance is only available to this instance of the QIviSimulationEngine.
- Using it from another QIviSimulationEngine or a QQmlEngine will not work and produce an error.
+ \note The registered instance is only available to this QIviSimulationEngine instance.
+ Using it from another QIviSimulationEngine or a QQmlEngine won't work and produces an error.
\sa qmlRegisterType
*/
@@ -397,31 +394,31 @@ void QIviSimulationEngine::loadSimulation(const QUrl &file)
\macro QIVI_SIMULATION_TRY_CALL_FUNC(instance_type, function, ret_func, ...)
\relates QIviSimulationEngine
- Tries to call \a function in the QML instances registered for the instance of type \a
- instance_type. The variadic arguments are passed as arguments to the function in QML.
+ Tries to call \a function in the QML instances registered for the \a instance_type. The variadic
+ arguments are passed as arguments to the function in QML.
- If the call was successful the code passed in \a ret_func will be executed. This can be useful
- for situations when the return value needs to be converted first. The original return value is
+ If the call is successful, the code passed via \a ret_func is run. This can be useful for
+ situations when the return value needs to be converted first. The original return value is
available as \c return_value.
\code
QIVI_SIMULATION_TRY_CALL_FUNC(MyClass, "contactList", return return_value.toStringList());
\endcode
- \sa QIVI_SIMULATION_TRY_CALL {Forwarding calls from the instance to the engine}
+ \sa QIVI_SIMULATION_TRY_CALL {Forward Calls from the Instance to the Engine}
*/
/*!
\macro QIVI_SIMULATION_TRY_CALL(instance_type, function, ret_type, ...)
\relates QIviSimulationEngine
- Tries to call \a function in the QML instances registered for the instance of type \a
- instance_type. The variadic arguments are passed as arguments to the function in QML.
+ Tries to call \a function in the QML instances registered for the \a instance_type. The variadic
+ arguments are passed as arguments to the function in QML.
- If the call was successful the return value of type \a ret_type will be returned and all code
- after this macro will \b not be executed.
+ If the call is successful, a return value of \a ret_type is returned and all code after this
+ macro \b{won't} run.
- \sa QIVI_SIMULATION_TRY_CALL_FUNC {Forwarding calls from the instance to the engine}
+ \sa QIVI_SIMULATION_TRY_CALL_FUNC {Forward Calls from the Instance to the Engine}
*/
QT_END_NAMESPACE