File indexing completed on 2025-02-09 05:31:48
0001 /* This file is part of the KDE project 0002 Copyright (C) 2007 Matthias Kretz <kretz@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Lesser General Public 0006 License as published by the Free Software Foundation; either 0007 version 2.1 of the License, or (at your option) version 3, or any 0008 later version accepted by the membership of KDE e.V. (or its 0009 successor approved by the membership of KDE e.V.), Nokia Corporation 0010 (or its successors, if any) and the KDE Free Qt Foundation, which shall 0011 act as a proxy defined in Section 6 of version 3 of the license. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 0021 */ 0022 0023 #ifndef PHONON_MEDIANODE_P_H 0024 #define PHONON_MEDIANODE_P_H 0025 0026 #include <QtGlobal> 0027 #include <QList> 0028 #include <QObject> 0029 0030 #include "path.h" 0031 #include "phononpimpl_p.h" 0032 #include "phonon_export.h" 0033 0034 class QObject; 0035 0036 namespace Phonon 0037 { 0038 class MediaNode; 0039 class MediaNodeDestructionHandler; 0040 0041 class PHONON_EXPORT MediaNodePrivate 0042 { 0043 P_DECLARE_PUBLIC(MediaNode) 0044 0045 friend class AudioOutputPrivate; 0046 friend class FactoryPrivate; 0047 0048 protected: 0049 enum CastId { 0050 MediaNodePrivateType, 0051 AbstractAudioOutputPrivateType, 0052 AudioOutputType 0053 }; 0054 public: 0055 /** 0056 * Returns the backend object. If the object does not exist it tries to 0057 * create it before returning. 0058 * 0059 * \return the Iface object, might return \c 0 0060 */ 0061 QObject *backendObject(); 0062 0063 const CastId castId; 0064 0065 protected: 0066 MediaNodePrivate(CastId _castId = MediaNodePrivateType); 0067 0068 virtual ~MediaNodePrivate(); 0069 0070 /** 0071 * \internal 0072 * This method cleanly deletes the Iface object. It is called on 0073 * destruction and before a backend change. 0074 */ 0075 void deleteBackendObject(); 0076 0077 virtual bool aboutToDeleteBackendObject() = 0; 0078 0079 /** 0080 * \internal 0081 * Creates the Iface object belonging to this class. For most cases the 0082 * implementation is 0083 * \code 0084 * Q_Q(ClassName); 0085 * m_iface = Factory::createClassName(this); 0086 * return m_iface; 0087 * \endcode 0088 * 0089 * This function should not be called except from slotCreateIface. 0090 * 0091 * \see slotCreateIface 0092 */ 0093 virtual void createBackendObject() = 0; 0094 0095 public: 0096 /** 0097 * \internal 0098 * This class has its own destroyed signal since some cleanup calls 0099 * need the pointer to the backend object intact. The 0100 * QObject::destroyed signals comes after the backend object was 0101 * deleted. 0102 * 0103 * As this class cannot derive from QObject a simple handler 0104 * interface is used. 0105 */ 0106 void addDestructionHandler(MediaNodeDestructionHandler *handler); 0107 0108 /** 0109 * \internal 0110 * This class has its own destroyed signal since some cleanup calls 0111 * need the pointer to the backend object intact. The 0112 * QObject::destroyed signals comes after the backend object was 0113 * deleted. 0114 * 0115 * As this class cannot derive from QObject a simple handler 0116 * interface is used. 0117 */ 0118 void removeDestructionHandler(MediaNodeDestructionHandler *handler); 0119 0120 void addOutputPath(const Path &); 0121 void addInputPath(const Path &); 0122 void removeOutputPath(const Path &); 0123 void removeInputPath(const Path &); 0124 0125 const QObject *qObject() const { return const_cast<MediaNodePrivate *>(this)->qObject(); } 0126 virtual QObject *qObject() { return nullptr; } 0127 0128 protected: 0129 MediaNode *q_ptr; 0130 public: 0131 QObject *m_backendObject; 0132 protected: 0133 QList<Path> outputPaths; 0134 QList<Path> inputPaths; 0135 0136 private: 0137 QList<MediaNodeDestructionHandler *> handlers; 0138 Q_DISABLE_COPY(MediaNodePrivate) 0139 }; 0140 0141 } // namespace Phonon 0142 0143 #endif // PHONON_MEDIANODE_P_H