object.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/private/object.h
  3. // Purpose: wxGtkObject class declaration
  4. // Author: Vadim Zeitlin
  5. // Created: 2008-08-27
  6. // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwindows.org>
  7. // Licence: wxWindows licence
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_GTK_PRIVATE_OBJECT_H_
  10. #define _WX_GTK_PRIVATE_OBJECT_H_
  11. // ----------------------------------------------------------------------------
  12. // Convenience class for calling g_object_unref() automatically
  13. // ----------------------------------------------------------------------------
  14. template <typename T>
  15. class wxGtkObject
  16. {
  17. public:
  18. explicit wxGtkObject(T *p) : m_ptr(p) { }
  19. ~wxGtkObject() { g_object_unref(m_ptr); }
  20. operator T *() const { return m_ptr; }
  21. private:
  22. T * const m_ptr;
  23. // copying could be implemented by using g_object_ref() but for now there
  24. // is no need for it so don't implement it
  25. wxDECLARE_NO_COPY_CLASS(wxGtkObject);
  26. };
  27. #endif // _WX_GTK_PRIVATE_OBJECT_H_