From d6a687cdff25a69b3333a1e490934128b095f0db Mon Sep 17 00:00:00 2001 From: Wolf Bergenheim Date: Fri, 19 Feb 2010 17:06:45 +0200 Subject: Changes based on Qt feedback. Removed addResources, it add no value --- libresourceqt/include/qt4/policy/audio-resource.h | 1 - libresourceqt/include/qt4/policy/resource-set.h | 57 +++++++++++++---------- libresourceqt/include/qt4/policy/resource.h | 1 - libresourceqt/include/qt4/policy/resources.h | 12 ----- 4 files changed, 32 insertions(+), 39 deletions(-) (limited to 'libresourceqt/include/qt4') diff --git a/libresourceqt/include/qt4/policy/audio-resource.h b/libresourceqt/include/qt4/policy/audio-resource.h index a1c8443..99c2c7f 100644 --- a/libresourceqt/include/qt4/policy/audio-resource.h +++ b/libresourceqt/include/qt4/policy/audio-resource.h @@ -29,7 +29,6 @@ public: void setStreamTag(const QString &name, const QString &value); virtual ResourceType type() const; - virtual Resource * clone() const; private: QString group; quint32 pid; diff --git a/libresourceqt/include/qt4/policy/resource-set.h b/libresourceqt/include/qt4/policy/resource-set.h index c6012c1..bc81b89 100644 --- a/libresourceqt/include/qt4/policy/resource-set.h +++ b/libresourceqt/include/qt4/policy/resource-set.h @@ -13,30 +13,34 @@ * * \section intro_section Introduction * - * This library is used to request resources from the Polict Resource Manager. + * This library is used to request resources from the Policy Resource Manager. * To use this library two classes are provided: \ref ResourcePolicy::Resource and * \ref ResourcePolicy::ResourceSet. * * \section library_use_section Library Usage * - * To use the Resource Policy Library, you first need to create a number of - * \ref Resource objects like this (given as an example of what a media player - * might want/need): + * To use the Resource Policy Library, you first need to create the + * \ref ResourcePolicy::ResourceSet like this: * \code - * ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource(); - * ResourcePolicy::VideoResource *audioResource = new ResourcePolicy::VideoResource(); - * videoResource->setOptional(); + * ResourcePolicy::ResourceSet *resources = new ResourcePolicy::ResourceSet("player"); * \endcode - * Then you need to create a \ref ResourcePolicy::ResourceSet like this: + * Then to add resources to the set use the \ref addResource() method to add + * resources to the \ref ResourceSet. Like this: * \code - * ResourcePolicy::ResourceSet *resources = new ResourcePolicy::ResourceSet("player"); - * resources->addResource(audioResource); - * resources->addResource(videoResource); + * resources->addResource(AudioPlaybackType); + * resources->addResource(VideoPlaybackType); + * \endcode + * If you want to pre-populate the AudioResource with the audio group (it is a good idea) + * and other oudio parameters you can create an audio object your self and then + * give that to the \ref ResourceSet. Note that you should NOT free this object. + * The \ref ResourceSet takes ownership of this pointer. + * \code + * ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource("fmradio"); + * resources->addResourceObject(audioResource); * \endcode - * The resource set now has control over the Resource object pointers. You can - * drop them, but should NOT delete them. Instead call the ResourcePolicy::ResourceSet::deleteResource() - * method. Then when you want to acquire the \ref ResourcePolicy::ResourceSet - * you simply use the \ref ResourcePolicy::ResourceSetacquire() method, like this: + * Calling the ResourcePolicy::ResourceSet::deleteResource() method will remove + * and delete the object. Then when you want to acquire the \ref ResourcePolicy::ResourceSet + * you simply use the \ref acquire() method, like this: * \code * QObject::connect(resources, SIGNAL(resourcesAcquired()), * this, SLOT(acquireOkHandler(QList))); @@ -50,6 +54,8 @@ * \endcode * This signal tells you when you should stop using the resources you have asked for. * So it is important that you connect to it. + * + * To modify the properties of the resources you can use the \ref resource() method. */ /** @@ -86,19 +92,20 @@ public: * This method adds a resource to the set. A set contains only a single * instance of a given resource. If the ResourceSet already contains a * resource of the given type it will be overridden. - * \param resource The resource to add to the set. A copy of this object + * \param resourceType The resource to add to the set. A copy of this object * is stored in the Set. */ - void addResource(Resource *resource); + bool addResource(ResourceType resourceType); + /** - * This method adds all resources in the list to the set. - * A set contains only a single instance of a given resource. If the - * ResourceSet already contains a resource of the given type it will be - * overridden. - * \param resources The list of resources to add to the set. These will - * be copied. - */ - void addResources(const QListresources); + * This method adds a resource to the set. A set contains only a single + * instance of a given resource. If the ResourceSet already contains a + * resource of the given type it will be overridden. + * \param resource The resource to add to the set. The \ref ResourseSet takes + * ownership of the pointer. Do NOT free! + */ + void addResourceObject(Resource *resource); + /** * This method removes the resource of the given type * \param type The type of the resource to remove from the set. diff --git a/libresourceqt/include/qt4/policy/resource.h b/libresourceqt/include/qt4/policy/resource.h index dd31a78..434f3dd 100644 --- a/libresourceqt/include/qt4/policy/resource.h +++ b/libresourceqt/include/qt4/policy/resource.h @@ -52,7 +52,6 @@ public: bool isGranted() const; virtual ResourceType type() const = 0; - virtual Resource * clone() const = 0; virtual ~Resource(); protected: Resource(); diff --git a/libresourceqt/include/qt4/policy/resources.h b/libresourceqt/include/qt4/policy/resources.h index 26ce014..c0d0eab 100644 --- a/libresourceqt/include/qt4/policy/resources.h +++ b/libresourceqt/include/qt4/policy/resources.h @@ -2,7 +2,6 @@ #define RESOURCES_H #include -#include #include namespace ResourcePolicy @@ -16,7 +15,6 @@ public: virtual ~AudioRecorderResource(); virtual ResourceType type() const; - virtual Resource * clone() const; private: QString group; quint32 pid; @@ -31,7 +29,6 @@ public: virtual ~BacklightResource(); virtual ResourceType type() const; - virtual Resource * clone() const; }; class LedsResource: public Resource @@ -42,7 +39,6 @@ public: virtual ~LedsResource(); virtual ResourceType type() const; - virtual Resource * clone() const; }; class VibraResource: public Resource @@ -53,7 +49,6 @@ public: virtual ~VibraResource(); virtual ResourceType type() const; - virtual Resource * clone() const; }; class VideoRecorderResource: public Resource @@ -64,7 +59,6 @@ public: virtual ~VideoRecorderResource(); virtual ResourceType type() const; - virtual Resource * clone() const; }; class VideoResource: public Resource @@ -75,7 +69,6 @@ public: virtual ~VideoResource(); virtual ResourceType type() const; - virtual Resource * clone() const; }; class SystemButtonResource: public Resource @@ -86,7 +79,6 @@ public: virtual ~SystemButtonResource(); virtual ResourceType type() const; - virtual Resource * clone() const; }; class LockButtonResource: public Resource @@ -97,7 +89,6 @@ public: virtual ~LockButtonResource(); virtual ResourceType type() const; - virtual Resource * clone() const; }; class ScaleButtonResource: public Resource @@ -108,7 +99,6 @@ public: virtual ~ScaleButtonResource(); virtual ResourceType type() const; - virtual Resource * clone() const; }; class SnapButtonResource: public Resource @@ -119,7 +109,6 @@ public: virtual ~SnapButtonResource(); virtual ResourceType type() const; - virtual Resource * clone() const; }; class LensCoverResource: public Resource @@ -130,7 +119,6 @@ public: virtual ~LensCoverResource(); virtual ResourceType type() const; - virtual Resource * clone() const; }; } #endif -- cgit v1.2.3