[gstreamermm] MiniObject: Lay the foundation for virtual methods in derived classes.
- From: José Alburquerque <jaalburqu src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gstreamermm] MiniObject: Lay the foundation for virtual methods in derived classes.
- Date: Fri, 5 Feb 2010 21:26:36 +0000 (UTC)
commit 71906d964c7f30bd0d91400d9c3cabb2ff89f19e
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Fri Feb 5 14:29:05 2010 -0500
MiniObject: Lay the foundation for virtual methods in derived classes.
* gstreamer/gstreamermm/miniobject.cc (class_init_function): Modified
method to override the GstMiniObject virtual methods.
(MiniObject): Added new constructor designed to be used to initialize
the Glib::Class sort of as what is done with the ConstructParams
Glib::Object constructor.
(copy_vfunc_callback):
(copy_vfunc):
(finalize_vfunc_callback):
(finalize_vfunc): Wrote out first attempt at the two GstMiniObject
virtual functions.
* gstreamer/gstreamermm/miniobject.h (MiniObject): Declared new
constructor.
(copy_vfunc):
(finalize_vfunc): Declared virtual functions.
* gstreamer/gstreamermm/private/miniobject_p.h (copy_vfunc_callback):
(finalize_vfunc_callback): Declared virtual function callbacks.
* tools/m4/class_gstminiobject.m4 (_MINI_CTOR_DEFAULT): Added default
constructor wrapping macro for Gst::MiniObject derived classes. The
default constructor will use the Glib::Class initializing parent
constructor sort of as what happens with the ConstructParams
Glib::Object constructor.
(_PH_MINIOBJECTCLASS_DECLARATION): Added a section which includes the
virtual function declarations.
* gstreamer/src/element.hg (~ElementInterfaced): Code formatting.
ChangeLog | 30 ++++++++++++-
gstreamer/gstreamermm/miniobject.cc | 63 ++++++++++++++++++++++++--
gstreamer/gstreamermm/miniobject.h | 19 +++++++-
gstreamer/gstreamermm/private/miniobject_p.h | 8 +++
gstreamer/src/element.hg | 4 +-
tools/m4/class_gstminiobject.m4 | 21 +++++++++
6 files changed, 137 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1ae9e70..265789a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2010-02-04 José Alburquerque <jaalburqu svn gnome org>
+
+ MiniObject: Lay the foundation for virtual methods in derived classes.
+
+ * gstreamer/gstreamermm/miniobject.cc (class_init_function): Modified
+ method to override the GstMiniObject virtual methods.
+ (MiniObject): Added new constructor designed to be used to initialize
+ the Glib::Class sort of as what is done with the ConstructParams
+ Glib::Object constructor.
+ (copy_vfunc_callback):
+ (copy_vfunc):
+ (finalize_vfunc_callback):
+ (finalize_vfunc): Wrote out first attempt at the two GstMiniObject
+ virtual functions.
+ * gstreamer/gstreamermm/miniobject.h (MiniObject): Declared new
+ constructor.
+ (copy_vfunc):
+ (finalize_vfunc): Declared virtual functions.
+ * gstreamer/gstreamermm/private/miniobject_p.h (copy_vfunc_callback):
+ (finalize_vfunc_callback): Declared virtual function callbacks.
+ * tools/m4/class_gstminiobject.m4 (_MINI_CTOR_DEFAULT): Added default
+ constructor wrapping macro for Gst::MiniObject derived classes. The
+ default constructor will use the Glib::Class initializing parent
+ constructor sort of as what happens with the ConstructParams
+ Glib::Object constructor.
+ (_PH_MINIOBJECTCLASS_DECLARATION): Added a section which includes the
+ virtual function declarations.
+ * gstreamer/src/element.hg (~ElementInterfaced): Code formatting.
+
2010-02-02 José Alburquerque <jaalburqu svn gnome org>
Correct constant declarations in header files.
@@ -19,7 +48,6 @@
* gstreamer/gstreamermm/gst_wrap_init.h: Typo.
-
2010-02-01 José Alburquerque <jaalburqu svn gnome org>
Remove initial class identification in Doxygen class docs.
diff --git a/gstreamer/gstreamermm/miniobject.cc b/gstreamer/gstreamermm/miniobject.cc
index 8ff52fd..50177da 100644
--- a/gstreamer/gstreamermm/miniobject.cc
+++ b/gstreamer/gstreamermm/miniobject.cc
@@ -37,10 +37,15 @@ const Glib::Class& MiniObject_Class::init()
return *this;
}
-// gst_mini_object_base_[init|finalize]() don't do anything so those don't
-// have to be called from here.
-void MiniObject_Class::class_init_function(void*, void*)
-{}
+void MiniObject_Class::class_init_function(void* g_class, void* /*class_data*/)
+{
+ BaseClassType* const klass = static_cast<BaseClassType*>(g_class);
+
+#ifdef GLIBMM_VFUNCS_ENABLED
+ klass->copy = ©_vfunc_callback;
+ klass->finalize = &finalize_vfunc_callback;
+#endif //GLIBMM_VFUNCS_ENABLED
+}
MiniObject* MiniObject_Class::wrap_new(GstMiniObject* object)
{
@@ -57,6 +62,10 @@ MiniObject::MiniObject()
: gobject_(0)
{}
+MiniObject::MiniObject(const Glib::Class& mini_object_class)
+: gobject_(gst_mini_object_new(mini_object_class.get_type()))
+{}
+
MiniObject::MiniObject(GstMiniObject* castitem, bool take_copy)
: gobject_(take_copy ? gst_mini_object_copy(castitem) : castitem)
{}
@@ -135,6 +144,52 @@ Glib::RefPtr<Gst::MiniObject> MiniObject::create_writable()
return Gst::wrap(gst_mini_object_make_writable(gobject_));
}
+#ifdef GLIBMM_VFUNCS_ENABLED
+GstMiniObject* MiniObject_Class::copy_vfunc_callback(const GstMiniObject* self)
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(GST_MINI_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ // Call the original underlying C function:
+ if(base && base->copy)
+ return (*base->copy)(self);
+
+ return static_cast<GstMiniObject*>(0);
+}
+Glib::RefPtr<Gst::MiniObject> Gst::MiniObject::copy_vfunc() const
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(GST_MINI_OBJECT_GET_CLASS(gobj())) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ if(base && base->copy)
+ return Gst::wrap((*base->copy)(gobj()));
+
+ return Glib::RefPtr<Gst::MiniObject>(0);
+}
+void MiniObject_Class::finalize_vfunc_callback(GstMiniObject* self)
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(GST_MINI_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ // Call the original underlying C function:
+ if(base && base->finalize)
+ (*base->finalize)(self);
+
+}
+void Gst::MiniObject::finalize_vfunc()
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(GST_MINI_OBJECT_GET_CLASS(gobj())) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ if(base && base->finalize)
+ (*base->finalize)(gobj());
+}
+#endif //GLIBMM_VFUNCS_ENABLED
+
} //namespace Gst
/*
diff --git a/gstreamer/gstreamermm/miniobject.h b/gstreamer/gstreamermm/miniobject.h
index 49cd334..dea74b3 100644
--- a/gstreamer/gstreamermm/miniobject.h
+++ b/gstreamer/gstreamermm/miniobject.h
@@ -25,6 +25,9 @@
#include <glibmm/value.h>
#include <gstreamermm/wrap.h>
+namespace Glib
+{ class Class; }
+
namespace Gst
{
@@ -53,8 +56,8 @@ private:
protected:
MiniObject();
+ explicit MiniObject(const Glib::Class& mini_object_class);
explicit MiniObject(GstMiniObject* castitem, bool take_copy = false);
- virtual ~MiniObject();
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -63,6 +66,8 @@ public:
#endif
public:
+ virtual ~MiniObject();
+
//Note that we don't add a constructor for gst_mini_object_new()
//because it's just an equivalent for g_object_new(),
//which is just an equivalent for C++'s new().
@@ -123,6 +128,18 @@ public:
// static void replace(Glib::RefPtr<Gst::MiniObject> & olddata, Glib::RefPtr<Gst::MiniObject> & newdata);
+#ifdef GLIBMM_VFUNCS_ENABLED
+ /** Virtual function called when the Gst::MiniObject needs to be copied.
+ */
+ virtual Glib::RefPtr<Gst::MiniObject> copy_vfunc() const;
+
+ /** Virtual function called when the Gst::MiniObject is about to be
+ * finalized.
+ */
+ virtual void finalize_vfunc();
+#endif //GLIBMM_VFUNCS_ENABLED
+
+
protected:
void swap(MiniObject& other);
diff --git a/gstreamer/gstreamermm/private/miniobject_p.h b/gstreamer/gstreamermm/private/miniobject_p.h
index ba0ae38..c9f6097 100644
--- a/gstreamer/gstreamermm/private/miniobject_p.h
+++ b/gstreamer/gstreamermm/private/miniobject_p.h
@@ -39,6 +39,14 @@ public:
static void class_init_function(void* g_class, void* class_data);
static Gst::MiniObject* wrap_new(GstMiniObject*);
+
+protected:
+
+#ifdef GLIBMM_VFUNCS_ENABLED
+ static GstMiniObject* copy_vfunc_callback(const GstMiniObject* self);
+ static void finalize_vfunc_callback(GstMiniObject* self);
+#endif //GLIBMM_VFUNCS_ENABLED
+
};
diff --git a/gstreamer/src/element.hg b/gstreamer/src/element.hg
index 61a9575..e571ed6 100644
--- a/gstreamer/src/element.hg
+++ b/gstreamer/src/element.hg
@@ -483,6 +483,8 @@ protected:
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
public:
+ virtual ~ElementInterfaced();
+
// The gobj() methods make calls involving access to the underlying gobject
// unambiguous (specifically, gobj() is ambiguous when called from an
// ElementInterfaced<..> class).
@@ -495,8 +497,6 @@ public:
/// Gets a copy of the underlying gobject. The copy should be freed.
GstElement* gobj_copy() { return Element::gobj_copy(); };
-
- virtual ~ElementInterfaced();
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
diff --git a/tools/m4/class_gstminiobject.m4 b/tools/m4/class_gstminiobject.m4
index 23d126d..19c45b3 100644
--- a/tools/m4/class_gstminiobject.m4
+++ b/tools/m4/class_gstminiobject.m4
@@ -1,5 +1,19 @@
dnl Copyright 2008 The gstreamermm Development Team
+dnl Declares and implements the default constructor
+dnl
+m4_define(`_MINI_CTOR_DEFAULT',`dnl
+__CPPNAME__`'();
+_PUSH(SECTION_CC)
+__CPPNAME__::__CPPNAME__`'()
+:
+ __CPPPARENT__`'(__BASE__`'_class_.init())
+{
+ _IMPORT(SECTION_CC_INITIALIZE_CLASS_EXTRA)
+}
+
+_POP()')
+
define(`_CLASS_GSTMINIOBJECT',`dnl
_PUSH()
dnl
@@ -128,6 +142,13 @@ ifdef(`__BOOL_NO_DERIVED_CLASS__',`dnl
')dnl
static Gst::MiniObject* wrap_new(GstMiniObject*);
+
+protected:
+
+ //Callbacks (virtual functions):
+#ifdef GLIBMM_VFUNCS_ENABLED
+_IMPORT(SECTION_PH_VFUNCS)
+#endif //GLIBMM_VFUNCS_ENABLED
};
')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]