ResourceHandler Class Reference

The class for representing a resource. More...

Public Member Functions

 ResourceHandler (QString name)
 Constructor.
 
 ~ResourceHandler ()
 Destructor.
 
void addNotifee (ResourcesUser *n)
 Adds a new observer.
 
bool exists () const
 Returns true if this holds an existing resource.
 
template<class T >
T * get () const
 The function to obtain the resource.
 
QMutex & getLock ()
 Returns the mutex for this resource.
 
bool isNotifee (ResourcesUser *n) const
 Returns true if n is an observer for this resource.
 
QString name () const
 Returns the name of the resource.
 
void removeNotifee (ResourcesUser *n)
 Removes an observer.
 
void set (int *res)
 The set method for an int resource.
 
void set (float *res)
 The set method for a float resource.
 
void set (double *res)
 The set method for a double resource.
 
void set (bool *res)
 The set method for a bool resource.
 
void set (Resource *res)
 The set method for a Resource resource.
 
void set (ParameterSettable *res)
 The set method for a ParameterSettable resource.
 
void set (QObject *res)
 The set method for a QObject resource.
 
void shareLockWith (ResourceHandler *other)
 Shares the lock with the other resource.
 
void unset ()
 Marks this resource as non-existing.
 

Detailed Description

The class for representing a resource.

This class represents a resource. It also contains the mutex for the resource (that can be shared among resources) and the list of objects that have to be notified when the resource changes. See the ResourcesUser class and its sublcasses for more information on resources

Definition at line 189 of file resource.h.

Constructor & Destructor Documentation

ResourceHandler ( QString  name)

Constructor.

This creates a non-existing resource

Parameters
namethe name of the resource. This cannot be changed once set here in the constructor

Definition at line 68 of file resource.cpp.

Destructor.

Definition at line 76 of file resource.cpp.

Member Function Documentation

void addNotifee ( ResourcesUser n)

Adds a new observer.

Parameters
nthe object that will be notified when this resource changes

Definition at line 148 of file resource.cpp.

Referenced by ConcurrentResourcesUser::addUsableResource(), ConcurrentResourcesUser::addUsableResources(), ConcurrentResourcesUser::shareResourcesWith(), and ConcurrentResourcesUser::usableResources().

bool * get< bool > ( ) const
inline

The function to obtain the resource.

Specialization for primitive types are implemented after the class because we cannot explitly specialize a function in a non-namespace

Returns
the resource or NULL if the type is not compatible

Definition at line 298 of file resource.h.

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

QMutex& getLock ( )
inline

Returns the mutex for this resource.

Returns
a reference to the mutex for this resource

Definition at line 317 of file resource.h.

bool isNotifee ( ResourcesUser n) const

Returns true if n is an observer for this resource.

Parameters
nthe object that will be searched in the set of observers
Returns
true if n is an observer for this resource

Definition at line 158 of file resource.cpp.

QString name ( ) const
inline

Returns the name of the resource.

Returns
the name of the resource

Definition at line 211 of file resource.h.

Referenced by ConcurrentResourcesUser::usedResourcesExist().

void removeNotifee ( ResourcesUser n)

Removes an observer.

Parameters
nthe object that will be no longer notified when this resource changes

Definition at line 153 of file resource.cpp.

Referenced by ConcurrentResourcesUser::removeAllUsableResources(), ConcurrentResourcesUser::removeUsableResource(), and ConcurrentResourcesUser::removeUsableResources().

void set ( int *  res)

The set method for an int resource.

This also notifes all observers of this resource

Parameters
resthe int resource to set

Definition at line 85 of file resource.cpp.

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

void set ( float *  res)

The set method for a float resource.

This also notifes all observers of this resource

Parameters
resthe float resource to set

Definition at line 93 of file resource.cpp.

void set ( double *  res)

The set method for a double resource.

This also notifes all observers of this resource

Parameters
resthe double resource to set

Definition at line 101 of file resource.cpp.

void set ( bool *  res)

The set method for a bool resource.

This also notifes all observers of this resource

Parameters
resthe bool resource to set

Definition at line 109 of file resource.cpp.

void set ( Resource res)

The set method for a Resource resource.

This also notifes all observers of this resource

Parameters
resthe Resource resource to set

Definition at line 117 of file resource.cpp.

void set ( ParameterSettable res)

The set method for a ParameterSettable resource.

This also notifes all observers of this resource

Parameters
resthe ParameterSettable resource to set

Definition at line 125 of file resource.cpp.

void set ( QObject *  res)

The set method for a QObject resource.

This also notifes all observers of this resource

Parameters
resthe QObject resource to set

Definition at line 133 of file resource.cpp.

void shareLockWith ( ResourceHandler other)

Shares the lock with the other resource.

After a call to this function, this and "other" will share the same mutex object. This is transitive, so if "other" already shared the mutex with some other resources, this will share the mutex with those other resources as well

Parameters
otherthe object sharing its lock

Definition at line 80 of file resource.cpp.

Referenced by ConcurrentResourcesUser::declareResource().

void unset ( )

Marks this resource as non-existing.

This also notifes all observers of this resource

Definition at line 141 of file resource.cpp.

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


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