The ObjectManager provides object management features to the developer. More...
#include <ObjectManager.h>
Public Member Functions | |
QStringList | allFactoryNames () const |
Provides a list with the names of all the factories registered in the object manager. | |
QtilitiesCategory | categoryForTag (const QString &factory_name, const QString &factory_tag, bool *ok=0) const |
Provides the category of the specified tag. | |
QObject * | createInstance (const InstanceFactoryInfo &ifactory_data) |
Constructs an instance in a specified factory and return it. | |
QList< QPointer< QObject > > | metaTypeActiveObjects (const QString &meta_type) const |
Returns the active object(s) for a specific meta type. If the meta type does not exist, an empty list is returned. | |
bool | moveSubjects (QList< QObject * > objects, int source_observer_id, int destination_observer_id, QString *error_msg, bool silent=false) |
A function which moves a list of objects from one observer to another observer. | |
bool | moveSubjects (QList< QPointer< QObject > > objects, int source_observer_id, int destination_observer_id, QString *error_msg, bool silent=false) |
Move subjects by providing the objects as a list with smart pointers. | |
QObject * | objectBase () |
Returns the QObject* base of the interface. | |
const QObject * | objectBase () const |
Returns a const QObject* base of the interface. | |
Observer * | objectPool () |
Function which returns a reference to the global object pool. | |
Observer * | observerReference (int id) const |
Gets the reference to an observer. | |
QStringList | providedFactories () const |
Provides the names of all the factories exposed through this interface. | |
QStringList | providedFactoryTags (const QString &factory_name, const QtilitiesCategory &category_filter=QtilitiesCategory(), bool *ok=0) const |
Provides the tags in a specific factory. | |
IFactoryProvider * | referenceIFactoryProvider (const QString &factory_name) const |
Provides a reference to the factory interface for a specific factory. | |
QList< QObject * > | registeredInterfaces (const QString &iface) const |
Returns all objects in the global object pool which implements the specified interface. | |
void | registerFactoryInterface (FactoryInterface< QObject > *factory_interface, FactoryItemID iface_tag) |
Registers a factory interface inside the Qtilities factory. | |
bool | registerIFactoryProvider (IFactoryProvider *factory_iface) |
Registers a factory interface in the object manager. | |
void | registerObject (QObject *obj, QtilitiesCategory category=QtilitiesCategory()) |
Registers an object to be included in the global object pool. | |
int | registerObserver (Observer *observer) |
Registers an observer in the observer manager. | |
void | removeObject (QObject *obj) |
Removes an object to from the global object pool. | |
void | setMetaTypeActiveObjects (QList< QObject * > objects, const QString &meta_type) |
Updates the active object(s) for a specific meta type. | |
void | setMetaTypeActiveObjects (QList< QPointer< QObject > > objects, const QString &meta_type) |
Update the active object(s) for a specific meta type by providing a list of smart pointers to the objects. | |
QMap< QString, QtilitiesCategory > | tagCategoryMap (const QString &factory_name, bool *ok=0) const |
Provides the full tag and category map for the given factory. | |
QStringList | tagsForFactory (const QString &factory_name) const |
Provides a list of all the tags registered in a specific factory. |
Static Public Member Functions | |
static bool | cloneObjectProperties (const QObject *source_obj, QObject *target_obj, PropertyTypeFlags property_types=AllPropertyTypes) |
Streams exportable dynamic properties from the given QDomDocument and QDomElement and then add them to the QObject. | |
static bool | compareDynamicProperties (const QObject *obj1, const QObject *obj2, PropertyTypeFlags property_types=AllPropertyTypes, PropertyDiffInfo *property_diff_info=0, QStringList ignore_list=QStringList()) |
Convenience function to compare all properties that match the PropertyTypeFlags on two objects. | |
static bool | constructDefaultPropertiesOnObject (QObject *obj, QString *errorMsg=0) |
Convenience function to allow construction of all properties specified by IAvailablePropertyProvider interfaces in the global object pool on the given object. | |
static SharedProperty * | constructPropertyFromSpecification (PropertySpecification specification) |
Convenience function to construct a property from a given PropertySpecification. | |
static QList< QPointer< QObject > > | convNormalObjectsToSafe (QList< QObject * > normal_list) |
Converts a QList<QObject*> object list to a QList<QPointer<QObject> > list. | |
static QList< QObject * > | convSafeObjectsToNormal (QList< QPointer< QObject > > safe_list) |
Converts a QList<QPointer<QObject> > object list to a QList<QObject*> list. | |
static IExportable::ExportResultFlags | exportObjectPropertiesBinary (const QObject *obj, QDataStream &stream, PropertyTypeFlags property_types=AllPropertyTypes, Qtilities::ExportVersion version=Qtilities::Qtilities_Latest) |
Streams exportable dynamic properties about the object to the given QDataStream. | |
static IExportable::ExportResultFlags | exportObjectPropertiesXml (const QObject *obj, QDomDocument *doc, QDomElement *object_node, PropertyTypeFlags property_types=AllPropertyTypes, Qtilities::ExportVersion version=Qtilities::Qtilities_Latest) |
Exports all exportable dynamic properties about the object to the given QDomDocument and QDomElement. | |
static MultiContextProperty | getMultiContextProperty (const QObject *obj, const char *property_name) |
Convenience function which will get the specified MultiContextProperty of the specified object. | |
static SharedProperty | getSharedProperty (const QObject *obj, const char *property_name) |
Convenience function which will get the specified SharedProperty of the specified object. | |
static IExportable::ExportResultFlags | importObjectPropertiesBinary (QObject *obj, QDataStream &stream) |
Streams exportable dynamic properties from the given data stream and add them to the QObject. | |
static IExportable::ExportResultFlags | importObjectPropertiesXml (QObject *obj, QDomDocument *doc, QDomElement *object_node) |
Streams exportable dynamic properties from the given QDomDocument and QDomElement and then add them to the QObject. | |
static bool | propertyExists (const QObject *obj, const char *property_name) |
Convenience function to check if a dynamic property exists on a object. | |
static bool | removeDynamicProperties (QObject *obj, PropertyTypeFlags property_types=AllPropertyTypes) |
Convenience function to remove all properties that match the PropertyTypeFlags from an object. | |
static bool | setMultiContextProperty (QObject *obj, MultiContextProperty multi_context_property) |
Convenience function which will set the specified MultiContextProperty on the specified object. | |
static bool | setSharedProperty (QObject *obj, SharedProperty shared_property) |
Convenience function which will set the specified SharedProperty on the specified object. | |
static bool | setSharedProperty (QObject *obj, const char *property_name, QVariant property_value) |
Convenience function which will create and set a SharedProperty with the given name and value on the object. | |
static bool | setSharedProperty (QObject *obj, PropertySpecification property_specification) |
Convenience function which will create and set a SharedProperty from the given PropertySpecification. |
Additional Inherited Members | |
Public Types inherited from Qtilities::Core::Interfaces::IObjectManager | |
enum | PropertyTypes { NoProperties = 0, MultiContextProperties = 1, SharedProperties = 2, QtilitiesInternalProperties = 4, NonQtilitiesProperties = 8 } |
Possible property types. More... | |
Signals inherited from Qtilities::Core::Interfaces::IObjectManager | |
void | metaTypeActiveObjectsChanged (QList< QPointer< QObject > > objects, const QString &meta_type) |
Signal which is emitted when the setMetaTypeActiveObjects() is finished. | |
void | newObjectAdded (QObject *obj) |
Signal which is emitted when a new object is added to the global object pool. | |
void | objectRemoved (QObject *obj) |
Signal which is emitted when an object is removed from the global object pool. |
The ObjectManager provides object management features to the developer.
For more information about object management in Qtilities, see the Object Management article.
|
virtual |
Provides the category of the specified tag.
factory_name | The factory in which the tag is located. |
factory_tag | The tag for which the category must is requested. |
ok | Set to true if the parameters matches a factory in this provider, false otherwise. |
This function was added in Qtilities v1.2.
Implements Qtilities::Core::Interfaces::IFactoryProvider.
|
static |
Streams exportable dynamic properties from the given QDomDocument and QDomElement and then add them to the QObject.
|
static |
Convenience function to compare all properties that match the PropertyTypeFlags on two objects.
This function checks each property using the == overload of the QVariant property type and returns true if they match exactly, false otherwise.
obj1 | The first object to use in the comparison. The results will be relative to this object, for example if a property exists on obj1 and not on obj2 , the diff result will show that the property was added. Also, when a property exists on both objects and the value changed, the old value will be the value on obj2 and the new value the value on obj1 . |
obj2 | The second object to use in the comparison. |
property_types | The property types which must be compared. |
property_diff_info | Information about property changes on obj1 compared to obj2. By default the differences will not be calculated, it will only be done when the property_diff_info parameter is passed a valid reference. |
ignore_list | A list of property names which should be ignored in the comparison. |
|
static |
Convenience function to allow construction of all properties specified by IAvailablePropertyProvider interfaces in the global object pool on the given object.
*This function can be used to do automatic dynamic property construction on objects. This is usefull in *extendible applications where you use dynamic properties in order to extend objects at runtime. For example, *if you have an application and plugins can add dynamic properties on specific type of objects, you can do it by *having some sort of mechanism where the plugin is notified of new objects that it is interested in. One way to do it *is to register the new objects in the global object pool and listen to the new object added signal on the object pool. *When the plugin gets this notification it adds the needed dynamic properties on the object.
*This function provides a more efficient way to do this. When called, the function looks for all implementations of *IAvailablePropertyProvider registered in the global object pool and gets all PropertySpecification specifications for *for which the given object inherits the d_class_name
specification of the property specification.
*It will check all these properties and if their d_add_during_construction
parameter is set *it will add these properties with the parameters specified by the matching PropertySpecification.
*The intended use of this function is to call it in the constructor of your object.
obj | The object on which the properties must be constructed.ad. |
errorMsg | When the function returns false due to any issues, the reason for the failure can be found through this parameter. |
*This function was added in Qtilities v1.2.
|
static |
Convenience function to construct a property from a given PropertySpecification.
Constructs a SharedProperty from the given PropertySpecification.
specification | The property specification |
*This function was added in Qtilities v1.2.
|
static |
Converts a QList<QObject*> object list to a QList<QPointer<QObject> > list.
This function was added in Qtilities v1.1.
|
static |
Converts a QList<QPointer<QObject> > object list to a QList<QObject*> list.
This function was added in Qtilities v1.1.
|
static |
Streams exportable dynamic properties about the object to the given QDataStream.
To use this function make sure that all the QVariant properties have the streaming << / >> operators overloaded. This is the case for all properties used in Qtilities.
|
static |
Exports all exportable dynamic properties about the object to the given QDomDocument and QDomElement.
To use this function make sure that all the QVariants are exportable. See QtilitiesProperty::isExportableVariant() for more information.
|
static |
Convenience function which will get the specified MultiContextProperty of the specified object.
|
static |
Convenience function which will get the specified SharedProperty of the specified object.
|
static |
Streams exportable dynamic properties from the given data stream and add them to the QObject.
|
static |
Streams exportable dynamic properties from the given QDomDocument and QDomElement and then add them to the QObject.
|
virtual |
Returns the active object(s) for a specific meta type. If the meta type does not exist, an empty list is returned.
For more information about see the Global object activity management section of the Object Management article.
Implements Qtilities::Core::Interfaces::IObjectManager.
|
virtual |
A function which moves a list of objects from one observer to another observer.
This function will attempt to move subjects from one observer context to another. If any of the subjects cannot be attached, it will be skipped and attempt to move the next subject in the list. If any of the subjects could not be attached, the function will return false. If all subjects was moved successfully the function will return true.
objects | The objects which must be moved. |
source_observer_id | The source observer ID. |
destination_observer_id | The destination observer ID. |
error_msg | When valid it will be populated with any error messages produced during the move operation. |
silent | When true the subjects must be moved without showing any dialogs. |
Implements Qtilities::Core::Interfaces::IObjectManager.
|
virtual |
Move subjects by providing the objects as a list with smart pointers.
This function will attempt to move subjects from one observer context to another. If any of the subjects cannot be attached, it will be skipped and attempt to move the next subject in the list. If any of the subjects could not be attached, the function will return false. If all subjects was moved successfully the function will return true.
objects | The objects which must be moved. |
source_observer_id | The source observer ID. |
destination_observer_id | The destination observer ID. |
error_msg | When valid it will be populated with any error messages produced during the move operation. |
silent | When true the subjects must be moved without showing any dialogs. |
Implements Qtilities::Core::Interfaces::IObjectManager.
|
inlinevirtual |
Returns a const QObject* base of the interface.
This function can be used in const methods, but make sure that you don't modify things that should stay const. An example where this is used is when we want to get a property on an object in a const method. This is a const operation.
Implements Qtilities::Core::Interfaces::IObjectBase.
|
virtual |
Function which returns a reference to the global object pool.
Care should be taken when using the object pool observer. You should for example not delete all the subjects in the pool unless you know what you are doing.
It is recommended to use registerObject() and registeredInterfaces() instead of the object pool directly, unless you require the use of additional functions on the object pool, like displaying it using an ObserverWidget.
Implements Qtilities::Core::Interfaces::IObjectManager.
|
virtual |
Gets the reference to an observer.
id | The observer id of the observer for which the reference must be fetched. |
Implements Qtilities::Core::Interfaces::IObjectManager.
|
virtual |
Provides the tags in a specific factory.
factory_name | The factory in which the tag is located. |
category_filter | Allows you to get tag for a specific category. When empty, all categories are returned. |
ok | Set to true if the parameters matches a factory in this provider, false otherwise. |
Implements Qtilities::Core::Interfaces::IFactoryProvider.
|
virtual |
Provides a reference to the factory interface for a specific factory.
This function returns the IFactoryProvider interface which contains the specified factory.
Implements Qtilities::Core::Interfaces::IObjectManager.
|
virtual |
Returns all objects in the global object pool which implements the specified interface.
For example:
Implements Qtilities::Core::Interfaces::IObjectManager.
|
virtual |
Registers a factory interface in the object manager.
The object manager keeps track of all IFactoryProvider interfaces registered using this function. It is then possible to access the IFactoryProvider interface for a specific factory using the referenceIFactoryProvider() function.
The way that the object manager keeps track of factories and their respective IFactoryProvider interfaces is done in such a way that factory names exposed by IFactoryProvider must be unique for all IFactoryProvider interfaces registered using this function.
If a duplicate factory name is found, an error is printed and this function returns false.
Implements Qtilities::Core::Interfaces::IObjectManager.
|
virtual |
Registers an object to be included in the global object pool.
category | The category under which the object must be registered. This parameter can be left out in most cases, however it is usefull when visualizing the global object pool using the Qtilities::Plugins::Debug plugin for example. |
Implements Qtilities::Core::Interfaces::IObjectManager.
|
virtual |
Removes an object to from the global object pool.
This function will detach the object from the global object pool observer. It will not however delete the object, it will just detach it.
Implements Qtilities::Core::Interfaces::IObjectManager.
|
virtual |
Updates the active object(s) for a specific meta type.
For more information about see the Global object activity management section of the Object Management article.
Implements Qtilities::Core::Interfaces::IObjectManager.
|
static |
Convenience function which will set the specified MultiContextProperty on the specified object.
Caution should be taken when using this function because you can easily overwrite property values for other contexts since the property has different values for different contexts.
Therefore you must always check if an observer property exist before setting as shown in the example below:
|
static |
Convenience function which will set the specified SharedProperty on the specified object.
|
static |
Convenience function which will create and set a SharedProperty with the given name and value on the object.
|
static |
Convenience function which will create and set a SharedProperty from the given PropertySpecification.
This function was added in Qtilities v1.2.
|
virtual |
Provides the full tag and category map for the given factory.
factory_name | The factory for which the map is requested. |
ok | Set to true if the parameters matches a factory in this provider, false otherwise. |
This function was added in Qtilities v1.2.
Implements Qtilities::Core::Interfaces::IFactoryProvider.
Qtilities : Reference Documentation | Back to top |
Copyright © 2009-2013, Jaco Naudé
|