| 1 |
/* gstreamermm - a C++ wrapper for gstreamer |
| 2 |
* |
| 3 |
* Copyright 2008 The gstreamermm Development Team |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free |
| 17 |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef REGISTER_H_ |
| 21 |
#define REGISTER_H_cxx . . $ `gstreamer/gstreamermm/register.h:21:9`! |
| 22 |
|
| 23 |
#include <glib-object.h> |
| 24 |
#include <glibmm/property.h> |
| 25 |
#include <glibmm/init.h> |
| 26 |
#include <gstreamermm/padtemplate.h>cxx . . $ `<file>/gstreamer/gstreamermm/padtemplate.h`/ |
| 27 |
|
| 28 |
namespace Gstcxx . . $ Gst/ |
| 29 |
{ |
| 30 |
|
| 31 |
template<class DerivedCppType> |
| 32 |
static GType |
| 33 |
register_mm_typecxx . . $ Gst/register_mm_type(751346f8406fd082).(const gchar * type_name=typeid(DerivedCppType).namecxx . . $ std/type_info#name(a9f41ea0e82d88cf).()); |
| 34 |
|
| 35 |
template<typename DerivedCppType> |
| 36 |
class ElementClasscxx . . $ Gst/ElementClass# |
| 37 |
{ |
| 38 |
friend GType register_mm_typecxx . . $ Gst/register_mm_type(751346f8406fd082).<DerivedCppType>(const gchar * type_name); |
| 39 |
GstElementClasscxx . . $ GstElementClass#* klasscxx . . $ Gst/ElementClass#klass.; |
| 40 |
ElementClasscxx . . $ Gst/ElementClass#`ElementClass<DerivedCppType>`(cb905a108c17f862).(typename DerivedCppType::BaseClassType* klass): klasscxx . . $ Gst/ElementClass#klass.((GstElementClasscxx . . $ GstElementClass#*) klass){} |
| 41 |
ElementClasscxx . . $ Gst/ElementClass#`ElementClass<DerivedCppType>`(fd070da0678858a0).(ElementClass const&); |
| 42 |
void operatorcxx . . $ Gst/ElementClass#`operator=`(fd070da0678858a0).=(ElementClass const&); |
| 43 |
public: |
| 44 |
void add_pad_templatecxx . . $ Gst/ElementClass#add_pad_template(dc732e5c6b9f3e94).(const Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::PadTemplatecxx . . $ Gst/PadTemplate#>& tpl) |
| 45 |
{ |
| 46 |
gst_element_class_add_pad_template(klasscxx . . $ Gst/ElementClass#klass., tpl->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).gobjcxx . . $ Gst/PadTemplate#gobj(a178b52555038b7a).()); |
| 47 |
} |
| 48 |
void set_metadatacxx . . $ Gst/ElementClass#set_metadata(998bbdab478bd19e).(const Glibcxx . . $ Glib/::ustringcxx . . $ Glib/ustring#& longname, const Glibcxx . . $ Glib/::ustringcxx . . $ Glib/ustring#& classification, |
| 49 |
const Glibcxx . . $ Glib/::ustringcxx . . $ Glib/ustring#& description, const Glibcxx . . $ Glib/::ustringcxx . . $ Glib/ustring#& author) |
| 50 |
{ |
| 51 |
gst_element_class_set_metadata(klasscxx . . $ Gst/ElementClass#klass., longname.c_strcxx . . $ Glib/ustring#c_str(a9f41ea0e82d88cf).(), classification.c_strcxx . . $ Glib/ustring#c_str(a9f41ea0e82d88cf).(), description.c_strcxx . . $ Glib/ustring#c_str(a9f41ea0e82d88cf).(), author.c_strcxx . . $ Glib/ustring#c_str(a9f41ea0e82d88cf).()); |
| 52 |
} |
| 53 |
|
| 54 |
void add_metadatacxx . . $ Gst/ElementClass#add_metadata(a774a3a463cfc512).(const Glibcxx . . $ Glib/::ustringcxx . . $ Glib/ustring#& key, const Glibcxx . . $ Glib/::ustringcxx . . $ Glib/ustring#& value) |
| 55 |
{ |
| 56 |
gst_element_class_add_metadata(klasscxx . . $ Gst/ElementClass#klass. ,key.c_strcxx . . $ Glib/ustring#c_str(a9f41ea0e82d88cf).(), value.c_strcxx . . $ Glib/ustring#c_str(a9f41ea0e82d88cf).()); |
| 57 |
} |
| 58 |
|
| 59 |
const GstElementClasscxx . . $ GstElementClass#* gobjcxx . . $ Gst/ElementClass#gobj(3df7b81df716a552).() const { return klasscxx . . $ Gst/ElementClass#klass.; } |
| 60 |
GstElementClasscxx . . $ GstElementClass#* gobjcxx . . $ Gst/ElementClass#gobj(336a6033d3ec69ec).() { return klasscxx . . $ Gst/ElementClass#klass.; } |
| 61 |
}; |
| 62 |
|
| 63 |
template<class DerivedCppType> |
| 64 |
static GType |
| 65 |
register_mm_typecxx . . $ Gst/register_mm_type(751346f8406fd082).(const gchar * type_name) |
| 66 |
{ |
| 67 |
struct GlibCppTypecxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType# |
| 68 |
{ |
| 69 |
typename DerivedCppType::BaseObjectType parentcxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType#parent.; |
| 70 |
DerivedCppType *selfcxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType#self.; |
| 71 |
static void initcxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType#init(6649e245d0e835bd).(GlibCppTypecxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType# *instance, gpointer /* g_class */) |
| 72 |
{ |
| 73 |
//instance->parent will be passed to C++ base of DerivedCppType; this will cause registerging "self" as MM wrapper of "parent" |
| 74 |
Gstcxx . . $ Gst/::initcxx . . $ Gst/init(49f6e7a06ebc5aa8).(); |
| 75 |
instance->selfcxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType#self. = new DerivedCppType(&cxx . . $ Gst/`operator&`(db1cd79346e0d415).instance->parentcxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType#parent.); |
| 76 |
} |
| 77 |
|
| 78 |
static void finalizecxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType#finalize(6087475fa43034d3).(GObjectcxx . . $ GObject# *object) |
| 79 |
{ |
| 80 |
//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". |
| 81 |
(G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`!(g_type_class_peek_parent(G_OBJECT_GET_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:89:9`!(object))))->finalizecxx . . $ _GObjectClass#finalize.(object); |
| 82 |
} |
| 83 |
}; |
| 84 |
|
| 85 |
struct GlibCppTypeClasscxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppTypeClass# |
| 86 |
{ |
| 87 |
typename DerivedCppType::BaseClassType parent_classcxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppTypeClass#parent_class.; |
| 88 |
/* nothing more */ |
| 89 |
static void initcxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppTypeClass#init(aa65f1eb71aa6eef). (GlibCppTypeClasscxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppTypeClass# * klass, gpointer data) |
| 90 |
{ |
| 91 |
DerivedCppType::CppClassType::class_init_function((void*)klass, (void*)data); |
| 92 |
GObjectClass *gobject_class; |
| 93 |
|
| 94 |
gobject_class = (GObjectClass *) klass; |
| 95 |
|
| 96 |
gobject_class->get_propertycxx . . $ _GObjectClass#get_property. = &Glibcxx . . $ Glib/::custom_get_property_callbackcxx . . $ Glib/custom_get_property_callback(cee2c52f22407c66).; |
| 97 |
gobject_class->set_propertycxx . . $ _GObjectClass#set_property. = &Glibcxx . . $ Glib/::custom_set_property_callbackcxx . . $ Glib/custom_set_property_callback(d7c4bb29f36c0dc4).; |
| 98 |
gobject_class->finalizecxx . . $ _GObjectClass#finalize. = &cxx . . $ Gst/`operator&`(db1cd79346e0d415).GlibCppTypecxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType#::finalize; |
| 99 |
|
| 100 |
Gstcxx . . $ Gst/::ElementClasscxx . . $ Gst/ElementClass#<DerivedCppType> element_class((typename DerivedCppType::BaseClassType*) klass); |
| 101 |
DerivedCppType::class_init(&cxx . . $ Gst/`operator&`(db1cd79346e0d415).element_class); |
| 102 |
} |
| 103 |
}; |
| 104 |
|
| 105 |
Glibcxx . . $ Glib/::initcxx . . $ Glib/init(49f6e7a06ebc5aa8).(); |
| 106 |
|
| 107 |
// the "most derived" pure glib type |
| 108 |
GType parent_type = DerivedCppType::get_base_type(); |
| 109 |
|
| 110 |
/* The typedef for GType may be gulong or gsize, depending on the |
| 111 |
* system and whether the compiler is c++ or not. The g_once_init_* |
| 112 |
* functions always take a gsize * though ... */ |
| •113 |
static gsize gonce_data = 0; |
| 114 |
if (g_once_init_entercxx . . $ `<external>/457917468643292165/gthread.h:270:10`! (&gonce_data)) { |
| 115 |
GTypeInfo info; |
| 116 |
|
| 117 |
info.class_sizecxx . . $ _GTypeInfo#class_size. = sizeof(GlibCppTypeClasscxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppTypeClass#); |
| 118 |
info.base_initcxx . . $ _GTypeInfo#base_init. = nullptr; |
| 119 |
info.base_finalizecxx . . $ _GTypeInfo#base_finalize. = nullptr; |
| 120 |
info.class_initcxx . . $ _GTypeInfo#class_init. = (GClassInitFunc) &cxx . . $ Gst/`operator&`(db1cd79346e0d415).GlibCppTypeClasscxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppTypeClass#::init; |
| 121 |
info.class_finalizecxx . . $ _GTypeInfo#class_finalize. = nullptr; |
| 122 |
info.class_datacxx . . $ _GTypeInfo#class_data. = nullptr; |
| 123 |
info.instance_sizecxx . . $ _GTypeInfo#instance_size. = sizeof(GlibCppTypecxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType#); |
| 124 |
info.n_preallocscxx . . $ _GTypeInfo#n_preallocs. = 0; |
| 125 |
info.instance_initcxx . . $ _GTypeInfo#instance_init. = (GInstanceInitFunc) &cxx . . $ Gst/`operator&`(db1cd79346e0d415).GlibCppTypecxx . . $ Gst/register_mm_type(751346f8406fd082).GlibCppType#::init; |
| 126 |
info.value_tablecxx . . $ _GTypeInfo#value_table. = nullptr; |
| 127 |
|
| 128 |
GType _type = g_type_register_static(parent_type, type_name, &info, (GTypeFlags)0); |
| 129 |
g_once_init_leavecxx . . $ `<external>/457917468643292165/gthread.h:277:10`!(&gonce_data, (gsize) _type); |
| 130 |
} |
| 131 |
return (GType) gonce_data; |
| 132 |
} |
| 133 |
|
| 134 |
} /*namespace Gst*/ |
| 135 |
|
| 136 |
|
| 137 |
#endif /* REGISTER_H_ */ |