1 | /* This file is part of the KDE project |
2 | Copyright (C) 2007 Matthias Kretz <kretz@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2.1 of the License, or (at your option) version 3, or any |
8 | later version accepted by the membership of KDE e.V. (or its |
9 | successor approved by the membership of KDE e.V.), Nokia Corporation |
10 | (or its successors, if any) and the KDE Free Qt Foundation, which shall |
11 | act as a proxy defined in Section 6 of version 3 of the license. |
12 | |
13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Lesser General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Lesser General Public |
19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
20 | |
21 | */ |
22 | |
23 | #ifndef PHONON_MEDIANODE_P_H |
24 | #define PHONON_MEDIANODE_P_H |
25 | |
26 | #include <QtGlobal> |
27 | #include <QList> |
28 | #include <QObject> |
29 | |
30 | #include "path.h" |
31 | #include "phononpimpl_p.h" |
32 | #include "phonon_export.h" |
33 | |
34 | class QObject; |
35 | |
36 | namespace Phonon |
37 | { |
38 | class MediaNode; |
39 | class MediaNodeDestructionHandler; |
40 | |
41 | class PHONON_EXPORT MediaNodePrivate |
42 | { |
43 | P_DECLARE_PUBLIC(MediaNode) |
44 | |
45 | friend class AudioOutputPrivate; |
46 | friend class FactoryPrivate; |
47 | |
48 | protected: |
49 | enum CastId { |
50 | MediaNodePrivateType, |
51 | AbstractAudioOutputPrivateType, |
52 | AudioOutputType |
53 | }; |
54 | public: |
55 | /** |
56 | * Returns the backend object. If the object does not exist it tries to |
57 | * create it before returning. |
58 | * |
59 | * \return the Iface object, might return \c 0 |
60 | */ |
61 | QObject *backendObject(); |
62 | |
63 | const CastId castId; |
64 | |
65 | protected: |
66 | MediaNodePrivate(CastId _castId = MediaNodePrivateType); |
67 | |
68 | virtual ~MediaNodePrivate(); |
69 | |
70 | /** |
71 | * \internal |
72 | * This method cleanly deletes the Iface object. It is called on |
73 | * destruction and before a backend change. |
74 | */ |
75 | void deleteBackendObject(); |
76 | |
77 | virtual bool aboutToDeleteBackendObject() = 0; |
78 | |
79 | /** |
80 | * \internal |
81 | * Creates the Iface object belonging to this class. For most cases the |
82 | * implementation is |
83 | * \code |
84 | * Q_Q(ClassName); |
85 | * m_iface = Factory::createClassName(this); |
86 | * return m_iface; |
87 | * \endcode |
88 | * |
89 | * This function should not be called except from slotCreateIface. |
90 | * |
91 | * \see slotCreateIface |
92 | */ |
93 | virtual void createBackendObject() = 0; |
94 | |
95 | public: |
96 | /** |
97 | * \internal |
98 | * This class has its own destroyed signal since some cleanup calls |
99 | * need the pointer to the backend object intact. The |
100 | * QObject::destroyed signals comes after the backend object was |
101 | * deleted. |
102 | * |
103 | * As this class cannot derive from QObject a simple handler |
104 | * interface is used. |
105 | */ |
106 | void addDestructionHandler(MediaNodeDestructionHandler *handler); |
107 | |
108 | /** |
109 | * \internal |
110 | * This class has its own destroyed signal since some cleanup calls |
111 | * need the pointer to the backend object intact. The |
112 | * QObject::destroyed signals comes after the backend object was |
113 | * deleted. |
114 | * |
115 | * As this class cannot derive from QObject a simple handler |
116 | * interface is used. |
117 | */ |
118 | void removeDestructionHandler(MediaNodeDestructionHandler *handler); |
119 | |
120 | void addOutputPath(const Path &); |
121 | void addInputPath(const Path &); |
122 | void removeOutputPath(const Path &); |
123 | void removeInputPath(const Path &); |
124 | |
125 | const QObject *qObject() const { return const_cast<MediaNodePrivate *>(this)->qObject(); } |
126 | virtual QObject *qObject() { return nullptr; } |
127 | |
128 | protected: |
129 | MediaNode *q_ptr; |
130 | public: |
131 | QObject *m_backendObject; |
132 | protected: |
133 | QList<Path> outputPaths; |
134 | QList<Path> inputPaths; |
135 | |
136 | private: |
137 | QList<MediaNodeDestructionHandler *> handlers; |
138 | Q_DISABLE_COPY(MediaNodePrivate) |
139 | }; |
140 | |
141 | } // namespace Phonon |
142 | |
143 | #endif // PHONON_MEDIANODE_P_H |
144 | |