OverviewQtilities provides an object manager which provides many object management features. The object manager is also responsible to provide a global object pool to the developer. This allows the registration of objects in the global object pool where other objects can access them or the interfaces they implement. This article will provide information on the different features of the object manager and the global object pool. Table of contents: |
|
The object manager implements the Qtilities::Core::Interfaces::IObjectManager interface and can be accessed directly through the thread safe OBJECT_MANAGER
macro or directly using Qtilities::Core::QtilitiesCoreApplication::objectManager()
For example:
A global object pool is a powerful object management feature in an application, especially when the application is extensible through plugins. It allows objects to be registered in the pool and can then be searched and used in other parts of the application. The example below shows some example usages of the global object pool.
A good example of using the global object pool is the methodology behind how plugins are used in the Qtilities extension system. Plugins register objects in which the rest of the application might be interested during plugin initialization. Once all plugins were initialized, plugins initializes their dependencies where it will inspect the global object pool for registered objects in which it is interested in.
The Qtilities::Plugins::Debug plugin provides a visual overview of the global object pool state during runtime which simplifies debugging. This is shown in the image below:
When attaching objects to observers, it is possible to specify the way the object should be managed in the observer context. The possible management options are defined in the Qtilities::Core::Observer::ObjectOwnership enumeration. See the Object lifetimes: Managing object lifetimes using observers section of the Observers article for more information.
The object manager provides functionality to manage global active objects in an application. Active objects can be set on a meta-type basis where the meta type is a simple QString used to identify the set of active objects. Active objects for a meta-type can be set using the Qtilities::Core::Interfaces::IObjectManager::setMetaTypeActiveObjects() function. When this function is called the Qtilities::Core::Interfaces::IObjectManager::metaTypeActiveObjectsChanged() signal is emitted with the new set of active objects for the specified meta-type. The active objects for a meta-type can be accessed at any time using the Qtilities::Core::Interfaces::IObjectManager::metaTypeActiveObjects() function.
Qtilities provided various features related to QObject property management. The sections that follow will provide highlights of these features.
To make working with object properties easier, Qtilities comes with its own property classes which all inherit from Qtilities::Core::QtilitiesProperty. This approach provides many advantages allowing you to control many aspects of the property. For example:
The object manager provides many functions which helps you to work with properties on QObjects. QtilitiesProperty based classes are meant to compliment normal QVariant properties which can be set on QObjects and all the property functions provided by the object manager supports normal QVariant properties as well as property classes inheriting from QtilitiesProperty.
Property related functionality on object manager includes:
See the static functions on Qtilities::Core::ObjectManager for more information.
When Qtilities is built using the QTILITIES_PROPERTY_BROWSER
define enabled, the following widgets allows you to inspect properties on objects at runtime.
The Qtilities::CoreGui::ObjectPropertyBrowser allows you to inspect Q_PROPERTY
properties on objects at runtime. The widget embedded in the debug plugin is shown below for an example object.
The Qtilities::CoreGui::DynamicObjectPropertyBrowser allows you to inspect dynamic properties on QObjects at runtime. This widget allows you to display the following type of properties:
The widget embedded in the debug plugin is shown below for an example object.
Qtilities : Reference Documentation | Back to top |
Copyright © 2009-2013, Jaco Naudé
|