Commit 902757b4 authored by Marcin Kolny's avatar Marcin Kolny

register.h: move code from base_init to class_init

parent 9f19e828
......@@ -22,6 +22,7 @@
#include <glib-object.h>
#include <glibmm/property.h>
#include <glibmm/init.h>
#include <gstreamermm/padtemplate.h>
namespace Gst
......@@ -36,7 +37,7 @@ class ElementClass
{
friend GType register_mm_type<DerivedCppType>(const gchar * type_name);
GstElementClass* klass;
ElementClass(typename DerivedCppType::BaseClassType* klass): klass((GstElementClass*)klass){}
ElementClass(typename DerivedCppType::BaseClassType* klass): klass((GstElementClass*) klass){}
ElementClass(ElementClass const&);
void operator=(ElementClass const&);
public:
......@@ -70,14 +71,10 @@ register_mm_type(const gchar * type_name)
static void init(GlibCppType *instance, gpointer /* g_class */)
{
//instance->parent will be passed to C++ base of DerivedCppType; this will cause registerging "self" as MM wrapper of "parent"
Gst::init();
instance->self = new DerivedCppType(&instance->parent);
}
static void base_init(typename DerivedCppType::BaseClassType *klass)
{
Gst::ElementClass<DerivedCppType> element_class(klass);
DerivedCppType::base_init(&element_class);
}
static void finalize(GObject *object)
{
//the following will destroy q_data, among which MM wrapper to this "object" is stored. This will cause implicit delete on "self", since it is registered as wrapper of "object".
......@@ -95,19 +92,18 @@ register_mm_type(const gchar * type_name)
GObjectClass *gobject_class;
gobject_class = (GObjectClass *) klass;
// gstelement_class = (GstElementClass *) klass;
gobject_class->get_property = &Glib::custom_get_property_callback;
gobject_class->set_property = &Glib::custom_set_property_callback;
gobject_class->finalize = &GlibCppType::finalize;
}
static void base_init(typename DerivedCppType::BaseClassType * /* klass */)
{
Gst::init();
Gst::ElementClass<DerivedCppType> element_class((typename DerivedCppType::BaseClassType*) klass);
DerivedCppType::class_init(&element_class);
}
};
Glib::init();
// the "most derived" pure glib type
GType parent_type = DerivedCppType::get_base_type();
......@@ -119,7 +115,7 @@ register_mm_type(const gchar * type_name)
GTypeInfo info;
info.class_size = sizeof(GlibCppTypeClass);
info.base_init = (GBaseInitFunc)&GlibCppType::base_init;
info.base_init = nullptr;
info.base_finalize = nullptr;
info.class_init = (GClassInitFunc) &GlibCppTypeClass::init;
info.class_finalize = nullptr;
......
......@@ -9,7 +9,7 @@
class DerivedFromAppSink : public Gst::AppSink
{
public:
static void base_init(Gst::ElementClass<DerivedFromAppSink> *klass)
static void class_init(Gst::ElementClass<DerivedFromAppSink> *klass)
{
klass->set_metadata("derivedfromappsink_longname",
"derivedfromappsink_classification", "derivedfromappsink_detail_description", "derivedfromappsink_detail_author");
......
......@@ -9,7 +9,7 @@
class DerivedFromAppSrc : public Gst::AppSrc
{
public:
static void base_init(Gst::ElementClass<DerivedFromAppSrc> *klass)
static void class_init(Gst::ElementClass<DerivedFromAppSrc> *klass)
{
klass->set_metadata("derivedfromappsrc_longname",
"derivedfromappsrc_classification", "derivedfromappsrc_detail_description", "derivedfromappsrc_detail_author");
......
......@@ -8,7 +8,7 @@
class DerivedFromBaseTransform : public Gst::BaseTransform
{
public:
static void base_init(Gst::ElementClass<DerivedFromBaseTransform> *klass)
static void class_init(Gst::ElementClass<DerivedFromBaseTransform> *klass)
{
klass->set_metadata("derivedfrombasetransform_longname",
"derivedfrombasetransform_classification", "derivedfrombasetransform_detail_description", "derivedfrombasetransform_detail_author");
......
......@@ -19,7 +19,7 @@ class Foo : public Gst::Element
Glib::Property<Glib::ustring> sample_property;
public:
static void base_init(Gst::ElementClass<Foo> *klass)
static void class_init(Gst::ElementClass<Foo> *klass)
{
klass->set_metadata("foo_longname",
"foo_classification", "foo_detail_description", "foo_detail_author");
......
......@@ -20,7 +20,7 @@ class FooSrc : public Gst::PushSrc
public:
static const int COUNT = 5;
static void base_init(Gst::ElementClass<FooSrc> *klass)
static void class_init(Gst::ElementClass<FooSrc> *klass)
{
klass->set_metadata("foosrc_longname",
"foosrc_classification", "foosrc_detail_description", "foosrc_detail_author");
......
......@@ -23,7 +23,7 @@ private:
Glib::Property<Glib::ustring> location;
public:
static void base_init(Gst::ElementClass<PluginBin> *klass)
static void class_init(Gst::ElementClass<PluginBin> *klass)
{
klass->set_metadata("Custom test bin", "test/bins", "test bin", "author");
}
......
......@@ -22,7 +22,7 @@ public:
return Element::get_base_type();
}
static void base_init(Gst::ElementClass<UriTestElement> *klass)
static void class_init(Gst::ElementClass<UriTestElement> *klass)
{
klass->set_metadata("uri_longname", "uri_classification",
"uri_detail_description", "uri_detail_author");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment