00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _GSTREAMERMM_WRAP_H
00023 #define _GSTREAMERMM_WRAP_H
00024
00025 #include <gst/gstminiobject.h>
00026 #include <glibmm/refptr.h>
00027 #include <gstreamermm/miniobject.h>
00028
00029 namespace Gst
00030 {
00031
00032 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00033
00034 class MiniObject;
00035
00036
00037 typedef Gst::MiniObject* (*WrapNewFunction) (GstMiniObject*);
00038
00039
00040
00041 void wrap_register_init();
00042 void wrap_register_cleanup();
00043
00044
00045 void wrap_register(GType type, WrapNewFunction func);
00046
00047
00048
00049 Gst::MiniObject* wrap_auto(GstMiniObject* object, bool take_copy = false);
00050
00055 Gst::MiniObject* wrap_create_new_wrapper_for_interface(GstMiniObject* object, GType interface_gtype);
00056
00057
00058
00059 template<class TInterface>
00060 TInterface* wrap_auto_interface(GstMiniObject* object, bool take_copy = false)
00061 {
00062 if(!object)
00063 return 0;
00064
00065
00066
00067 MiniObject* pCppObject = 0;
00068
00069 if(!pCppObject)
00070 {
00071
00072
00073
00074 pCppObject = wrap_create_new_wrapper_for_interface(object, TInterface::get_base_type());
00075 }
00076
00077
00078
00079
00080 TInterface* result = 0;
00081 if(pCppObject)
00082 result = dynamic_cast<TInterface*>(pCppObject);
00083 else
00084 result = new TInterface((typename TInterface::BaseObjectType*)object);
00085
00086
00087
00088 if(take_copy && result)
00089 result->reference();
00090
00091 return result;
00092 }
00093
00094 #endif //DOXYGEN_SHOULD_SKIP_THIS
00095
00096
00097
00098
00099
00101 Glib::RefPtr<Gst::MiniObject> wrap(GstMiniObject* object, bool take_copy = false);
00102
00103
00107 template <class T> inline
00108 typename T::BaseObjectType* unwrap(T* ptr)
00109 {
00110 return (ptr) ? ptr->gobj() : 0;
00111 }
00112
00116 template <class T> inline
00117 const typename T::BaseObjectType* unwrap(const T* ptr)
00118 {
00119 return (ptr) ? ptr->gobj() : 0;
00120 }
00121
00125 template <class T> inline
00126 typename T::BaseObjectType* unwrap(const Glib::RefPtr<T>& ptr)
00127 {
00128 return (ptr) ? ptr->gobj() : 0;
00129 }
00130
00134 template <class T> inline
00135 const typename T::BaseObjectType* unwrap(const Glib::RefPtr<const T>& ptr)
00136 {
00137 return (ptr) ? ptr->gobj() : 0;
00138 }
00139
00144 template <class T> inline
00145 typename T::BaseObjectType* unwrap_copy(const Glib::RefPtr<T>& ptr)
00146 {
00147 return (ptr) ? ptr->gobj_copy() : 0;
00148 }
00149
00154 template <class T> inline
00155 const typename T::BaseObjectType* unwrap_copy(const Glib::RefPtr<const T>& ptr)
00156 {
00157 return (ptr) ? ptr->gobj_copy() : 0;
00158 }
00159
00160 extern GLIBMM_API GQuark quark_;
00161 extern GLIBMM_API GQuark quark_cpp_wrapper_deleted_;
00162
00163 }
00164
00165 #endif