[gstreamermm] Make sure the MiniObject type is registered in the GType system.
- From: José Alburquerque <jaalburqu src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gstreamermm] Make sure the MiniObject type is registered in the GType system.
- Date: Fri, 23 Oct 2009 04:12:51 +0000 (UTC)
commit bf2e4d2c854d70c4ca7a5ce82ea3131df3cfafa1
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Thu Oct 22 23:49:27 2009 -0400
Make sure the MiniObject type is registered in the GType system.
* gstreamer/gstreamermm/miniobject.cc:
* gstreamer/gstreamermm/miniobject.h:
* gstreamer/gstreamermm/private/miniobject_p.h: Added code to ensure
that the MiniObject class can be successfully registered with the
GType system. Made the class non-copyable as it should be with
reference counted classes. Removed the copy() method which doesn't
make sense for a reference counted class. Use gst_mini_object_copy()
in gobj_copy(). Included a Value< Glib::RefPtr<Gst::MiniObject> >
template specialization to make sure that MiniObject can work with the
Glib::ValueBase system.
* tools/m4/class_gstminiobject.m4: Use gst_mini_object_copy() in
gobj_copy() for MiniObject derived classes.
* gstreamer/src/event.ccg:
* gstreamer/src/event.hg:
* gstreamer/src/message.ccg:
* gstreamer/src/message.hg:
* gstreamer/src/query.ccg:
* gstreamer/src/query.hg: Remove the copy() method which doesn't make
sense for reference counted classes.
* gstreamer/src/structure.ccg: Remove the MiniObject conversion
section in the _set_gstructure_field() gstreamermm/GStreamer
translation function because it is not needed.
* gstreamer/gstreamermm/wrap.h: Remove unneeded include.
ChangeLog | 28 ++++++++++
gstreamer/gstreamermm/miniobject.cc | 54 ++++++++++++++------
gstreamer/gstreamermm/miniobject.h | 71 ++++++++++++++++----------
gstreamer/gstreamermm/private/miniobject_p.h | 2 +
gstreamer/gstreamermm/wrap.h | 1 -
gstreamer/src/event.ccg | 5 --
gstreamer/src/event.hg | 6 +--
gstreamer/src/message.ccg | 5 --
gstreamer/src/message.hg | 6 +--
gstreamer/src/query.ccg | 5 --
gstreamer/src/query.hg | 5 --
gstreamer/src/structure.ccg | 8 ---
tools/m4/class_gstminiobject.m4 | 9 ++-
13 files changed, 119 insertions(+), 86 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3a15e9d..c2516e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2009-10-22 José Alburquerque <jaalburqu svn gnome org>
+
+ Make sure the MiniObject type is registered in the GType system.
+
+ * gstreamer/gstreamermm/miniobject.cc:
+ * gstreamer/gstreamermm/miniobject.h:
+ * gstreamer/gstreamermm/private/miniobject_p.h: Added code to ensure
+ that the MiniObject class can be successfully registered with the
+ GType system. Made the class non-copyable as it should be with
+ reference counted classes. Removed the copy() method which doesn't
+ make sense for a reference counted class. Use gst_mini_object_copy()
+ in gobj_copy(). Included a Value< Glib::RefPtr<Gst::MiniObject> >
+ template specialization to make sure that MiniObject can work with the
+ Glib::ValueBase system.
+ * tools/m4/class_gstminiobject.m4: Use gst_mini_object_copy() in
+ gobj_copy() for MiniObject derived classes.
+ * gstreamer/src/event.ccg:
+ * gstreamer/src/event.hg:
+ * gstreamer/src/message.ccg:
+ * gstreamer/src/message.hg:
+ * gstreamer/src/query.ccg:
+ * gstreamer/src/query.hg: Remove the copy() method which doesn't make
+ sense for reference counted classes.
+ * gstreamer/src/structure.ccg: Remove the MiniObject conversion
+ section in the _set_gstructure_field() gstreamermm/GStreamer
+ translation function because it is not needed.
+ * gstreamer/gstreamermm/wrap.h: Remove unneeded include.
+
2009-10-21 José Alburquerque <jaalburqu svn gnome org>
Fix the taglist test to fix the distcheck.
diff --git a/gstreamer/gstreamermm/miniobject.cc b/gstreamer/gstreamermm/miniobject.cc
index 03a4d68..8ff52fd 100644
--- a/gstreamer/gstreamermm/miniobject.cc
+++ b/gstreamer/gstreamermm/miniobject.cc
@@ -24,12 +24,35 @@
namespace Gst
{
+ /**** Gst::MiniObject_Class *********************************************/
+
+const Glib::Class& MiniObject_Class::init()
+{
+ if(!gtype_)
+ {
+ class_init_func_ = &MiniObject_Class::class_init_function;
+ register_derived_type(GST_TYPE_MINI_OBJECT);
+ }
+
+ 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*)
{}
+MiniObject* MiniObject_Class::wrap_new(GstMiniObject* object)
+{
+ return new MiniObject(object);
+}
+
+
+/**** Gst::MiniObject *****************************************************/
+
+// static data
+MiniObject::CppClassType MiniObject::mini_object_class_;
+
MiniObject::MiniObject()
: gobject_(0)
{}
@@ -38,16 +61,12 @@ MiniObject::MiniObject(GstMiniObject* castitem, bool take_copy)
: gobject_(take_copy ? gst_mini_object_copy(castitem) : castitem)
{}
-MiniObject::MiniObject(const MiniObject& other)
-: gobject_(gst_mini_object_copy(other.gobject_))
-{}
-
-MiniObject&
-MiniObject::operator=(const MiniObject& other)
+GstMiniObject* MiniObject::gobj_copy()
{
- MiniObject temp(other);
- swap(temp);
- return *this;
+ // Use the mini object copying function to get a copy of the underlying
+ // gobject instead of referencing and returning the underlying gobject as
+ // would be done normally:
+ return gst_mini_object_copy(gobj());
}
MiniObject::~MiniObject()
@@ -56,6 +75,16 @@ MiniObject::~MiniObject()
gst_mini_object_unref(gobject_);
}
+GType MiniObject::get_type()
+{
+ return mini_object_class_.init().get_type();
+}
+
+GType MiniObject::get_base_type()
+{
+ return GST_TYPE_MINI_OBJECT;
+}
+
void MiniObject::swap(MiniObject& other)
{
GstMiniObject *const temp = gobject_;
@@ -95,13 +124,6 @@ void MiniObject::unset_flag(guint flag)
GST_MINI_OBJECT_FLAG_UNSET(gobj(), flag);
}
-Glib::RefPtr<Gst::MiniObject>
-MiniObject::copy() const
-{
- GstMiniObject * copy = gst_mini_object_copy(gobject_);
- return Gst::wrap(copy, false);
-}
-
bool
MiniObject::is_writable() const
{
diff --git a/gstreamer/gstreamermm/miniobject.h b/gstreamer/gstreamermm/miniobject.h
index b3317e2..6495d88 100644
--- a/gstreamer/gstreamermm/miniobject.h
+++ b/gstreamer/gstreamermm/miniobject.h
@@ -20,8 +20,10 @@
#ifndef _GSTREAMERMM_MINIOBJECT_H
#define _GSTREAMERMM_MINIOBJECT_H
-#include <glibmm/refptr.h>
#include <gst/gstminiobject.h>
+#include <glibmm/refptr.h>
+#include <glibmm/value.h>
+#include <gstreamermm/wrap.h>
namespace Gst
{
@@ -41,6 +43,10 @@ public:
typedef GstMiniObjectClass BaseClassType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+private:
+ friend class MiniObject_Class;
+ static CppClassType mini_object_class_;
+
//protected:
public:
MiniObject();
@@ -49,24 +55,18 @@ public:
public:
virtual ~MiniObject();
+ #ifndef DOXYGEN_SHOULD_SKIP_THIS
+ static GType get_type() G_GNUC_CONST;
+ static GType get_base_type() G_GNUC_CONST;
+#endif
+
//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().
-//protected:
+private:
// noncopyable
- /** A copy constructor. Please note that copying is actually only supported
- * in sub-classes that define their own custom copy function in the C API
- * such as Gst::Event, Gst::Buffer, etc. otherwise the copy is not
- * successful and a warning is issued.
- */
MiniObject(const MiniObject&);
-
- /** Assignment operator. Please note that copying is actually only
- * supported in sub-classes that define their own custom copy function in
- * the C API such as Gst::Event, Gst::Buffer, etc. otherwise the copy
- * is not successful and a warning is issued.
- */
MiniObject& operator=(const MiniObject&);
public:
@@ -91,20 +91,6 @@ public:
*/
void unset_flag(guint flag);
- /** Creates a copy of the mini-object. Please note that copying is
- * supported only by sub-classes of Gst::MiniObject such as Gst::Event,
- * Gst::Buffer, etc. that define their own custom copy function in the C API
- * and not directly by Gst::MiniObject, a base class. If used from only a
- * Gst::MiniObject instance and not a sub-class instance the copy is not
- * successful and a warning is issued.
- *
- * MT safe.
- *
- * @return A copy of the mini-object or warn if this object is only a
- * Gst::MiniObject and not a sub-class that defines its own copy function.
- */
- Glib::RefPtr<Gst::MiniObject> copy() const;
-
/** Checks if a mini-object is writable. A mini-object is writable if the
* reference count is one and the Gst::MINI_OBJECT_FLAG_READONLY flag is not
* set. Modification of a mini-object should only be done after verifying
@@ -135,6 +121,8 @@ public:
///Provides access to the underlying C GstMiniObject.
const GstMiniObject* gobj() const { return reinterpret_cast<GstMiniObject*>(gobject_); }
+ ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
+ GstMiniObject* gobj_copy();
// static void replace(Glib::RefPtr<Gst::MiniObject> & olddata, Glib::RefPtr<Gst::MiniObject> & newdata);
@@ -147,4 +135,31 @@ protected:
} // namespace Gst
-#endif //#ifndef _GSTREAMERMM_MINIOBJECT_H
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+namespace Glib
+{
+
+template <>
+class Value< Glib::RefPtr<Gst::MiniObject> > : public ValueBase
+{
+public:
+ static GType value_type()
+ {
+ return Gst::MiniObject::get_type();
+ }
+
+ void set(const Glib::RefPtr<Gst::MiniObject>& object)
+ {
+ g_value_set_pointer(&gobject_, Gst::unwrap(object));
+ }
+
+ Glib::RefPtr<Gst::MiniObject> get()
+ {
+ return Glib::RefPtr<Gst::MiniObject>(Gst::wrap_auto(static_cast<GstMiniObject*>(g_value_get_pointer(&gobject_)), true));
+ }
+};
+
+} // namespace Glib
+#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+#endif // #ifndef _GSTREAMERMM_MINIOBJECT_H
diff --git a/gstreamer/gstreamermm/private/miniobject_p.h b/gstreamer/gstreamermm/private/miniobject_p.h
index 707a875..ba0ae38 100644
--- a/gstreamer/gstreamermm/private/miniobject_p.h
+++ b/gstreamer/gstreamermm/private/miniobject_p.h
@@ -37,6 +37,8 @@ public:
const Glib::Class& init();
static void class_init_function(void* g_class, void* class_data);
+
+ static Gst::MiniObject* wrap_new(GstMiniObject*);
};
diff --git a/gstreamer/gstreamermm/wrap.h b/gstreamer/gstreamermm/wrap.h
index 42d275f..d682e74 100644
--- a/gstreamer/gstreamermm/wrap.h
+++ b/gstreamer/gstreamermm/wrap.h
@@ -24,7 +24,6 @@
#include <gst/gstminiobject.h>
#include <glibmm/refptr.h>
-#include <gstreamermm/miniobject.h>
namespace Gst
{
diff --git a/gstreamer/src/event.ccg b/gstreamer/src/event.ccg
index 578e16e..21302e2 100644
--- a/gstreamer/src/event.ccg
+++ b/gstreamer/src/event.ccg
@@ -45,11 +45,6 @@ EventTypeFlags get_flags(EventType t)
} //namespace Enums
-Glib::RefPtr<Gst::Event> Event::copy() const
-{
- return Gst::wrap(gst_event_copy(gobj()));
-}
-
Glib::RefPtr<Gst::Event> Event::create_writable()
{
return
diff --git a/gstreamer/src/event.hg b/gstreamer/src/event.hg
index 391ebd5..4ab6627 100644
--- a/gstreamer/src/event.hg
+++ b/gstreamer/src/event.hg
@@ -18,6 +18,7 @@
*/
#include <gst/gstevent.h>
+#include <gstreamermm/miniobject.h>
#include <gstreamermm/wrap.h>
#include <gstreamermm/format.h>
#include <gstreamermm/clock.h>
@@ -127,11 +128,6 @@ public:
*/
static Glib::RefPtr<Gst::Event> wrap(GstEvent* event, bool take_copy=false);
- /** Copy the event using the event specific copy function.
- * @return The Gst::Event copy.
- */
- Glib::RefPtr<Gst::Event> copy() const;
-
// A copy is taken so that the original is not freed by the wrapper.
#m4 _CONVERSION(`const GstStructure*',`const Gst::Structure',`Glib::wrap(const_cast<GstStructure*>($3), true)')
_WRAP_METHOD(const Gst::Structure get_structure() const, gst_event_get_structure)
diff --git a/gstreamer/src/message.ccg b/gstreamer/src/message.ccg
index 9d71f65..c0f64b1 100644
--- a/gstreamer/src/message.ccg
+++ b/gstreamer/src/message.ccg
@@ -44,11 +44,6 @@ Glib::QueryQuark get_quark(MessageType t)
} //namespace Enums
-Glib::RefPtr<Gst::Message> Message::copy() const
-{
- return Gst::wrap(gst_message_copy(gobj()));
-}
-
Glib::RefPtr<Gst::Message> Message::create_writable()
{
return Gst::wrap(gst_message_make_writable(gobj()));
diff --git a/gstreamer/src/message.hg b/gstreamer/src/message.hg
index 351f8bb..1299c04 100644
--- a/gstreamer/src/message.hg
+++ b/gstreamer/src/message.hg
@@ -18,6 +18,7 @@
*/
#include <gst/gstmessage.h>
+#include <gstreamermm/miniobject.h>
#include <gstreamermm/wrap.h>
#include <gstreamermm/format.h>
#include <gstreamermm/clock.h>
@@ -83,11 +84,6 @@ public:
*/
static Glib::RefPtr<Gst::Message> wrap(GstMessage* message, bool take_copy=false);
- /** Creates a copy of the message. MT safe.
- * @return A copy of the message.
- */
- Glib::RefPtr<Gst::Message> copy() const;
-
// A copy is taken so that the original is not freed by the wrapper.
#m4 _CONVERSION(`const GstStructure*',`const Gst::Structure',`Glib::wrap(const_cast<GstStructure*>($3), true)')
_WRAP_METHOD(const Gst::Structure get_structure() const, gst_message_get_structure)
diff --git a/gstreamer/src/query.ccg b/gstreamer/src/query.ccg
index a6b89eb..1091707 100644
--- a/gstreamer/src/query.ccg
+++ b/gstreamer/src/query.ccg
@@ -57,11 +57,6 @@ Glib::QueryQuark get_quark(QueryType t)
} //namespace Enums
-Glib::RefPtr<Gst::Query> Query::copy() const
-{
- return Gst::wrap(gst_query_copy(gobj()));
-}
-
Glib::RefPtr<Gst::Query> Query::create_writable()
{
return Gst::wrap(gst_query_make_writable(gobj()));
diff --git a/gstreamer/src/query.hg b/gstreamer/src/query.hg
index 2011589..3c4848c 100644
--- a/gstreamer/src/query.hg
+++ b/gstreamer/src/query.hg
@@ -120,11 +120,6 @@ public:
*/
static Glib::RefPtr<Gst::Query> wrap(GstQuery* query, bool take_copy=false);
- /** Copies the given query using the query copy function.
- * @return The Gst::Query copy.
- */
- Glib::RefPtr<Gst::Query> copy() const;
-
/** Makes a writable query from the given query. Does exactly what
* Gst::MiniObject::create_writable() does for the Gst::Query.
* @return A Gst::Query (possibly the same pointer) that is writable.
diff --git a/gstreamer/src/structure.ccg b/gstreamer/src/structure.ccg
index e739023..4177cae 100644
--- a/gstreamer/src/structure.ccg
+++ b/gstreamer/src/structure.ccg
@@ -254,14 +254,6 @@ void Structure::_set_gstructure_field(GstStructure* cstructure, const Glib::ustr
gst_structure_set(cstructure, fieldname.c_str(), GST_TYPE_STRUCTURE,
obj->get().gobj(), (void*)0);
}
- else if(type == Glib::Value<MiniObject>::value_type())
- {
- const Glib::Value<MiniObject>* obj =
- static_cast< const Glib::Value<MiniObject>* >(&value);
-
- gst_structure_set(cstructure, fieldname.c_str(), GST_TYPE_MINI_OBJECT,
- obj->get().gobj(), (void*)0);
- }
else
{
gst_structure_set_value(cstructure, fieldname.c_str(), value.gobj());
diff --git a/tools/m4/class_gstminiobject.m4 b/tools/m4/class_gstminiobject.m4
index e7a60e9..23d126d 100644
--- a/tools/m4/class_gstminiobject.m4
+++ b/tools/m4/class_gstminiobject.m4
@@ -184,8 +184,10 @@ Gst::MiniObject* __CPPNAME__`'_Class::wrap_new(GstMiniObject* object)
__CNAME__* __CPPNAME__::gobj_copy()
{
- reference();
- return gobj();
+ // Use the mini object copying function to get a copy of the underlying
+ // gobject instead of referencing and returning the underlying gobject as
+ // would be done normally:
+ return reinterpret_cast<__CNAME__*>(gst_mini_object_copy(reinterpret_cast<GstMiniObject*>(gobj())));
}
@@ -227,7 +229,8 @@ public:
m4_ifdef(`__BOOL_PROTECTED_GCLASS__',
`protected:',`dnl else
-private:')dnl endif
+private:
+')dnl endif
friend class __CPPNAME__`'_Class;
static CppClassType `'__BASE__`'_class_;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]