#ifndef _GLIBMM_OBJECT_H
#define _GLIBMM_OBJECT_H
/* Copyright 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
// X11 defines DestroyNotify and some other non-prefixed stuff, and it's too late to change that
// now,
// so let's give people a clue about the compilation errors that they will see:
#ifdef DestroyNotify
#error \
"X11/Xlib.h seems to have been included before this header. Due to some commonly-named macros in X11/Xlib.h, it may only be included after any glibmm, gdkmm, or gtkmm headers."
#endif
#include
#include
#include
#include
#include
#include /* Could be private, but that would be tedious. */
#include /* Because its specializations may be here. */
#include
#include /* for G_GNUC_NULL_TERMINATED */
#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C" {
using GObject = struct _GObject;
using GObjectClass = struct _GObjectClass;
}
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
namespace Glib
{
#ifndef DOXYGEN_SHOULD_SKIP_THIS
class GLIBMM_API Class;
class GLIBMM_API Object_Class;
class GLIBMM_API GSigConnectionNode;
/* ConstructParams::ConstructParams() takes a varargs list of properties
* and values, like g_object_new() does. This list will then be converted
* to a GParameter array, for use with g_object_newv(). No overhead is
* involved, since g_object_new() is just a wrapper around g_object_newv()
* as well.
*
* The advantage of an auxiliary ConstructParams object over g_object_new()
* is that the actual construction is always done in the Glib::Object ctor.
* This allows for neat tricks like easy creation of derived custom types,
* without adding special support to each ctor of every class.
*
* The comments in object.cc and objectbase.cc should explain in detail
* how this works.
*/
class GLIBMM_API ConstructParams
{
public:
const Glib::Class& glibmm_class;
unsigned int n_parameters;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GParameter* parameters;
G_GNUC_END_IGNORE_DEPRECATIONS
explicit ConstructParams(const Glib::Class& glibmm_class_);
ConstructParams(const Glib::Class& glibmm_class_, const char* first_property_name,
...) G_GNUC_NULL_TERMINATED; // warn if called without a trailing NULL pointer
~ConstructParams() noexcept;
// The copy constructor is semantically required by the C++ compiler
// (since g++ 3.4) to be able to create temporary instances, depending
// on the usage context. Apparently the compiler will actually optimize
// away the copy, though. See bug #132300.
ConstructParams(const ConstructParams& other);
private:
// no copy assignment
ConstructParams& operator=(const ConstructParams&);
};
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
class GLIBMM_API Object : virtual public ObjectBase
{
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
using CppObjectType = Object;
using CppClassType = Object_Class;
using BaseObjectType = GObject;
using BaseClassType = GObjectClass;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
// noncopyable
Object(const Object&) = delete;
Object& operator=(const Object&) = delete;
Object(Object&& src) noexcept;
Object& operator=(Object&& src) noexcept;
protected:
Object(); // For use by C++-only sub-types.
explicit Object(const Glib::ConstructParams& construct_params);
explicit Object(GObject* castitem);
~Object() noexcept override; // It should only be deleted by the callback.
public:
// static RefPtr