27 #include "parametersettable.h"
29 #include "configurationexceptions.h"
39 class ResourceHandler;
40 class ResourceCollection;
123 return (m_shared == other.m_shared);
133 return m_shared->resourceLock;
144 return &(m_shared->resourceLock);
152 struct MutexAndRefCounter
157 MutexAndRefCounter() :
158 resourceLock(QMutex::Recursive),
171 int referenceCounter;
177 MutexAndRefCounter* m_shared;
241 void set(
float* res);
249 void set(
double* res);
281 void set(QObject* res);
302 return dynamic_cast<T*
>(m_pointers.res);
303 case t_paramSettable:
304 return dynamic_cast<T*
>(m_pointers.par);
306 return dynamic_cast<T*
>(m_pointers.obj);
329 return (m_type != t_nonExistent);
366 const QString m_name;
391 ParameterSettable* par;
405 ResourceMutexHolder m_lock;
411 QSet<ResourcesUser *> m_notifees;
416 ResourceHandler(
const ResourceHandler&);
421 ResourceHandler& operator=(
const ResourceHandler&);
425 inline int* ResourceHandler::get<int>()
const
427 if (m_type == t_int) {
428 return m_pointers.intp;
435 inline float* ResourceHandler::get<float>()
const
437 if (m_type == t_float) {
438 return m_pointers.floatp;
445 inline double* ResourceHandler::get<double>()
const
447 if (m_type == t_double) {
448 return m_pointers.doublep;
455 inline bool* ResourceHandler::get<bool>()
const
457 if (m_type == t_bool) {
458 return m_pointers.boolp;
503 return m_waitCondition;
513 return ++m_referenceCounter;
523 return --m_referenceCounter;
533 return m_referenceCounter;
557 return (m_resources.contains(name) && m_resources[name]->exists());
566 QMap<QString, ResourceHandler*> m_resources;
585 QWaitCondition m_waitCondition;
590 int m_referenceCounter;
652 m_useLocks = useLock;
665 return (m_resourceCollection == other.m_resourceCollection);
675 return *m_resourceCollection;
686 return m_resourceCollection;
ResourceCollection * operator->() const
Overload of the dereference operator (->)
This file contains the common type defitions used on the whole framework.
bool exists() const
Returns true if this holds an existing resource.
bool operator==(const ResourceMutexHolder &other) const
Comparison operator.
The class keeping the resources.
int incrementReferenceCounter()
Increments the reference counter.
QString name() const
Returns the name of the resource.
virtual ~Resource()
Destructor.
The base for classes that can be configured/saved using a ConfigurationParameters object...
ResourceCollection & operator*() const
Overload of the dereference operator.
bool hasResource(QString name) const
Returns true if a resource with name specified has been declared.
QWaitCondition & getWaitCondition()
Returns the wait condition on the global resource lock.
int decrementReferenceCounter()
Decrements the reference counter.
QMutex & getLock()
Returns the mutex for this resource.
Resource is a class representing a generic resource addable into ResourceCollection.
QMutex & getLock()
Returns the global resource lock for this instance.
int getReferenceCounter()
Returns the current value of the reference counter.
The parent of classes managing resources.
A class that allows sharing the same mutex among different objects.
QMutex * operator->() const
Overload of the dereference operator (->)
bool operator==(const ResourceCollectionHolder &other) const
Comparison operator.
void setUseLock(bool useLock)
Sets whether locks should be used or not.
The class for representing a resource.
QMutex & operator*() const
Overload of the dereference operator.
This keeps an instance of ResourceCollection eventually sharing it.
ResourceChangeType
The change that happened to a resource.