The class for representing a resource. More...
Public Member Functions | |
ResourceHandler (QString name) | |
Constructor. More... | |
~ResourceHandler () | |
Destructor. More... | |
void | addNotifee (ResourcesUser *n) |
Adds a new observer. More... | |
bool | exists () const |
Returns true if this holds an existing resource. More... | |
template<class T > | |
T * | get () const |
The function to obtain the resource. More... | |
template<> | |
int * | get () const |
template<> | |
float * | get () const |
template<> | |
double * | get () const |
template<> | |
bool * | get () const |
QMutex & | getLock () |
Returns the mutex for this resource. More... | |
bool | isNotifee (ResourcesUser *n) const |
Returns true if n is an observer for this resource. More... | |
QString | name () const |
Returns the name of the resource. More... | |
void | removeNotifee (ResourcesUser *n) |
Removes an observer. More... | |
void | set (int *res) |
The set method for an int resource. More... | |
void | set (float *res) |
The set method for a float resource. More... | |
void | set (double *res) |
The set method for a double resource. More... | |
void | set (bool *res) |
The set method for a bool resource. More... | |
void | set (Resource *res) |
The set method for a Resource resource. More... | |
void | set (ParameterSettable *res) |
The set method for a ParameterSettable resource. More... | |
void | set (QObject *res) |
The set method for a QObject resource. More... | |
void | shareLockWith (ResourceHandler *other) |
Shares the lock with the other resource. More... | |
void | unset () |
Marks this resource as non-existing. More... | |
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
-
name the name of the resource. This cannot be changed once set here in the constructor
Definition at line 68 of file resource.cpp.
~ResourceHandler | ( | ) |
Destructor.
Definition at line 76 of file resource.cpp.
Member Function Documentation
void addNotifee | ( | ResourcesUser * | n | ) |
Adds a new observer.
- Parameters
-
n the 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().
|
inline |
Returns true if this holds an existing resource.
- Returns
- true if this holds an existing resource
Definition at line 327 of file resource.h.
Referenced by ConcurrentResourcesUser::addUsableResource(), ConcurrentResourcesUser::addUsableResources(), ConcurrentResourcesUser::declareResource(), SimpleResourcesUser::deleteResource(), ConcurrentResourcesUser::deleteResource(), SimpleResourcesUser::getResource(), ConcurrentResourcesUser::getResource(), ConcurrentResourcesUser::removeAllUsableResources(), ConcurrentResourcesUser::removeUsableResources(), ConcurrentResourcesUser::usableResources(), and ConcurrentResourcesUser::usedResourcesExist().
|
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().
|
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
-
n the 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.
|
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
-
n the 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
-
res the 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
-
res the 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
-
res the 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
-
res the 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
-
res the 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
-
res the 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
-
res the 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
-
other the 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:
- configuration/include/resource.h
- configuration/src/resource.cpp