The parent of classes managing resources. More...

Inheritance diagram for ResourcesUser:

Public Types

typedef
Resource::ResourceChangeType 
ResourceChangeType
 The change that happened to a resource.
 
- Public Types inherited from Resource
enum  ResourceChangeType { Created, Modified, Deleted }
 The change that happened to a resource. More...
 

Public Member Functions

virtual void shareResourcesWith (ResourcesUser *other)
 The function to share resources.
 
- Public Member Functions inherited from Resource
virtual ~Resource ()
 Destructor.
 

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.
 
ResourcesUseroperator= (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:

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.

Member Typedef Documentation

The change that happened to a resource.

This is only a typedef, the enumeration is in the Resource class

Definition at line 78 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
otherthe object to copy

Definition at line 65 of file resourcesuser.cpp.

~ResourcesUser ( )
protectedvirtual

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 
)
protectedpure virtual

The function called by ResourceHandler when a resource is changed.

Implemented in subclasses

Parameters
resourcethe handler of the resource that has changed.
chageTypethe 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
otherthe object to copy

Definition at line 70 of file resourcesuser.cpp.

References ResourcesUser::m_resources.

Referenced by SimpleResourcesUser::operator=().

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
otherthe 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 ConcurrentResourcesUser, and SimpleResourcesUser.

Definition at line 49 of file resourcesuser.cpp.

References ResourcesUser::m_resources.

Referenced by SimpleResourcesUser::shareResourcesWith(), and ConcurrentResourcesUser::shareResourcesWith().

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 155 of file resourcesuser.h.

friend class ResourceHandler
friend

The ResourceHandler class is friend to access the notifyResourceChange() function.

Definition at line 149 of file resourcesuser.h.

Member Data Documentation


The documentation for this class was generated from the following files: