summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.co.uk>2011-01-04 17:55:27 +0200
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.co.uk>2011-01-04 17:55:27 +0200
commitfff687bc227c6061c2bd2dea1eb9ce3f338542a1 (patch)
tree85da0574d7f12454be1bf1fb1bc378fc6990eb31
parentb5263d56a5e0469ce282bf826f46c9366cbe5f2b (diff)
Add a new QGlib::Interface base class for interfaces and make all interfaces inherit from there.
This will help avoid issues with interface inheritance, since theoretically it is possible to change interface requirements without breaking ABI in the C library, but it is not possible to change object inheritance in C++ without breaking ABI.
-rw-r--r--src/QGlib/global.h3
-rw-r--r--src/QGlib/object.cpp24
-rw-r--r--src/QGlib/object.h37
-rw-r--r--src/QGst/Ui/videowidget.cpp4
-rw-r--r--src/QGst/childproxy.h2
-rw-r--r--src/QGst/clock.h2
-rw-r--r--src/QGst/colorbalance.h5
-rw-r--r--src/QGst/element.h2
-rw-r--r--src/QGst/object.h2
-rw-r--r--src/QGst/propertyprobe.h5
-rw-r--r--src/QGst/streamvolume.h5
-rw-r--r--src/QGst/urihandler.h5
-rw-r--r--src/QGst/videoorientation.h5
-rw-r--r--src/QGst/xoverlay.h5
-rw-r--r--tests/auto/urihandlertest.cpp1
15 files changed, 73 insertions, 34 deletions
diff --git a/src/QGlib/global.h b/src/QGlib/global.h
index 4ddb8b2..94a0618 100644
--- a/src/QGlib/global.h
+++ b/src/QGlib/global.h
@@ -60,6 +60,9 @@ typedef RefPointer<Object> ObjectPtr;
#define QGLIB_WRAPPER(Class) \
QGLIB_WRAPPER_DECLARATION_MACRO(Class, Class, G, Class)
+#define QGLIB_WRAPPER_DIFFERENT_C_CLASS(Class, CClass) \
+ QGLIB_WRAPPER_DECLARATION_MACRO(Class, CClass, G, Class)
+
#if !defined(BOOST_NO_STATIC_ASSERT) //we have c++0x static_assert
# define QGLIB_STATIC_ASSERT(expr, message) static_assert(expr, message)
diff --git a/src/QGlib/object.cpp b/src/QGlib/object.cpp
index 505885f..0e1b918 100644
--- a/src/QGlib/object.cpp
+++ b/src/QGlib/object.cpp
@@ -36,7 +36,7 @@ QList< RefPointer<T> > arrayToList(typename T::CType **array, uint n)
} //namespace Private
-ParamSpecPtr Object::findProperty(const char *name) const
+ParamSpecPtr ObjectBase::findProperty(const char *name) const
{
GObjectClass *klass = G_OBJECT_CLASS(g_type_class_ref(Type::fromInstance(object<void>())));
GParamSpec *param = g_object_class_find_property(klass, name);
@@ -48,7 +48,7 @@ ParamSpecPtr Object::findProperty(const char *name) const
}
}
-QList<ParamSpecPtr> Object::listProperties() const
+QList<ParamSpecPtr> ObjectBase::listProperties() const
{
GObjectClass *klass = G_OBJECT_CLASS(g_type_class_ref(Type::fromInstance(object<void>())));
uint n;
@@ -59,7 +59,7 @@ QList<ParamSpecPtr> Object::listProperties() const
return result;
}
-Value Object::property(const char *name) const
+Value ObjectBase::property(const char *name) const
{
Value result;
ParamSpecPtr param = findProperty(name);
@@ -70,49 +70,49 @@ Value Object::property(const char *name) const
return result;
}
-void Object::setPropertyValue(const char *name, const Value & value)
+void ObjectBase::setPropertyValue(const char *name, const Value & value)
{
g_object_set_property(object<GObject>(), name, value);
}
-void *Object::data(const char *key) const
+void *ObjectBase::data(const char *key) const
{
return g_object_get_data(object<GObject>(), key);
}
-void *Object::stealData(const char *key) const
+void *ObjectBase::stealData(const char *key) const
{
return g_object_steal_data(object<GObject>(), key);
}
-void Object::setData(const char *key, void *data, void (*destroyCallback)(void*))
+void ObjectBase::setData(const char *key, void *data, void (*destroyCallback)(void*))
{
g_object_set_data_full(object<GObject>(), key, data, destroyCallback);
}
-void *Object::quarkData(const Quark & quark) const
+void *ObjectBase::quarkData(const Quark & quark) const
{
return g_object_get_qdata(object<GObject>(), quark);
}
-void *Object::stealQuarkData(const Quark & quark) const
+void *ObjectBase::stealQuarkData(const Quark & quark) const
{
return g_object_steal_qdata(object<GObject>(), quark);
}
-void Object::setQuarkData(const Quark & quark, void *data, void (*destroyCallback)(void*))
+void ObjectBase::setQuarkData(const Quark & quark, void *data, void (*destroyCallback)(void*))
{
g_object_set_qdata_full(object<GObject>(), quark, data, destroyCallback);
}
-void Object::ref(bool increaseRef)
+void ObjectBase::ref(bool increaseRef)
{
if (increaseRef) {
g_object_ref(m_object);
}
}
-void Object::unref()
+void ObjectBase::unref()
{
g_object_unref(m_object);
}
diff --git a/src/QGlib/object.h b/src/QGlib/object.h
index 389821c..94578e3 100644
--- a/src/QGlib/object.h
+++ b/src/QGlib/object.h
@@ -29,11 +29,14 @@
namespace QGlib {
/*! \headerfile QGlib/object.h <QGlib/Object>
- * \brief Wrapper class for GObject
+ * \brief Common virtual base class for Object and Interface
+ *
+ * This class is an implementation detail that serves only in code reuse between
+ * the Object and Interface classes. You should not use this class directly at all.
+ * Use Object or Interface instead.
*/
-class Object : public RefCountedObject
+class ObjectBase : public RefCountedObject
{
- QGLIB_WRAPPER(Object)
public:
ParamSpecPtr findProperty(const char *name) const;
QList<ParamSpecPtr> listProperties() const;
@@ -51,12 +54,37 @@ public:
void setQuarkData(const Quark & quark, void *data, void (*destroyCallback)(void*) = NULL);
protected:
+ ObjectBase() {}
+ virtual ~ObjectBase() {}
+ Q_DISABLE_COPY(ObjectBase);
+
virtual void ref(bool increaseRef);
virtual void unref();
};
+/*! \headerfile QGlib/object.h <QGlib/Object>
+ * \brief Wrapper class for GObject
+ *
+ * The methods of this class can be found in ObjectBase.
+ */
+class Object : virtual public ObjectBase
+{
+ QGLIB_WRAPPER(Object)
+};
+
+/*! \headerfile QGlib/object.h <QGlib/Object>
+ * \brief Base class for interface wrappers
+ *
+ * The methods of this class can be found in ObjectBase.
+ */
+class Interface : virtual public ObjectBase
+{
+ QGLIB_WRAPPER_DIFFERENT_C_CLASS(Interface, Object)
+};
+
+
template <class T>
-void Object::setProperty(const char *name, const T & value)
+void ObjectBase::setProperty(const char *name, const T & value)
{
ParamSpecPtr param = findProperty(name);
if (param) {
@@ -70,5 +98,6 @@ void Object::setProperty(const char *name, const T & value)
} //namespace QGlib
QGLIB_REGISTER_TYPE(QGlib::Object)
+QGLIB_REGISTER_TYPE(QGlib::Interface)
#endif
diff --git a/src/QGst/Ui/videowidget.cpp b/src/QGst/Ui/videowidget.cpp
index 7fca3fd..659176d 100644
--- a/src/QGst/Ui/videowidget.cpp
+++ b/src/QGst/Ui/videowidget.cpp
@@ -62,13 +62,13 @@ public:
widget()->update();
}
- virtual ElementPtr videoSink() const { return m_sink; }
+ virtual ElementPtr videoSink() const { return m_sink.dynamicCast<Element>(); }
virtual bool eventFilter(QObject *filteredObject, QEvent *event)
{
if (filteredObject == parent() && event->type() == QEvent::Paint) {
State currentState;
- m_sink->getState(&currentState, NULL, 0);
+ videoSink()->getState(&currentState, NULL, 0);
if (currentState == StatePlaying || currentState == StatePaused) {
m_sink->expose();
} else {
diff --git a/src/QGst/childproxy.h b/src/QGst/childproxy.h
index 49b9fcc..107f3f0 100644
--- a/src/QGst/childproxy.h
+++ b/src/QGst/childproxy.h
@@ -24,7 +24,7 @@ namespace QGst {
/*! \interface ChildProxy childproxy.h <QGst/ChildProxy>
* \brief Wrapper class for GstChildProxy
*/
-class ChildProxy : public virtual Object
+class ChildProxy : public QGlib::Interface
{
QGST_WRAPPER(ChildProxy)
public:
diff --git a/src/QGst/clock.h b/src/QGst/clock.h
index c068828..b4e364f 100644
--- a/src/QGst/clock.h
+++ b/src/QGst/clock.h
@@ -27,7 +27,7 @@ namespace QGst {
/*! \headerfile clock.h <QGst/Clock>
* \brief Wrapper class for GstClock
*/
-class Clock : public virtual Object
+class Clock : public Object
{
QGST_WRAPPER(Clock)
public:
diff --git a/src/QGst/colorbalance.h b/src/QGst/colorbalance.h
index 025424a..c8bf262 100644
--- a/src/QGst/colorbalance.h
+++ b/src/QGst/colorbalance.h
@@ -17,7 +17,8 @@
#ifndef QGST_COLORBALANCE_H
#define QGST_COLORBALANCE_H
-#include "element.h"
+#include "global.h"
+#include "../QGlib/object.h"
namespace QGst {
@@ -36,7 +37,7 @@ public:
/*! \headerfile colorbalance.h <QGst/ColorBalance>
* \brief Wrapper class for GstColorBalance
*/
-class ColorBalance : public Element
+class ColorBalance : public QGlib::Interface
{
QGST_WRAPPER(ColorBalance)
public:
diff --git a/src/QGst/element.h b/src/QGst/element.h
index 8235485..371d622 100644
--- a/src/QGst/element.h
+++ b/src/QGst/element.h
@@ -25,7 +25,7 @@ namespace QGst {
/*! \headerfile element.h <QGst/Element>
* \brief Wrapper class for GstElement
*/
-class Element : public virtual Object
+class Element : public Object
{
QGST_WRAPPER(Element)
public:
diff --git a/src/QGst/object.h b/src/QGst/object.h
index 33d1722..015efac 100644
--- a/src/QGst/object.h
+++ b/src/QGst/object.h
@@ -25,7 +25,7 @@ namespace QGst {
/*! \headerfile QGst/object.h <QGst/Object>
* \brief Wrapper class for GstObject
*/
-class Object : public virtual QGlib::Object
+class Object : public QGlib::Object
{
QGST_WRAPPER(Object)
public:
diff --git a/src/QGst/propertyprobe.h b/src/QGst/propertyprobe.h
index edf9249..75714e6 100644
--- a/src/QGst/propertyprobe.h
+++ b/src/QGst/propertyprobe.h
@@ -17,14 +17,15 @@
#ifndef QGST_PROPERTYPROBE_H
#define QGST_PROPERTYPROBE_H
-#include "element.h"
+#include "global.h"
+#include "../QGlib/object.h"
namespace QGst {
/*! \interface PropertyProbe propertyprobe.h <QGst/PropertyProbe>
* \brief Wrapper class for GstPropertyProbe
*/
-class PropertyProbe : public Element
+class PropertyProbe : public QGlib::Interface
{
QGST_WRAPPER(PropertyProbe)
public:
diff --git a/src/QGst/streamvolume.h b/src/QGst/streamvolume.h
index 8a7f624..b908f66 100644
--- a/src/QGst/streamvolume.h
+++ b/src/QGst/streamvolume.h
@@ -17,14 +17,15 @@
#ifndef QGST_STREAMVOLUME_H
#define QGST_STREAMVOLUME_H
-#include "element.h"
+#include "global.h"
+#include "../QGlib/object.h"
namespace QGst {
/*! \headerfile streamvolume.h <QGst/StreamVolume>
* \brief Wrapper class for GstStreamVolume
*/
-class StreamVolume : public Element
+class StreamVolume : public QGlib::Interface
{
QGST_WRAPPER(StreamVolume)
public:
diff --git a/src/QGst/urihandler.h b/src/QGst/urihandler.h
index d644c72..eeb2538 100644
--- a/src/QGst/urihandler.h
+++ b/src/QGst/urihandler.h
@@ -17,7 +17,8 @@
#ifndef QGST_URIHANDLER_H
#define QGST_URIHANDLER_H
-#include "element.h"
+#include "global.h"
+#include "../QGlib/object.h"
class QUrl;
namespace QGst {
@@ -25,7 +26,7 @@ namespace QGst {
/*! \interface UriHandler urihandler.h <QGst/UriHandler>
* \brief Wrapper class for GstURIHandler
*/
-class UriHandler : public virtual Element
+class UriHandler : public QGlib::Interface
{
QGST_WRAPPER_DIFFERENT_C_CLASS(UriHandler, URIHandler)
public:
diff --git a/src/QGst/videoorientation.h b/src/QGst/videoorientation.h
index 254a9af..4764ee1 100644
--- a/src/QGst/videoorientation.h
+++ b/src/QGst/videoorientation.h
@@ -19,14 +19,15 @@
#ifndef QGST_VIDEOORIENTATION_H
#define QGST_VIDEOORIENTATION_H
-#include "element.h"
+#include "global.h"
+#include "../QGlib/object.h"
namespace QGst {
/*! \interface VideoOrientation videoorientation.h <QGst/VideoOrientation>
* \brief Wrapper class for GstVideoOrientation
*/
-class VideoOrientation : public Element
+class VideoOrientation : public QGlib::Interface
{
QGST_WRAPPER(VideoOrientation)
public:
diff --git a/src/QGst/xoverlay.h b/src/QGst/xoverlay.h
index 5a69f0a..f8d665b 100644
--- a/src/QGst/xoverlay.h
+++ b/src/QGst/xoverlay.h
@@ -17,7 +17,8 @@
#ifndef QGST_XOVERLAY_H
#define QGST_XOVERLAY_H
-#include "element.h"
+#include "global.h"
+#include "../QGlib/object.h"
#include <QtGui/qwindowdefs.h>
class QRect;
@@ -27,7 +28,7 @@ namespace QGst {
/*! \interface XOverlay xoverlay.h <QGst/XOverlay>
* \brief Wrapper class for GstXOverlay
*/
-class XOverlay : public Element
+class XOverlay : public QGlib::Interface
{
QGST_WRAPPER(XOverlay)
public:
diff --git a/tests/auto/urihandlertest.cpp b/tests/auto/urihandlertest.cpp
index 755829c..c722e87 100644
--- a/tests/auto/urihandlertest.cpp
+++ b/tests/auto/urihandlertest.cpp
@@ -16,6 +16,7 @@
*/
#include "qgsttest.h"
#include <QGst/UriHandler>
+#include <QGst/Element>
#include <QGst/ElementFactory>
class UriHandlerTest : public QGstTest