Updated libglibmm2 to glibmm-2.12.5
[ardour.git] / libs / glibmm2 / glibmm / objectbase.h
index bddfdcf6ca513beb448c70bff9b6906e43890e83..2ad6e650301f133379c0ca3c2e2d21fe3c2c34c5 100644 (file)
 
 #include <glibmm/signalproxy.h>
 #include <glibmm/propertyproxy.h>
+#include <glibmm/ustring.h>
+#include <glibmm/value.h>
 #include <sigc++/trackable.h>
 #include <typeinfo>
 #include <glibmmconfig.h>
 #include <glibmm/debug.h>
 
+#include <glibmmconfig.h>
+
 GLIBMM_USING_STD(type_info)
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -44,35 +48,44 @@ class GSigConnectionNode;
 
 //This inherits virtually from sigc::trackable so that people can multiply inherit glibmm classes from other sigc::trackable-derived classes.
 //See bugzilla.gnome.org bug # 116280
-class ObjectBase : virtual public sigc::trackable
+/** Glib::ObjectBase is a common base class for Objects and Interfaces.
+ *
+ * This is used as virtual base class.  This means the ObjectBase
+ * constructor runs before all others, either implicitly or explicitly.  Each of
+ * the available constructors initializes custom_type_name_ in a different way.
+ */
+class GLIBMM_API ObjectBase : virtual public sigc::trackable
 {
 protected:
-  // Glib::ObjectBase is used as virtual base class.  This means the ObjectBase
-  // ctor runs before all others -- either implicitly or explicitly.  Each of
-  // the available ctors initializes custom_type_name_ in a different way:
-  //
-  // 1) default:      custom_type_name_ = "gtkmm__anonymous_custom_type"
-  // 2) const char*:  custom_type_name_ = custom_type_name
-  // 3) type_info:    custom_type_name_ = custom_type_info.name()
-  //
-  // All classes generated by gtkmmproc use ctor 2) with custom_type_name = 0,
-  // which essentially means it's not a custom type.  This is used to optimize
-  // vfunc and signal handler callbacks -- since the C++ virtual methods are
-  // not overridden, invocation can be skipped.
-  //
-  // The default ctor 1) is called implicitly from the ctor of user-derived
-  // classes -- yes, even if e.g. Gtk::Button calls ctor 2), a derived ctor
-  // always overrides this choice.  The language itself ensures that the ctor
-  // is only invoked once.
-  //
-  // Ctor 3) is a special feature to allow creation of derived types on the
-  // fly, without having to use g_object_new() manually.  This feature is
-  // sometimes necessary, e.g. to implement a custom Gtk::CellRenderer.  The
-  // neat trick with the virtual base class ctor makes it possible to reuse
-  // the same direct base class' ctor as with non-custom types.
-
+  /** This default constructor is called implicitly from the constructor of user-derived
+   * classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor.
+   * This is normal behaviour for C++ virtual inheritance.
+   * 
+   * The GType name will be gtkmm__anonymous_custom_type.
+   */
   ObjectBase();
+
+  /** A derived constructor always overrides this choice.
+   * The C++ language itself ensures that the constructor
+   * is only invoked once.
+   * 
+   * All classes generated by gtkmmproc use this constructor, with custom_type_name = 0,
+   * which essentially means it's not a custom type.  This is used to optimize
+   * vfunc and signal handler callbacks -- since the C++ virtual methods are
+   * not overridden, invocation can be skipped.
+   *
+   * The GType name will be @a custom_type_name.
+   */
   explicit ObjectBase(const char* custom_type_name);
+
+  /** This constructor is a special feature to allow creation of derived types on the
+   * fly, without having to use g_object_new() manually.  This feature is
+   * sometimes necessary, e.g. to implement a custom Gtk::CellRenderer.  The
+   * neat trick with the virtual base class ctor makes it possible to reuse
+   * the same direct base class' constructor as with non-custom types.
+   *
+   * The GType name will be @a custom_type_info.name().
+   */
   explicit ObjectBase(const std::type_info& custom_type_info);
 
   virtual ~ObjectBase() = 0;
@@ -96,22 +109,38 @@ public:
   template <class PropertyType>
   void get_property(const Glib::ustring& property_name, PropertyType& value) const;
 
-  
-  virtual void reference()   const;
+  /** You can use the signal_changed() signal of the property proxy instead, 
+   * but this is necessary when using the reduced API.
+   */
+  void connect_property_changed(const Glib::ustring& property_name, const sigc::slot<void>& slot);
+
+  /** Increment the reference count for this object.
+   * You should never need to do this manually - use the object via a RefPtr instead.
+   */
+  virtual void reference() const;
+
+  /** Decrement the reference count for this object.
+   * You should never need to do this manually - use the object via a RefPtr instead.
+   */
   virtual void unreference() const;
 
+  ///Provides access to the underlying C GtkObject.
   inline GObject*       gobj()       { return gobject_; }
+
+  ///Provides access to the underlying C GtkObject.
   inline const GObject* gobj() const { return gobject_; }
 
-  // Give a ref-ed copy to someone. Use for direct struct access.
+  /// Give a ref-ed copy to someone. Use for direct struct access.
   GObject* gobj_copy() const;
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   static ObjectBase* _get_current_wrapper(GObject* object);
   bool _cpp_destruction_is_in_progress() const;
-#endif
+#endif //DOXYGEN_SHOULD_SKIP_THIS
 
 protected:
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
   GObject*            gobject_; // the GLib/GDK/GTK+ object instance
   const char*         custom_type_name_;
   bool                cpp_destruction_in_progress_;
@@ -123,13 +152,16 @@ protected:
   virtual void destroy_notify_();
 
   void _set_current_wrapper(GObject* object);
+#endif //DOXYGEN_SHOULD_SKIP_THIS
 
 private:
   // noncopyable
   ObjectBase(const ObjectBase&);
   ObjectBase& operator=(const ObjectBase&);
 
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
   virtual void set_manage(); // calls g_error()
+#endif //DOXYGEN_SHOULD_SKIP_THIS
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   friend class Glib::GSigConnectionNode; // for GSigConnectionNode::notify()
@@ -138,7 +170,7 @@ private:
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 
-template <class PropertyType>
+template <class PropertyType> inline
 void ObjectBase::set_property(const Glib::ustring& property_name, const PropertyType& value)
 {
   Glib::Value<PropertyType> property_value;
@@ -148,7 +180,7 @@ void ObjectBase::set_property(const Glib::ustring& property_name, const Property
   this->set_property_value(property_name, property_value);
 }
 
-template <class PropertyType>
+template <class PropertyType> inline
 void ObjectBase::get_property(const Glib::ustring& property_name, PropertyType& value) const
 {
   Glib::Value<PropertyType> property_value;