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