Debian Codegraph @

gstreamer/gstreamermm/allocator.h

raw symbols SCIP
1 // Generated by gmmproc 2.50.1 -- DO NOT MODIFY!
2 #ifndef _GSTREAMERMM_ALLOCATOR_H
3 #define _GSTREAMERMM_ALLOCATOR_H
4
5
6 #include <glibmm/ustring.h>
7 #include <sigc++/sigc++.h>
8
9 /* gstreamermm - a C++ wrapper for gstreamer
10 *
11 * Copyright 2014-2016 The gstreamermm Development Team
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 * Last reviewed on 2016-04-22 (1.8.0)
28 */
29
30 #include <gstreamermm/object.h>
31 #include <gstreamermm/memory.h>
32
33
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 extern "C" { typedef struct _GstAllocationParams GstAllocationParams; }
36 #endif
37
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 using GstAllocator = struct _GstAllocator;
40 using GstAllocatorClass = struct _GstAllocatorClass;
41 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
42
43
44 #ifndef DOXYGEN_SHOULD_SKIP_THIS
45 namespace Gst
46 { class Allocator_Class; } // namespace Gst
47 #endif //DOXYGEN_SHOULD_SKIP_THIS
48
49 namespace Gst
50 {
51
52 /** Parameters to control the allocation of memory.
53 */
54 class AllocationParams
55 {
56 public:
57 #ifndef DOXYGEN_SHOULD_SKIP_THIS
58 using CppObjectType = AllocationParams;
59 using BaseObjectType = GstAllocationParams;
60 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
61
62 /** Get the GType for this class, for use with the underlying GObject type system.
63 */
64 static GType get_type() G_GNUC_CONST;
65
66
67 explicit AllocationParams(GstAllocationParams* gobject, bool make_a_copy = true);
68
69 AllocationParams(const AllocationParams& other);
70 AllocationParams& operator=(const AllocationParams& other);
71
72 AllocationParams(AllocationParams&& other) noexcept;
73 AllocationParams& operator=(AllocationParams&& other) noexcept;
74
75 ~AllocationParams() noexcept;
76
77 void swap(AllocationParams& other) noexcept;
78
79 ///Provides access to the underlying C instance.
80 GstAllocationParams* gobj() { return gobject_; }
81
82 ///Provides access to the underlying C instance.
83 const GstAllocationParams* gobj() const { return gobject_; }
84
85 ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
86 GstAllocationParams* gobj_copy() const;
87
88 protected:
89 GstAllocationParams* gobject_;
90
91 private:
92
93
94 public:
95
96
97 AllocationParams();
98
99
100 /** Initialize @a params to its default values
101 */
102 void init();
103
104 MemoryFlags get_flags() const;
105 void set_flags(const MemoryFlags& value);
106
107 gsize get_align() const;
108 void set_align(const gsize& value);
109
110 gsize get_prefix() const;
111 void set_prefix(const gsize& value);
112
113 gsize get_padding() const;
114 void set_padding(const gsize& value);
115
116
117 };
118
119 /** Allocate memory blocks.
120 *
121 * Memory is usually created by allocators with a alloc()
122 * method call. When nullptr is used as the allocator, the default allocator will
123 * be used.
124 *
125 * New allocators can be registered with register_allocator().
126 * Allocators are identified by name and can be retrieved with
127 * find(). set_default() can be used to change the
128 * default allocator.
129 */
130
131
132 class Allocator : public Gst::Object
133 {
134
135 #ifndef DOXYGEN_SHOULD_SKIP_THIS
136
137 public:
138 using CppObjectType = Allocator;
139 using CppClassType = Allocator_Class;
140 using BaseObjectType = GstAllocator;
141 using BaseClassType = GstAllocatorClass;
142
143 // noncopyable
144 Allocator(const Allocator&) = delete;
145 Allocator& operator=(const Allocator&) = delete;
146
147 private: friend class Allocator_Class;
148 static CppClassType allocator_class_;
149
150 protected:
151 explicit Allocator(const Glib::ConstructParams& construct_params);
152 explicit Allocator(GstAllocator* castitem);
153
154 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
155
156 public:
157
158 Allocator(Allocator&& src) noexcept;
159 Allocator& operator=(Allocator&& src) noexcept;
160
161 ~Allocator() noexcept override;
162
163 /** Get the GType for this class, for use with the underlying GObject type system.
164 */
165 static GType get_type() G_GNUC_CONST;
166
167 #ifndef DOXYGEN_SHOULD_SKIP_THIS
168
169
170 static GType get_base_type() G_GNUC_CONST;
171 #endif
172
173 ///Provides access to the underlying C GObject.
174 GstAllocator* gobj() { return reinterpret_cast<GstAllocator*>(gobject_); }
175
176 ///Provides access to the underlying C GObject.
177 const GstAllocator* gobj() const { return reinterpret_cast<GstAllocator*>(gobject_); }
178
179 ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
180 GstAllocator* gobj_copy();
181
182 private:
183
184
185 public:
186
187 /** Find a previously registered allocator with @a name. When @a name is <tt>nullptr</tt>, the
188 * default allocator will be returned.
189 *
190 * @param name The name of the allocator.
191 * @return A Gst::Allocator or <tt>nullptr</tt> when
192 * the allocator with @a name was not registered. Use Gst::Object::unref()
193 * to release the allocator after usage.
194 */
195 static Glib::RefPtr<Gst::Allocator> find(const Glib::ustring& name);
196
197 /** Registers the memory @a allocator with @a name. This function takes ownership of
198 * @a allocator.
199 *
200 * @param name The name of the allocator.
201 * @param allocator Gst::Allocator.
202 */
203 static void register_allocator(const Glib::ustring& name, Glib::RefPtr<Gst::Allocator>&& allocator);
204
205 /** Free @a memory that was previously allocated with alloc().
206 *
207 * @param memory The memory to free.
208 */
209 void free(Glib::RefPtr<Gst::Memory>&& memory);
210
211 /** Use @a allocator to allocate a new memory block with memory that is at least
212 * @a size big.
213 *
214 * The optional @a params can specify the prefix and padding for the memory. If
215 * <tt>nullptr</tt> is passed, no flags, no extra prefix/padding and a default alignment is
216 * used.
217 *
218 * The prefix/padding will be filled with 0 if flags contains
219 * Gst::MEMORY_FLAG_ZERO_PREFIXED and Gst::MEMORY_FLAG_ZERO_PADDED respectively.
220 *
221 * When @a allocator is <tt>nullptr</tt>, the default allocator will be used.
222 *
223 * The alignment in @a params is given as a bitmask so that @a align + 1 equals
224 * the amount of bytes to align to. For example, to align to 8 bytes,
225 * use an alignment of 7.
226 *
227 * @param size Size of the visible memory area.
228 * @param params Optional parameters.
229 * @return A new Gst::Memory.
230 */
231 Glib::RefPtr<Gst::Memory> alloc(gsize size, const Gst::AllocationParams& params);
232
233 /// A alloc() convenience overload.
234 Glib::RefPtr<Gst::Memory> alloc(gsize size);
235
236
237 /** Set the default allocator. This function takes ownership of @a allocator.
238 */
239
240 void set_default();
241
242 /**
243 * Find default allocator.
244 *
245 * @return: default allocator.
246 */
247 static Glib::RefPtr<Gst::Allocator> get_default_allocator();
248
249 virtual Glib::RefPtr<Gst::Memory> alloc_vfunc(gsize size, const Gst::AllocationParams& params);
250
251
252 // This vfunc is hand-coded because it takes reference to a memory.
253 // In generally, arguments are passed to a function by copy, so
254 // custom wrapper is necessary.
255 virtual void free_vfunc(Glib::RefPtr<Gst::Memory>&& memory);
256
257 protected:
258
259
260 public:
261
262 public:
263 //C++ methods used to invoke GTK+ virtual functions:
264
265 protected:
266 //GTK+ Virtual Functions (override these to change behaviour):
267
268 //Default Signal Handlers::
269
270
271 };
272 }
273
274
275 namespace Gst
276 {
277
278 /** @relates Gst::AllocationParams
279 * @param lhs The left-hand side
280 * @param rhs The right-hand side
281 */
282 inline void swap(AllocationParams& lhs, AllocationParams& rhs) noexcept
283 { lhs.swap(rhs); }
284
285 } // namespace Gst
286
287 namespace Glib
288 {
289
290 /** A Glib::wrap() method for this object.
291 *
292 * @param object The C instance.
293 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
294 * @result A C++ instance that wraps this C instance.
295 *
296 * @relates Gst::AllocationParams
297 */
298 Gst::AllocationParams wrap(GstAllocationParams* object, bool take_copy = false);
299
300 #ifndef DOXYGEN_SHOULD_SKIP_THIS
301 template <>
302 class Value<Gst::AllocationParams> : public Glib::Value_Boxed<Gst::AllocationParams>
303 {};
304 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
305
306 } // namespace Glib
307
308
309 namespace Glib
310 {
311 /** A Glib::wrap() method for this object.
312 *
313 * @param object The C instance.
314 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
315 * @result A C++ instance that wraps this C instance.
316 *
317 * @relates Gst::Allocator
318 */
319 Glib::RefPtr<Gst::Allocator> wrap(GstAllocator* object, bool take_copy = false);
320 }
321
322
323 #endif /* _GSTREAMERMM_ALLOCATOR_H */
324