Debian Codegraph @

gstreamer/src/preset.ccg

raw
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2008-2016 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 namespace Gst
21 {
22
23 bool Preset::get_meta(const Glib::ustring& name, const Glib::ustring& tag,
24 Glib::ustring& value) const
25 {
26 gchar* meta = nullptr;
27
28 gboolean result = gst_preset_get_meta(const_cast<GstPreset*>(gobj()),
29 name.c_str(), tag.c_str(), &meta);
30 value = meta;
31 g_free(meta);
32 return result;
33 }
34
35 gchar** Preset_Class::get_preset_names_vfunc_callback(GstPreset* self)
36 {
37 Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
38 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
39
40 // Non-gtkmmproc-generated custom classes implicitly call the default
41 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
42 // generated classes can use this optimisation, which avoids the unnecessary
43 // parameter conversions if there is no possibility of the virtual function
44 // being overridden:
45 if(obj_base && obj_base->is_derived_())
46 {
47 CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
48 if(obj) // This can be NULL during destruction.
49 {
50 try // Trap C++ exceptions which would normally be lost because this is a C callback.
51 {
52 // Call the virtual member method, which derived classes might override.
53 return const_cast<gchar**>((obj->get_preset_names_vfunc()).data());
54 }
55 catch(...)
56 {
57 Glib::exception_handlers_invoke();
58 }
59 }
60 }
61
62 BaseClassType *const base = static_cast<BaseClassType*>(
63 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
64 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
65 ) );
66
67 // Call the original underlying C function:
68 if(base && base->get_preset_names)
69 return (*base->get_preset_names)(self);
70
71
72 typedef gchar** RType;
73 return RType();
74 }
75 gchar** Preset_Class::get_property_names_vfunc_callback(GstPreset* self)
76 {
77 Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
78 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
79
80 // Non-gtkmmproc-generated custom classes implicitly call the default
81 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
82 // generated classes can use this optimisation, which avoids the unnecessary
83 // parameter conversions if there is no possibility of the virtual function
84 // being overridden:
85 if(obj_base && obj_base->is_derived_())
86 {
87 CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
88 if(obj) // This can be NULL during destruction.
89 {
90 try // Trap C++ exceptions which would normally be lost because this is a C callback.
91 {
92 // Call the virtual member method, which derived classes might override.
93 return const_cast<gchar**>((obj->get_property_names_vfunc()).data());
94 }
95 catch(...)
96 {
97 Glib::exception_handlers_invoke();
98 }
99 }
100 }
101
102 BaseClassType *const base = static_cast<BaseClassType*>(
103 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
104 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
105 ) );
106
107 // Call the original underlying C function:
108 if(base && base->get_property_names)
109 return (*base->get_property_names)(self);
110
111
112 typedef gchar** RType;
113 return RType();
114 }
115 gboolean Preset_Class::get_meta_vfunc_callback(GstPreset* self, const gchar* name, const gchar* tag, gchar** value)
116 {
117 Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
118 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
119
120 // Non-gtkmmproc-generated custom classes implicitly call the default
121 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
122 // generated classes can use this optimisation, which avoids the unnecessary
123 // parameter conversions if there is no possibility of the virtual function
124 // being overridden:
125 if(obj_base && obj_base->is_derived_())
126 {
127 CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
128 if(obj) // This can be NULL during destruction.
129 {
130 try // Trap C++ exceptions which would normally be lost because this is a C callback.
131 {
132 Glib::ustring cpp_value;
133 // Call the virtual member method, which derived classes might override.
134 const gboolean result = static_cast<int>(obj->get_meta_vfunc(Glib::convert_const_gchar_ptr_to_ustring(name)
135 , Glib::convert_const_gchar_ptr_to_ustring(tag) , cpp_value));
136 *value = g_strdup(cpp_value.c_str());
137 return result;
138 }
139 catch(...)
140 {
141 Glib::exception_handlers_invoke();
142 }
143 }
144 }
145
146 BaseClassType *const base = static_cast<BaseClassType*>(
147 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
148 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
149 ) );
150
151 // Call the original underlying C function:
152 if(base && base->get_meta)
153 return (*base->get_meta)(self, name, tag, value);
154
155
156 typedef gboolean RType;
157 return RType();
158 }
159 Glib::StringArrayHandle Gst::Preset::get_preset_names_vfunc() const
160 {
161 BaseClassType *const base = static_cast<BaseClassType*>(
162 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
163 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
164 ) );
165
166 if(base && base->get_preset_names)
167 return Glib::StringArrayHandle((*base->get_preset_names)(const_cast<GstPreset*>(gobj())), Glib::OWNERSHIP_DEEP);
168
169 return Glib::StringArrayHandle(nullptr, Glib::OWNERSHIP_NONE);
170 }
171 Glib::StringArrayHandle Gst::Preset::get_property_names_vfunc() const
172 {
173 BaseClassType *const base = static_cast<BaseClassType*>(
174 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
175 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
176 ) );
177
178 if(base && base->get_property_names)
179 return Glib::StringArrayHandle((*base->get_property_names)(const_cast<GstPreset*>(gobj())), Glib::OWNERSHIP_DEEP);
180
181 return Glib::StringArrayHandle(nullptr, Glib::OWNERSHIP_NONE);
182 }
183 bool Gst::Preset::get_meta_vfunc(const Glib::ustring& name,
184 const Glib::ustring& tag, Glib::ustring& value) const
185 {
186 BaseClassType *const base = static_cast<BaseClassType*>(
187 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
188 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
189 ) );
190
191 if(base && base->get_meta)
192 {
193 gchar* gst_value;
194 const bool result = (*base->get_meta)(const_cast<GstPreset*>(gobj()),((name).c_str()),((tag).c_str()), &gst_value);
195 value = gst_value;
196 g_free(gst_value);
197 return result;
198 }
199
200 typedef bool RType;
201 return RType();
202 }
203
204 }