| 1 | // Generated by gmmproc 2.50.1 -- DO NOT MODIFY! |
| 2 | #ifndef _GSTREAMERMM_MINIOBJECT_H |
| 3 | #define _GSTREAMERMM_MINIOBJECT_H |
| 4 | |
| 5 | |
| 6 | #include <glibmm/ustring.h> |
| 7 | #include <sigc++/sigc++.h> |
| 8 | |
| 9 | /* gstreamermm - a C++ wrapper for gstreamer |
| 10 | * |
| 11 | * Copyright 2008 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 | |
| 28 | #include <gst/gst.h> |
| 29 | #include <glibmm/value.h> |
| 30 | #include <sigc++/sigc++.h> |
| 31 | |
| 32 | #include <map> |
| 33 | |
| 34 | |
| 35 | namespace Gst |
| 36 | { |
| 37 | |
| 38 | /** @addtogroup gstreamermmEnums gstreamermm Enums and Flags */ |
| 39 | |
| 40 | /** |
| 41 | * @var MiniObjectFlags MINI_OBJECT_FLAG_LOCKABLE |
| 42 | * The object can be locked and unlocked with |
| 43 | * Gst::MiniObject::lock() and Gst::MiniObject::unlock(). |
| 44 | * |
| 45 | * @var MiniObjectFlags MINI_OBJECT_FLAG_LOCK_READONLY |
| 46 | * The object is permanently locked in |
| 47 | * READONLY mode. Only read locks can be performed on the object. |
| 48 | * |
| 49 | * @var MiniObjectFlags MINI_OBJECT_FLAG_LAST |
| 50 | * First flag that can be used by subclasses. |
| 51 | * |
| 52 | * @enum MiniObjectFlags |
| 53 | * |
| 54 | * Flags for the mini object |
| 55 | * |
| 56 | * @ingroup gstreamermmEnums |
| 57 | * @par Bitwise operators: |
| 58 | * <tt>%MiniObjectFlags operator|(MiniObjectFlags, MiniObjectFlags)</tt><br> |
| 59 | * <tt>%MiniObjectFlags operator&(MiniObjectFlags, MiniObjectFlags)</tt><br> |
| 60 | * <tt>%MiniObjectFlags operator^(MiniObjectFlags, MiniObjectFlags)</tt><br> |
| 61 | * <tt>%MiniObjectFlags operator~(MiniObjectFlags)</tt><br> |
| 62 | * <tt>%MiniObjectFlags& operator|=(MiniObjectFlags&, MiniObjectFlags)</tt><br> |
| 63 | * <tt>%MiniObjectFlags& operator&=(MiniObjectFlags&, MiniObjectFlags)</tt><br> |
| 64 | * <tt>%MiniObjectFlags& operator^=(MiniObjectFlags&, MiniObjectFlags)</tt><br> |
| 65 | */ |
| 66 | enum MiniObjectFlags |
| 67 | { |
| 68 | MINI_OBJECT_FLAG_LOCKABLE = (1 << 0), |
| 69 | MINI_OBJECT_FLAG_LOCK_READONLY = (1 << 1), |
| 70 | MINI_OBJECT_FLAG_LAST = (1 << 4) |
| 71 | }; |
| 72 | |
| 73 | /** @ingroup gstreamermmEnums */ |
| 74 | inline MiniObjectFlags operator|(MiniObjectFlags lhs, MiniObjectFlags rhs) |
| 75 | { return static_cast<MiniObjectFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } |
| 76 | |
| 77 | /** @ingroup gstreamermmEnums */ |
| 78 | inline MiniObjectFlags operator&(MiniObjectFlags lhs, MiniObjectFlags rhs) |
| 79 | { return static_cast<MiniObjectFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); } |
| 80 | |
| 81 | /** @ingroup gstreamermmEnums */ |
| 82 | inline MiniObjectFlags operator^(MiniObjectFlags lhs, MiniObjectFlags rhs) |
| 83 | { return static_cast<MiniObjectFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); } |
| 84 | |
| 85 | /** @ingroup gstreamermmEnums */ |
| 86 | inline MiniObjectFlags operator~(MiniObjectFlags flags) |
| 87 | { return static_cast<MiniObjectFlags>(~static_cast<unsigned>(flags)); } |
| 88 | |
| 89 | /** @ingroup gstreamermmEnums */ |
| 90 | inline MiniObjectFlags& operator|=(MiniObjectFlags& lhs, MiniObjectFlags rhs) |
| 91 | { return (lhs = static_cast<MiniObjectFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); } |
| 92 | |
| 93 | /** @ingroup gstreamermmEnums */ |
| 94 | inline MiniObjectFlags& operator&=(MiniObjectFlags& lhs, MiniObjectFlags rhs) |
| 95 | { return (lhs = static_cast<MiniObjectFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); } |
| 96 | |
| 97 | /** @ingroup gstreamermmEnums */ |
| 98 | inline MiniObjectFlags& operator^=(MiniObjectFlags& lhs, MiniObjectFlags rhs) |
| 99 | { return (lhs = static_cast<MiniObjectFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); } |
| 100 | |
| 101 | } // namespace Gst |
| 102 | |
| 103 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 104 | namespace Glib |
| 105 | { |
| 106 | |
| 107 | template <> |
| 108 | class Value<Gst::MiniObjectFlags> : public Glib::Value_Flags<Gst::MiniObjectFlags> |
| 109 | { |
| 110 | public: |
| 111 | static GType value_type() G_GNUC_CONST; |
| 112 | }; |
| 113 | |
| 114 | } // namespace Glib |
| 115 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 116 | |
| 117 | namespace Gst |
| 118 | { |
| 119 | |
| 120 | /** |
| 121 | * @var LockFlags LOCK_FLAG_READ |
| 122 | * Lock for read access. |
| 123 | * |
| 124 | * @var LockFlags LOCK_FLAG_WRITE |
| 125 | * Lock for write access. |
| 126 | * |
| 127 | * @var LockFlags LOCK_FLAG_EXCLUSIVE |
| 128 | * Lock for exclusive access. |
| 129 | * |
| 130 | * @var LockFlags LOCK_FLAG_LAST |
| 131 | * First flag that can be used for custom purposes. |
| 132 | * |
| 133 | * @enum LockFlags |
| 134 | * |
| 135 | * Flags used when locking miniobjects |
| 136 | * |
| 137 | * @ingroup gstreamermmEnums |
| 138 | * @par Bitwise operators: |
| 139 | * <tt>%LockFlags operator|(LockFlags, LockFlags)</tt><br> |
| 140 | * <tt>%LockFlags operator&(LockFlags, LockFlags)</tt><br> |
| 141 | * <tt>%LockFlags operator^(LockFlags, LockFlags)</tt><br> |
| 142 | * <tt>%LockFlags operator~(LockFlags)</tt><br> |
| 143 | * <tt>%LockFlags& operator|=(LockFlags&, LockFlags)</tt><br> |
| 144 | * <tt>%LockFlags& operator&=(LockFlags&, LockFlags)</tt><br> |
| 145 | * <tt>%LockFlags& operator^=(LockFlags&, LockFlags)</tt><br> |
| 146 | */ |
| 147 | enum LockFlags |
| 148 | { |
| 149 | LOCK_FLAG_READ = (1 << 0), |
| 150 | LOCK_FLAG_WRITE = (1 << 1), |
| 151 | LOCK_FLAG_EXCLUSIVE = (1 << 2), |
| 152 | LOCK_FLAG_LAST = (1 << 8) |
| 153 | }; |
| 154 | |
| 155 | /** @ingroup gstreamermmEnums */ |
| 156 | inline LockFlags operator|(LockFlags lhs, LockFlags rhs) |
| 157 | { return static_cast<LockFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } |
| 158 | |
| 159 | /** @ingroup gstreamermmEnums */ |
| 160 | inline LockFlags operator&(LockFlags lhs, LockFlags rhs) |
| 161 | { return static_cast<LockFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); } |
| 162 | |
| 163 | /** @ingroup gstreamermmEnums */ |
| 164 | inline LockFlags operator^(LockFlags lhs, LockFlags rhs) |
| 165 | { return static_cast<LockFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); } |
| 166 | |
| 167 | /** @ingroup gstreamermmEnums */ |
| 168 | inline LockFlags operator~(LockFlags flags) |
| 169 | { return static_cast<LockFlags>(~static_cast<unsigned>(flags)); } |
| 170 | |
| 171 | /** @ingroup gstreamermmEnums */ |
| 172 | inline LockFlags& operator|=(LockFlags& lhs, LockFlags rhs) |
| 173 | { return (lhs = static_cast<LockFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); } |
| 174 | |
| 175 | /** @ingroup gstreamermmEnums */ |
| 176 | inline LockFlags& operator&=(LockFlags& lhs, LockFlags rhs) |
| 177 | { return (lhs = static_cast<LockFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); } |
| 178 | |
| 179 | /** @ingroup gstreamermmEnums */ |
| 180 | inline LockFlags& operator^=(LockFlags& lhs, LockFlags rhs) |
| 181 | { return (lhs = static_cast<LockFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); } |
| 182 | |
| 183 | } // namespace Gst |
| 184 | |
| 185 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 186 | namespace Glib |
| 187 | { |
| 188 | |
| 189 | template <> |
| 190 | class Value<Gst::LockFlags> : public Glib::Value_Flags<Gst::LockFlags> |
| 191 | { |
| 192 | public: |
| 193 | static GType value_type() G_GNUC_CONST; |
| 194 | }; |
| 195 | |
| 196 | } // namespace Glib |
| 197 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 198 | |
| 199 | namespace Gst |
| 200 | { |
| 201 | |
| 202 | |
| 203 | /** This is a base class for data which represents qdata. |
| 204 | */ |
| 205 | class QuarkData |
| 206 | { |
| 207 | public: |
| 208 | virtual ~QuarkData(){} |
| 209 | }; |
| 210 | |
| 211 | /** This is a base class for some gstreamermm objects. |
| 212 | * It is similar to Glib::Object but has no GObject property or signal support. |
| 213 | */ |
| 214 | class MiniObject |
| 215 | { |
| 216 | public: |
| 217 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 218 | using CppObjectType = MiniObject; |
| 219 | using BaseObjectType = GstMiniObject; |
| 220 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 221 | |
| 222 | |
| 223 | /** Increment the reference count for this object. |
| 224 | * You should never need to do this manually - use the object via a RefPtr instead. |
| 225 | */ |
| 226 | void reference() const; |
| 227 | |
| 228 | /** Decrement the reference count for this object. |
| 229 | * You should never need to do this manually - use the object via a RefPtr instead. |
| 230 | */ |
| 231 | void unreference() const; |
| 232 | |
| 233 | ///Provides access to the underlying C instance. |
| 234 | GstMiniObject* gobj(); |
| 235 | |
| 236 | ///Provides access to the underlying C instance. |
| 237 | const GstMiniObject* gobj() const; |
| 238 | |
| 239 | ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. |
| 240 | GstMiniObject* gobj_copy() const; |
| 241 | |
| 242 | MiniObject() = delete; |
| 243 | |
| 244 | // noncopyable |
| 245 | MiniObject(const MiniObject&) = delete; |
| 246 | MiniObject& operator=(const MiniObject&) = delete; |
| 247 | |
| 248 | protected: |
| 249 | // Do not derive this. Gst::MiniObject can neither be constructed nor deleted. |
| 250 | |
| 251 | void operator delete(void*, std::size_t); |
| 252 | |
| 253 | private: |
| 254 | |
| 255 | |
| 256 | public: |
| 257 | typedef sigc::slot< void > SlotFinalizer; |
| 258 | |
| 259 | ~MiniObject(); |
| 260 | guint get_flags() const; |
| 261 | void set_flags(const guint& value); |
| 262 | |
| 263 | gint get_refcount() const; |
| 264 | |
| 265 | gint get_lockstate() const; |
| 266 | |
| 267 | |
| 268 | /** Lock the mini-object with the specified access mode in @a flags. |
| 269 | * |
| 270 | * @param flags Gst::LockFlags. |
| 271 | * @return <tt>true</tt> if @a object could be locked. |
| 272 | */ |
| 273 | bool lock(LockFlags flags); |
| 274 | |
| 275 | /** Unlock the mini-object with the specified access mode in @a flags. |
| 276 | * |
| 277 | * @param flags Gst::LockFlags. |
| 278 | */ |
| 279 | void unlock(LockFlags flags); |
| 280 | |
| 281 | /** If @a mini_object has the LOCKABLE flag set, check if the current EXCLUSIVE |
| 282 | * lock on @a object is the only one, this means that changes to the object will |
| 283 | * not be visible to any other object. |
| 284 | * |
| 285 | * If the LOCKABLE flag is not set, check if the refcount of @a mini_object is |
| 286 | * exactly 1, meaning that no other reference exists to the object and that the |
| 287 | * object is therefore writable. |
| 288 | * |
| 289 | * Modification of a mini-object should only be done after verifying that it |
| 290 | * is writable. |
| 291 | * |
| 292 | * @return <tt>true</tt> if the object is writable. |
| 293 | */ |
| 294 | bool is_writable() const; |
| 295 | |
| 296 | |
| 297 | /** Checks if a mini-object is writable. If not, a writable copy is made and |
| 298 | * returned. This gives away the reference to the original mini object, |
| 299 | * and returns a reference to the new object. |
| 300 | * |
| 301 | * MT safe |
| 302 | * @return A mini-object (possibly the same pointer) that |
| 303 | * is writable. |
| 304 | */ |
| 305 | Glib::RefPtr<MiniObject> create_writable(); |
| 306 | |
| 307 | /** This sets an opaque, named pointer on a miniobject. |
| 308 | * The name is specified through a #GQuark (retrived e.g. via |
| 309 | * g_quark_from_static_string()), and the pointer |
| 310 | * can be gotten back with get_qdata(). |
| 311 | * Setting a previously set user data pointer, overrides (frees) |
| 312 | * the old pointer set, using NULL as pointer essentially |
| 313 | * removes the data stored. |
| 314 | * @param quark a GQuark, naming the user data pointer. |
| 315 | * @param data an opaque user data pointer. |
| 316 | */ |
| 317 | void set_qdata(GQuark quark, QuarkData *data); |
| 318 | |
| 319 | |
| 320 | /** This function gets back user data pointers stored via |
| 321 | * set_qdata(). |
| 322 | * @param quark a GQuark, naming the user data pointer. |
| 323 | * @return the user data pointer set, or NULL. |
| 324 | */ |
| 325 | QuarkData* get_qdata(GQuark quark) const; |
| 326 | |
| 327 | |
| 328 | /** This function gets back user data pointers stored via set_qdata() |
| 329 | * and removes the data from @a object without invoking its destroy() function (if |
| 330 | * any was set). |
| 331 | * |
| 332 | * @param quark A Quark, naming the user data pointer. |
| 333 | * @return The user data pointer set, or |
| 334 | * <tt>nullptr</tt>. |
| 335 | */ |
| 336 | QuarkData* steal_qdata(GQuark quark); |
| 337 | |
| 338 | // Copying a mini object can be achieved by assignment. |
| 339 | |
| 340 | |
| 341 | /** Adds notifier when mini object is finalized |
| 342 | * @param slot notifier. |
| 343 | */ |
| 344 | void add_finalize_notifier(const SlotFinalizer& slot); |
| 345 | |
| 346 | /** Remove finalize notifier |
| 347 | */ |
| 348 | void remove_finalize_notifier(); |
| 349 | |
| 350 | |
| 351 | private: |
| 352 | // In this class non-static member cannot exists, so there is a map |
| 353 | // with key = gobj() and value = handler. |
| 354 | static std::map<GstMiniObject*, SlotFinalizer*> finalizers; |
| 355 | |
| 356 | static void destroy_qdata(gpointer qdata); |
| 357 | |
| 358 | static void MiniObject_Finalizer_gstreamermm_callback(gpointer userdata, GstMiniObject *obj); |
| 359 | |
| 360 | |
| 361 | }; |
| 362 | |
| 363 | } // namespace Gst |
| 364 | |
| 365 | |
| 366 | namespace Glib |
| 367 | { |
| 368 | |
| 369 | /** A Glib::wrap() method for this object. |
| 370 | * |
| 371 | * @param object The C instance. |
| 372 | * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. |
| 373 | * @result A C++ instance that wraps this C instance. |
| 374 | * |
| 375 | * @relates Gst::MiniObject |
| 376 | */ |
| 377 | Glib::RefPtr<Gst::MiniObject> wrap(GstMiniObject* object, bool take_copy = false); |
| 378 | |
| 379 | } // namespace Glib |
| 380 | |
| 381 | |
| 382 | #endif /* _GSTREAMERMM_MINIOBJECT_H */ |
| 383 |