Debian Codegraph @

gstreamer/src/miniobject.hg

raw
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 #include <gst/gst.h>
21 #include <glibmm/value.h>
22 #include <sigc++/sigc++.h>
23
24 #include <map>
25
26 _DEFS(gstreamermm,gst)
27
28 namespace Gst
29 {
30
31 _WRAP_ENUM(MiniObjectFlags, GstMiniObjectFlags)
32 _WRAP_ENUM(LockFlags, GstLockFlags)
33
34 /** This is a base class for data which represents qdata.
35 */
36 class QuarkData
37 {
38 public:
39 virtual ~QuarkData(){}
40 };
41
42 /** This is a base class for some gstreamermm objects.
43 * It is similar to Glib::Object but has no GObject property or signal support.
44 */
45 class MiniObject
46 {
47 _CLASS_OPAQUE_REFCOUNTED(MiniObject, GstMiniObject, NONE, gst_mini_object_ref, gst_mini_object_unref)
48 _IGNORE(gst_mini_object_ref, gst_mini_object_unref)
49
50 public:
51 typedef sigc::slot< void > SlotFinalizer;
52
53 ~MiniObject();
54 _MEMBER_GET(flags, flags, guint, guint)
55 _MEMBER_SET(flags, flags, guint, guint)
56
57 _MEMBER_GET(refcount, refcount, gint, gint)
58
59 _MEMBER_GET(lockstate, lockstate, gint, gint)
60
61 _WRAP_METHOD(bool lock(LockFlags flags), gst_mini_object_lock)
62 _WRAP_METHOD(void unlock(LockFlags flags), gst_mini_object_unlock)
63 _WRAP_METHOD(bool is_writable() const, gst_mini_object_is_writable)
64
65 _IGNORE(gst_mini_object_make_writable)
66 /** Checks if a mini-object is writable. If not, a writable copy is made and
67 * returned. This gives away the reference to the original mini object,
68 * and returns a reference to the new object.
69 *
70 * MT safe
71 * @return A mini-object (possibly the same pointer) that
72 * is writable.
73 */
74 Glib::RefPtr<MiniObject> create_writable();
75
76 /** This sets an opaque, named pointer on a miniobject.
77 * The name is specified through a #GQuark (retrived e.g. via
78 * g_quark_from_static_string()), and the pointer
79 * can be gotten back with get_qdata().
80 * Setting a previously set user data pointer, overrides (frees)
81 * the old pointer set, using NULL as pointer essentially
82 * removes the data stored.
83 * @param quark a GQuark, naming the user data pointer.
84 * @param data an opaque user data pointer.
85 */
86 void set_qdata(GQuark quark, QuarkData *data);
87 _IGNORE(gst_mini_object_set_qdata)
88
89 /** This function gets back user data pointers stored via
90 * set_qdata().
91 * @param quark a GQuark, naming the user data pointer.
92 * @return the user data pointer set, or NULL.
93 */
94 QuarkData* get_qdata(GQuark quark) const;
95 _IGNORE(gst_mini_object_get_qdata)
96
97 #m4 _CONVERSION(`gpointer',`QuarkData*',`static_cast<QuarkData*>($3)')
98 _WRAP_METHOD(QuarkData* steal_qdata(GQuark quark), gst_mini_object_steal_qdata)
99
100 // Copying a mini object can be achieved by assignment.
101 _IGNORE(gst_mini_object_copy)
102
103 /** Adds notifier when mini object is finalized
104 * @param slot notifier.
105 */
106 void add_finalize_notifier(const SlotFinalizer& slot);
107
108 /** Remove finalize notifier
109 */
110 void remove_finalize_notifier();
111
112 _IGNORE(gst_mini_object_weak_ref)
113 _IGNORE(gst_mini_object_weak_unref)
114
115 private:
116 // In this class non-static member cannot exists, so there is a map
117 // with key = gobj() and value = handler.
118 static std::map<GstMiniObject*, SlotFinalizer*> finalizers;
119
120 static void destroy_qdata(gpointer qdata);
121
122 static void MiniObject_Finalizer_gstreamermm_callback(gpointer userdata, GstMiniObject *obj);
123
124 };
125
126 } // namespace Gst