ResourcesUser Class Reference
The parent of classes managing resources. More...

Public Member Functions | |
virtual void | shareResourcesWith (ResourcesUser *other) |
The function to share resources. | |
Protected Member Functions | |
ResourcesUser () | |
Constructor. | |
ResourcesUser (const ResourcesUser &other) throw () | |
Copy constructor. | |
virtual | ~ResourcesUser () |
Constructor. | |
virtual void | notifyResourceChange (ResourceHandler *resource, ResourceChangeType changeType)=0 |
The function called by ResourceHandler when a resource is changed. | |
ResourcesUser & | operator= (const ResourcesUser &other) throw () |
Copy operator. | |
Protected Attributes | |
ResourceCollectionHolder | m_resources |
The object holding the shared resources. | |
Friends | |
class | ConcurrentResourcesUser |
The ConcurrentResourcesUser class is friend to access the m_resources member of instances of type ResourcesUser. | |
class | ResourceHandler |
The ResourceHandler class is friend to access the notifyResourceChange() function. |
Detailed Description
The parent of classes managing resources.
A resource is a pointer to a variable of a primitive type or to an object that is associated to a resource name. The resource name is a string that can be used to access the resource. If you want an instance of a class to be used as a resource, the class must be a subclass (direct or indirect) of one of the following classes:
- Resource
- ParameterSettable
- QObject
This is the parent of classes that can be used to manage resources. There are no methods here to access or declare resources. The only purpouse of this class is to make it possible to share resources among different classes and to provide a unified callback for notifications of changes in a resource. Moreover the constructors and destructor are protected, so you cannot instantiate this class directly. You should use either SimpleResourcesUser or ConcurrentResourcesUser classes. See their description for information on how to get/declare resources and for the differences among them.
- Note:
- ResourcesUser is a child of Resource, so an instance of this class can be a resource itself.
Definition at line 70 of file resourcesuser.h.
Constructor & Destructor Documentation
ResourcesUser | ( | ) | [protected] |
Constructor.
This is protected to prevent instantiations of this class
Definition at line 60 of file resourcesuser.cpp.
ResourcesUser | ( | const ResourcesUser & | other | ) | throw () [protected] |
Copy constructor.
This object and the one from which it is copied will share the same resources (no need to call shareResourcesWith()). This is protected to prevent instantiations of this class
- Parameters:
-
other the object to copy
Definition at line 65 of file resourcesuser.cpp.
~ResourcesUser | ( | ) | [protected, virtual] |
Constructor.
This is protected to prevent instantiations of this class
Definition at line 81 of file resourcesuser.cpp.
Member Function Documentation
virtual void notifyResourceChange | ( | ResourceHandler * | resource, |
ResourceChangeType | changeType | ||
) | [protected, pure virtual] |
The function called by ResourceHandler when a resource is changed.
Implemented in subclasses
- Parameters:
-
resource the handler of the resource that has changed. chageType the type of change the resource has gone through (whether it was created, modified or deleted)
ResourcesUser & operator= | ( | const ResourcesUser & | other | ) | throw () [protected] |
Copy operator.
This object and the one from which it is copied will share the same resources (no need to call shareResourcesWith()). This is protected to let child classes decide whether to allow copying or not
- Parameters:
-
other the object to copy
Definition at line 70 of file resourcesuser.cpp.
References ResourcesUser::m_resources.
void shareResourcesWith | ( | ResourcesUser * | other | ) | [virtual] |
The function to share resources.
The calling instance will lose the possibility to access the resources it had before this call
- Parameters:
-
other the instance with which resources will be shared. If NULL we lose the association with other objects and start with an empty resource set
- Note:
- This is NOT thread safe (both this and the other instance should not be being accessed by other threads)
Reimplemented in SimpleResourcesUser, and ConcurrentResourcesUser.
Definition at line 49 of file resourcesuser.cpp.
References ResourcesUser::m_resources.
Friends And Related Function Documentation
friend class ConcurrentResourcesUser [friend] |
The ConcurrentResourcesUser class is friend to access the m_resources member of instances of type ResourcesUser.
Definition at line 147 of file resourcesuser.h.
friend class ResourceHandler [friend] |
The ResourceHandler class is friend to access the notifyResourceChange() function.
Definition at line 141 of file resourcesuser.h.
Member Data Documentation
ResourceCollectionHolder m_resources [protected] |
The object holding the shared resources.
Definition at line 135 of file resourcesuser.h.
Referenced by ConcurrentResourcesUser::addUsableResource(), ConcurrentResourcesUser::addUsableResources(), ConcurrentResourcesUser::ConcurrentResourcesUser(), ConcurrentResourcesUser::deleteResource(), SimpleResourcesUser::deleteResource(), ConcurrentResourcesUser::hasResource(), ResourcesUser::operator=(), ConcurrentResourcesUser::removeAllUsableResources(), ConcurrentResourcesUser::removeUsableResource(), ConcurrentResourcesUser::removeUsableResources(), ConcurrentResourcesUser::shareResourcesWith(), ResourcesUser::shareResourcesWith(), ConcurrentResourcesUser::usableResources(), and ConcurrentResourcesUser::usedResourcesExist().
The documentation for this class was generated from the following files:
- configuration/include/resourcesuser.h
- configuration/src/resourcesuser.cpp