Debian Codegraph @

gstreamer/gstreamermm/atomicqueue.h

raw symbols SCIP
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2014 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 _GSTREAMERMM_ATOMICQUEUE_H
21 #define _GSTREAMERMM_ATOMICQUEUE_Hcxx . . $ `gstreamer/gstreamermm/atomicqueue.h:21:9`!
22
23 #include <glibmm/refptr.h>
24 #include <gstreamermm/handle_error.h>cxx . . $ `<file>/gstreamer/gstreamermm/handle_error.h`/
25 #include <gst/gstatomicqueue.h>
26
27 namespace Gstcxx . . $ Gst/
28 {
29
30 /**
31 * The Gst::AtomicQueue object implements a queue that can be used from multiple
32 * threads without performing any blocking operations.
33 */
34 template <typename T>
35 class AtomicQueuecxx . . $ Gst/AtomicQueue#
36 {
37 public:
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 typedef AtomicQueue CppObjectTypecxx . . $ Gst/AtomicQueue#CppObjectType#;
40 typedef GstAtomicQueue BaseObjectTypecxx . . $ Gst/AtomicQueue#BaseObjectType#;
41 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
42
43
44 /** Increment the reference count for this object.
45 * You should never need to do this manually - use the object via a RefPtr instead.
46 */
47 void referencecxx . . $ Gst/AtomicQueue#reference(83f5f38750778ac8).() const
48 {
49 // See the comment at the top of this file, if you want to know why the cast works.
50 gst_atomic_queue_ref(reinterpret_cast<GstAtomicQueue*>(const_cast<AtomicQueuecxx . . $ Gst/AtomicQueue#<T>*>(this)));
51 }
52
53 /** Decrement the reference count for this object.
54 * You should never need to do this manually - use the object via a RefPtr instead.
55 */
56 void unreferencecxx . . $ Gst/AtomicQueue#unreference(83f5f38750778ac8).() const
57 {
58 // See the comment at the top of this file, if you want to know why the cast works.
59 gst_atomic_queue_unref(reinterpret_cast<GstAtomicQueue*>(const_cast<AtomicQueuecxx . . $ Gst/AtomicQueue#<T>*>(this)));
60 }
61
62 ///Provides access to the underlying C instance.
63 const GstAtomicQueue* gobjcxx . . $ Gst/AtomicQueue#gobj(3ed86145306ade39).() const
64 {
65 // See the comment at the top of this file, if you want to know why the cast works.
66 return reinterpret_cast<const GstAtomicQueue*>(this);
67 }
68
69 ///Provides access to the underlying C instance.
70 GstAtomicQueue* gobjcxx . . $ Gst/AtomicQueue#gobj(d5e08cb589e3287b).()
71 {
72 // See the comment at the top of this file, if you want to know why the cast works.
73 return reinterpret_cast<GstAtomicQueue*>(this);
74 }
75
76 ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
77 GstAtomicQueue* gobj_copycxx . . $ Gst/AtomicQueue#gobj_copy(2d6a2a21f4d1817c).() const
78 {
79 // See the comment at the top of this file, if you want to know why the cast works.
80 GstAtomicQueue *const gobject = reinterpret_cast<GstAtomicQueue*>(const_cast<AtomicQueuecxx . . $ Gst/AtomicQueue#<T>*>(this));
81 gst_atomic_queue_ref(gobject);
82 return gobject;
83 }
84
85 static Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::AtomicQueuecxx . . $ Gst/AtomicQueue#<T> > createcxx . . $ Gst/AtomicQueue#create(fa22b110f805697).(guint initial_size)
86 {
87 // See the comment at the top of this file, if you want to know why the cast works.
88 return Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<AtomicQueuecxx . . $ Gst/AtomicQueue#<T> >(reinterpret_cast<AtomicQueuecxx . . $ Gst/AtomicQueue#<T>*>(gst_atomic_queue_new(initial_size)));
89 }
90
91 protected:
92 // Do not derive this. Gst::AtomicQueue can neither be constructed nor deleted.
93 AtomicQueuecxx . . $ Gst/AtomicQueue#`AtomicQueue<T>`(49f6e7a06ebc5aa8).();
94 void operatorcxx . . $ Gst/AtomicQueue#`operator delete`(5500c4293b1bbef0). delete(void*, stdcxx . . $ std/::size_tcxx . . $ std/size_t#);
95
96 private:
97 // noncopyable
98 AtomicQueuecxx . . $ Gst/AtomicQueue#`AtomicQueue<T>`(47a7a0b3f6d24fc6).(const AtomicQueue&);
99 AtomicQueue& operatorcxx . . $ Gst/AtomicQueue#`operator=`(1e42e59e0857c521).=(const AtomicQueue&);
100
101
102 public:
103
104 /** Get the amount of items in the queue.
105 * @return The number of elements in the queue.
106 */
107 guint lengthcxx . . $ Gst/AtomicQueue#length(db52760e79bf9054).()
108 {
109 return gst_atomic_queue_length(gobjcxx . . $ Gst/AtomicQueue#gobj(3ed86145306ade39).());
110 }
111
112 /** Get the amount of items in the queue.
113 * @return The number of elements in the queue.
114 */
115 guint lengthcxx . . $ Gst/AtomicQueue#length(ddd8539a2fcdd4ce).() const
116 {
117 return const_cast<AtomicQueue*>(this)->lengthcxx . . $ Gst/AtomicQueue#length(db52760e79bf9054).();
118 }
119
120 /** Append @a data to the tail of the queue.
121 * @param data The data.
122 */
123 void pushcxx . . $ Gst/AtomicQueue#push(77d9f17553126ecb).(const T& data)
124 {
125 T* tmp = new T(data);
126 gst_atomic_queue_push(gobjcxx . . $ Gst/AtomicQueue#gobj(3ed86145306ade39).(), tmp);
127 }
128
129 /** Peek the head element of the queue without removing it from the queue.
130 * @return The head element of queue.
131 *
132 * @throws std::runtime_error if the queue is empty.
133 */
134 T peekcxx . . $ Gst/AtomicQueue#peek(5f357b03ed472e5e).()
135 {
136 gpointer val = gst_atomic_queue_peek(gobjcxx . . $ Gst/AtomicQueue#gobj(3ed86145306ade39).());
137 if (val == nullptr)
138 gstreamermm_handle_errorcxx . . $ Gst/gstreamermm_handle_error(1ff0bff2cee2bc51).("Queue is empty"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
139 T v = *(T*)val;
140 return v;
141 }
142
143 /** Get the head element of the queue.
144 * @return The head element of queue.
145 *
146 * @throws std::runtime_error if the queue is empty.
147 */
148 T popcxx . . $ Gst/AtomicQueue#pop(5f357b03ed472e5e).()
149 {
150 gpointer val = gst_atomic_queue_pop(gobjcxx . . $ Gst/AtomicQueue#gobj(3ed86145306ade39).());
151 if (val == nullptr)
152 gstreamermm_handle_errorcxx . . $ Gst/gstreamermm_handle_error(1ff0bff2cee2bc51).("Queue is empty"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
153 T v = *(T*)val;
154 delete (T*)val;
155 return v;
156 }
157
158 };
159
160 } // namespace Gst
161
162
163 namespace Glibcxx . . $ Glib/
164 {
165
166 /** A Glib::wrap() method for this object.
167 *
168 * @param object The C instance.
169 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
170 * @result A C++ instance that wraps this C instance.
171 *
172 * @relates Gst::AtomicQueue
173 */
174 template <typename T>
175 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::AtomicQueuecxx . . $ Gst/AtomicQueue#<T> > wrapcxx . . $ Glib/wrap(593cc12046ea5a60).(GstAtomicQueue* object, bool take_copy = false)
176 {
177 if(take_copy && object)
178 gst_atomic_queue_ref(object);
179 // See the comment at the top of this file, if you want to know why the cast works.
180 return Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::AtomicQueuecxx . . $ Gst/AtomicQueue#<T> >(reinterpret_cast<Gstcxx . . $ Gst/::AtomicQueuecxx . . $ Gst/AtomicQueue#<T>*>(object));
181 }
182
183 } // namespace Glib
184
185
186 #endif /* _GSTREAMERMM_ATOMICQUEUE_H */
187