- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# objectdescription.h

Go to the documentation of this file.

    00001 /*  This file is part of the KDE project
    00002     Copyright (C) 2006-2007 Matthias Kretz <kretz@kde.org>
    00003
    00004     This library is free software; you can redistribute it and/or
    00005     modify it under the terms of the GNU Lesser General Public
    00006     License as published by the Free Software Foundation; either
    00007     version 2.1 of the License, or (at your option) version 3, or any
    00008     later version accepted by the membership of KDE e.V. (or its
    00009     successor approved by the membership of KDE e.V.), Nokia Corporation
    00010     (or its successors, if any) and the KDE Free Qt Foundation, which shall
    00011     act as a proxy defined in Section 6 of version 3 of the license.
    00012
    00013     This library is distributed in the hope that it will be useful,
    00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00016     Lesser General Public License for more details.
    00017
    00018     You should have received a copy of the GNU Lesser General Public
    00019     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
    00020
    00021 */
    00022
    00023 #ifndef PHONON_OBJECTDESCRIPTION_H
    00024 #define PHONON_OBJECTDESCRIPTION_H
    00025
    00026 #include "phonon_export.h"
    00027
    00028 #include <QtCore/QExplicitlySharedDataPointer>
    00029 #include <QtCore/QtDebug>
    00030 #include <QtCore/QList>
    00031 #include <QtCore/QSharedData>
    00032 #include <QtCore/QString>
    00033 #include <QtCore/QVariant>
    00034
    00035 QT_BEGIN_HEADER
    00036 QT_BEGIN_NAMESPACE
    00037
    00038 namespace Phonon
    00039 {
    00040     class ObjectDescriptionPrivate;
    00041
    00048     enum ObjectDescriptionType
    00049     {
    00060         AudioOutputDeviceType,
    00061
    00065         EffectType,
    00066         AudioChannelType,
    00067         SubtitleType,
    00068
    00079         AudioCaptureDeviceType
    00080
    00081         //VideoOutputDeviceType,
    00082         //VideoCaptureDeviceType,
    00083         //AudioCodecType,
    00084         //VideoCodecType,
    00085         //ContainerFormatType,
    00086         //VisualizationType,
    00087     };
    00088
    00096 class PHONON_EXPORT ObjectDescriptionData : public QSharedData //krazy:exclude=dpointer (it's protected, which should be fine for this type of class)
    00097 {
    00098     public:
    00103         bool operator==(const ObjectDescriptionData &otherDescription) const;
    00104
    00111         QString name() const;
    00112
    00120         QString description() const;
    00121
    00129         QVariant property(const char *name) const;
    00130
    00136         QList<QByteArray> propertyNames() const;
    00137
    00142         bool isValid() const;
    00143
    00150         int index() const;
    00151
    00152         static ObjectDescriptionData *fromIndex(ObjectDescriptionType type, int index);
    00153
    00154         ~ObjectDescriptionData();
    00155
    00156         ObjectDescriptionData(ObjectDescriptionPrivate * = 0);
    00157         ObjectDescriptionData(int index, const QHash<QByteArray, QVariant> &properties);
    00158
    00159     protected:
    00160         ObjectDescriptionPrivate *const d;
    00161
    00162     private:
    00163         ObjectDescriptionData &operator=(const ObjectDescriptionData &rhs);
    00164 };
    00165
    00166 template<ObjectDescriptionType T> class ObjectDescriptionModel;
    00167
    00179 template<ObjectDescriptionType T>
    00180 class ObjectDescription
    00181 {
    00182     public:
    00187         static inline ObjectDescription<T> fromIndex(int index) { //krazy:exclude=inline
    00188             return ObjectDescription<T>(QExplicitlySharedDataPointer<ObjectDescriptionData>(ObjectDescriptionData::fromIndex(T, index)));
    00189         }
    00190
    00195         inline bool operator==(const ObjectDescription &otherDescription) const { //krazy:exclude=inline
    00196             return *d == *otherDescription.d;
    00197         }
    00198
    00203         inline bool operator!=(const ObjectDescription &otherDescription) const { //krazy:exclude=inline
    00204             return !operator==(otherDescription);
    00205         }
    00206
    00213         inline QString name() const { return d->name(); } //krazy:exclude=inline
    00214
    00222         inline QString description() const { return d->description(); } //krazy:exclude=inline
    00223
    00231         inline QVariant property(const char *name) const { return d->property(name); } //krazy:exclude=inline
    00232
    00238         inline QList<QByteArray> propertyNames() const { return d->propertyNames(); } //krazy:exclude=inline
    00239
    00244         inline bool isValid() const { return d->isValid(); } //krazy:exclude=inline
    00245
    00252         inline int index() const { return d->index(); } //krazy:exclude=inline
    00253
    00254         ObjectDescription() : d(new ObjectDescriptionData(0)) {}
    00255         ObjectDescription(int index, const QHash<QByteArray, QVariant> &properties) : d(new ObjectDescriptionData(index, properties)) {}
    00256
    00257     protected:
    00258         friend class ObjectDescriptionModel<T>;
    00259         ObjectDescription(const QExplicitlySharedDataPointer<ObjectDescriptionData> &dd) : d(dd) {}
    00260         QExplicitlySharedDataPointer<ObjectDescriptionData> d;
    00261 };
    00262
    00263 template<ObjectDescriptionType T>
    00264 inline QDebug operator<<(QDebug s, const ObjectDescription<T> &o) //krazy:exclude=inline
    00265 {
    00266     return s << o.name();
    00267 }
    00268
    00272 typedef ObjectDescription<AudioOutputDeviceType> AudioOutputDevice;
    00276 #ifndef QT_NO_PHONON_AUDIOCAPTURE
    00277 typedef ObjectDescription<AudioCaptureDeviceType> AudioCaptureDevice;
    00278 #endif //QT_NO_PHONON_AUDIOCAPTURE
    00279
    00282 //typedef ObjectDescription<VideoOutputDeviceType> VideoOutputDevice;
    00286 //typedef ObjectDescription<VideoCaptureDeviceType> VideoCaptureDevice;
    00290 #ifndef QT_NO_PHONON_EFFECT
    00291 typedef ObjectDescription<EffectType> EffectDescription;
    00292 #endif //QT_NO_PHONON_EFFECT
    00293
    00297 //typedef ObjectDescription<AudioCodecType> AudioCodecDescription;
    00301 //typedef ObjectDescription<VideoCodecType> VideoCodecDescription;
    00305 //typedef ObjectDescription<ContainerFormatType> ContainerFormatDescription;
    00309 //typedef ObjectDescription<VisualizationType> VisualizationDescription;
    00310 #ifndef QT_NO_PHONON_MEDIACONTROLLER
    00311 typedef ObjectDescription<AudioChannelType> AudioChannelDescription;
    00312 typedef ObjectDescription<SubtitleType> SubtitleDescription;
    00313 #endif //QT_NO_PHONON_MEDIACONTROLLER
    00314
    00315 } //namespace Phonon
    00316
    00317 QT_END_NAMESPACE
    00318
    00319 Q_DECLARE_METATYPE(Phonon::AudioOutputDevice)
    00320 Q_DECLARE_METATYPE(QList<Phonon::AudioOutputDevice>)
    00321
    00322 #ifndef QT_NO_PHONON_AUDIOCAPTURE
    00323 Q_DECLARE_METATYPE(Phonon::AudioCaptureDevice)
    00324 Q_DECLARE_METATYPE(QList<Phonon::AudioCaptureDevice>)
    00325 #endif //QT_NO_PHONON_AUDIOCAPTURE
    00326
    00327 #ifndef QT_NO_PHONON_EFFECT
    00328 Q_DECLARE_METATYPE(QList<Phonon::EffectDescription>)
    00329 Q_DECLARE_METATYPE(Phonon::EffectDescription)
    00330 #endif //QT_NO_PHONON_EFFECT
    00331
    00332
    00333 #ifndef QT_NO_PHONON_MEDIACONTROLLER
    00334 Q_DECLARE_METATYPE(Phonon::AudioChannelDescription)
    00335 Q_DECLARE_METATYPE(Phonon::SubtitleDescription)
    00336 Q_DECLARE_METATYPE(QList<Phonon::AudioChannelDescription>)
    00337 Q_DECLARE_METATYPE(QList<Phonon::SubtitleDescription>)
    00338 #endif //QT_NO_PHONON_MEDIACONTROLLER
    00339
    00340 QT_END_HEADER
    00341
    00342 #endif // PHONON_OBJECTDESCRIPTION_H