diff options
author | Murray Cumming <murrayc@src.gnome.org> | 2005-01-21 12:48:06 +0000 |
---|---|---|
committer | Murray Cumming <murrayc@src.gnome.org> | 2005-01-21 12:48:06 +0000 |
commit | a8e848b1f08e71f376ddfce775794c7056609f23 (patch) | |
tree | da3afa00b8a0d9e09245cc7e7769db014fe6f418 /glib/glibmm/object.h | |
parent | 477ea23168b754530c508e31729d29bc309a4b13 (diff) | |
download | glibmm-a8e848b1f08e71f376ddfce775794c7056609f23.tar.gz |
Temporarily reverted some stuff. I will recommit some of it.
Diffstat (limited to 'glib/glibmm/object.h')
-rw-r--r-- | glib/glibmm/object.h | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/glib/glibmm/object.h b/glib/glibmm/object.h index 3f196f9c..d9bca6e1 100644 --- a/glib/glibmm/object.h +++ b/glib/glibmm/object.h @@ -25,7 +25,6 @@ #include <glibmm/quark.h> #include <glibmm/refptr.h> #include <glibmm/utility.h> /* Could be private, but that would be tedious. */ -#include <glibmm/containerhandle_shared.h> //Because its specializations may be here. #include <glibmm/value.h> #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -146,136 +145,6 @@ private: //virtual void set_manage(); }; - -//For some (proably, more spec-compliant) compilers, these specializations must -//be next to the objects that they use. -#ifndef GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION -#ifndef DOXYGEN_SHOULD_SKIP_THIS /* hide the specializations */ - -namespace Container_Helpers -{ - -/** Partial specialization for pointers to GObject instances. - * @ingroup ContHelpers - * The C++ type is always a Glib::RefPtr<>. - */ -template <class T> -struct TypeTraits< Glib::RefPtr<T> > -{ - typedef Glib::RefPtr<T> CppType; - typedef typename T::BaseObjectType * CType; - typedef typename T::BaseObjectType * CTypeNonConst; - - static CType to_c_type (const CppType& ptr) { return Glib::unwrap(ptr); } - static CType to_c_type (CType ptr) { return ptr; } - static CppType to_cpp_type (CType ptr) - { - //return Glib::wrap(ptr, true); - - //We copy/paste the wrap() implementation here, - //because we can not use a specific Glib::wrap(CType) overload here, - //because that would be "dependent", and g++ 3.4 does not allow that. - //The specific Glib::wrap() overloads don't do anything special anyway. - GObject* cobj = (GObject*)const_cast<CTypeNonConst>(ptr); - return Glib::RefPtr<T>( dynamic_cast<T*>(Glib::wrap_auto(cobj, true /* take_copy */)) ); - //We use dynamic_cast<> in case of multiple inheritance. - } - - static void release_c_type (CType ptr) - { - GLIBMM_DEBUG_UNREFERENCE(0, ptr); - g_object_unref(ptr); - } -}; - -//This confuse the SUN Forte compiler, so we ifdef it out: -#ifdef GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS - -/** Partial specialization for pointers to const GObject instances. - * @ingroup ContHelpers - * The C++ type is always a Glib::RefPtr<>. - */ -template <class T> -struct TypeTraits< Glib::RefPtr<const T> > -{ - typedef Glib::RefPtr<const T> CppType; - typedef const typename T::BaseObjectType * CType; - typedef typename T::BaseObjectType * CTypeNonConst; - - static CType to_c_type (const CppType& ptr) { return Glib::unwrap(ptr); } - static CType to_c_type (CType ptr) { return ptr; } - static CppType to_cpp_type (CType ptr) - { - //return Glib::wrap(ptr, true); - - //We copy/paste the wrap() implementation here, - //because we can not use a specific Glib::wrap(CType) overload here, - //because that would be "dependent", and g++ 3.4 does not allow that. - //The specific Glib::wrap() overloads don't do anything special anyway. - GObject* cobj = (GObject*)(ptr); - return Glib::RefPtr<const T>( dynamic_cast<const T*>(Glib::wrap_auto(cobj, true /* take_copy */)) ); - //We use dynamic_cast<> in case of multiple inheritance. - } - - static void release_c_type (CType ptr) - { - GLIBMM_DEBUG_UNREFERENCE(0, ptr); - g_object_unref(const_cast<CTypeNonConst>(ptr)); - } -}; - -#endif //GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS - -} //namespace Container_Helpers - - -template <class T, class PtrT> inline -PtrT Value_Pointer<T,PtrT>::get_(Glib::Object*) const -{ - return dynamic_cast<T*>(get_object()); -} - - -/** Partial specialization for RefPtr<> to Glib::Object. - * @ingroup glibmmValue - */ -template <class T> -class Value< Glib::RefPtr<T> > : public ValueBase_Object -{ -public: - typedef Glib::RefPtr<T> CppType; - typedef typename T::BaseObjectType* CType; - - static GType value_type() { return T::get_base_type(); } - - void set(const CppType& data) { set_object(data.operator->()); } - CppType get() const { return Glib::RefPtr<T>::cast_dynamic(get_object_copy()); } -}; - -//The SUN Forte Compiler has a problem with this: -#ifdef GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS - -/** Partial specialization for RefPtr<> to const Glib::Object. - * @ingroup glibmmValue - */ -template <class T> -class Value< Glib::RefPtr<const T> > : public ValueBase_Object -{ -public: - typedef Glib::RefPtr<const T> CppType; - typedef typename T::BaseObjectType* CType; - - static GType value_type() { return T::get_base_type(); } - - void set(const CppType& data) { set_object(const_cast<T*>(data.operator->())); } - CppType get() const { return Glib::RefPtr<T>::cast_dynamic(get_object_copy()); } -}; -#endif //GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS - - -#endif //DOXYGEN_SHOULD_SKIP_THIS -#endif //GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION - } // namespace Glib #endif /* _GLIBMM_OBJECT_H */ |