Publish and Subscribe |
Layer | Description |
---|---|
Shared Memory Layer | The Shared Memory layer provides a non-permanent Value Space backing store using shared memory and local sockets. The Shared Memory layer is only available on Unix platforms. The Shared Memory layer has an order of 0x10000000. |
Volatile Registry Layer | The Volatile Registry layer provides a non-permanent Value Space backing store using volatile keys stored in the Windows' registry. The Volatile Registry layer is only available on Windows platforms. The Volatile Registry layer has an order of 0x1000. |
Non-volatile Registry Layer | The Non-volatile Registry layer provides a permanent Value Space backing store using keys stored in the Windows' registry. The Non-volatile Registry layer is only available on Windows platforms. The Non-volatile Registry layer has an order of 0. |
ContextKit Layer | The ContextKit layer provides a non-permanent Value Space backing store using ContextKit. Publishing values to this layer via QValueSpacePublisher is currently not supported. The ContextKit layer has an order of 0. |
Symbian Settings Layer | The Symbian Settings layer provides a permanent Value Space backing store using the Symbian OS' Properties (RProperty) as well as Central Repository files (CRepository). The Symbian Settings layer has an order of 0. |
The Value Space has support for both client/server and peer-to-peer layer architectures. If a layer that uses a client/server architecture is used and a server process is not provided by the underlying system it will be necessary to start one. This can be done by calling QValueSpace::initValueSpaceServer() prior to any other use of the Value Space.
The Shared Memory layer stores all values in a 10MB block of shared memory which is reserved when the Value Space server initializes. As the layer creates this region at startup, it is assumed that the operating system lazily commits memory. If this assumption is invalid, the Shared Memory layer will unnecessarily consume 10MB of memory.
Value Space clients read from the Shared Memory layer's shared memory region directly. A kernel lock is acquired for each read to prevent corruption. While the layer supports concurrent readers, it is possible that a faulty or malicious application could acquire and refuse to release this lock causing any layer updates to be delayed indefinitely.
Only the Value Space server ever writes to the shared memory region. When clients attempt to add items to the layer, their changes are transmitted via a QLocalSocket (e.g. /tmp/qt/valuespace_shmlayer domain socket on Unix systems) to the server where the update is performed. Updates are batched in-process and sent when the process re-enters the Qt event loop. Transmission and synchronization of changes can be forced manually by the QValueSpacePublisher::sync() function, although as this requires a round trip between the client and server, doing so frequently may significantly degrade performance.
Change notifications are transmitted to clients in the form of "something has changed" messages. Nodes within the shared memory region are versioned, which allows clients to quickly determine exactly what has changed without the need for a bulkier change notification protocol.
Publish and Subscribe API can be used to access Symbian OS' Properties (RProperty) as well as Central Repository files (CRepository). The underlying system limits the features and available data types but at least reading, writing and monitoring Symbian aware data types work in both RProperty and CRepository.
Since Publish and Subscribe API is based on Value Space that is accessed via textual path we need to somehow specify how particular paths are turned into RPropery or CRepository key definitions. Here the QCRML files come for help.
QCRML files are XML files that can be used to declare available Value Space paths that are visible to the clients. Each path defines whether the actual value is stored in CRepository or RPropery as well as needed Category/Repository/Key UIDs.
The following QCRML file defines Value Space paths for power state properties stored in Symbian OS Properties:
<?xml version="1.0" encoding="UTF-8"?> <repository target="RProperty" version="" uidName="KPSUidHWRMPowerState" uidValue="0x10205041"> <key ref="/resources/battery/level" int="0x00000001"/> <key ref="/resources/battery/status" int="0x00000002"/> <key ref="/resources/charging/status" int="0x00000003"/> </repository>
The following QCRML file defines a Value Space path for the "current profile id" stored in Central Repository:
<?xml version="1.0" encoding="UTF-8"?> <repository target="CRepository" version="" uidName="KCRUidProfileEngine" uidValue="0x101f8798"> <key ref="/profile/id" int="0x7e000001"/> </repository>
The qcrmlgen tool located in the tools directory can be used to create QCRML files.
All the QCRML files need to be located in c:\resource\qt\crml directory in Symbian file system.
In .pro files this means that the files need to be deployed with the SIS package.
Example .pro file section:
symbian { crml.sources = resources.qcrml profile.qcrml crml.path = c:/resource/qt/crml DEPLOYMENT += crml }
Symbian OS Properties are limited to data of type int and QByteArray. QString is also possible to be passed via Value Space but it is recognized as QByteArray in the receiving end. Use QVariant::toString() to explicitly convert it back into a QString in cases where you know that the data was originally a QString. The maximum size for QByteArray is 65535 bytes.
In addition to the types supported by Symbian OS Properties, Central Repository also supports qreal.
In the example Publish and Subscribe the Value Space is used as a method of communicating changes in one dialog (the publisher) to another dialog (the subscriber).
In the example Accessing Publish and Subscribe from QML the Publish and Subscribe concept is now extended to make the publisher an input of the level of charge in a battery. A slider on the publisher dialog represents the modifiable level of charge. The Value Space acts as a communications medium between the publisher dialog and the subscriber graphical battery animation. The battery is implemented in QML and C++ with Value Space supplying the charge level for the animation to represent.
QAbstractValueSpaceLayer | Support for adding new logical data layers to the Qt Value Space |
---|---|
QValueSpace | Contains miscellaneous identifiers used throughtout the Publish and Subscribe API |
QValueSpacePublisher | Allows applications to publish values in the Value Space |
QValueSpaceSubscriber | Allows applications to read and subscribe to Value Space paths |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt qtmobility-1.0-tp | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com