Sensor backends are generally registered statically. The registration happens when the sensors library is first used and the registration remains in effect while the program runs.
Statically registered backends may still exhibit some dynamic behaviour as the QSensorBackendFactory is free to return 0 to indicate that a backend cannot be created.
While static registration is fine for most backends there are some situations where this is problematic.
The clearest example is backends that represent non-fixed hardware. As an example, lets consider a game controller that is connected via Bluetooth. As there may be more than one game controller in range of the phone, the program wants to record that a specific game controller should be used. If the backend had been registered statically there would have been no unique information about the controller. Instead, the registration is delayed until the controller is seen.
A backend for fixed hardware should be registered immediately. Applications can see that the sensor can be used.
A backend for remote hardware should not be registered immediately. Applications can see that the sensor cannot be used. When the remote hardware becomes available the backend should be registered. Applications can see that the sensor is now available.
If it is necessary to return 0 from a factory for a backend that was registered, the backend should be unregistered. Applications can see that the sensor is no longer available. If the factory can create the backend again it should be registered. Applications can see that the sensor is available again.
When the underlying hardware is no longer available, the backend should be deregistered. Existing instances of the backend should report error states to the application but should handle the situation gracefully.
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.