1 #ifndef _GLIBMM_INTERFACE_H
2 #define _GLIBMM_INTERFACE_H
3 
4 /* Copyright 2002 The gtkmm Development Team
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include <glibmm/object.h>
21 
22 namespace Glib
23 {
24 
25 #ifndef DOXYGEN_SHOULD_SKIP_THIS
26 class GLIBMM_API Interface_Class;
27 #endif
28 
29 // There is no base GInterface struct in Glib, though there is G_TYPE_INTERFACE enum value.
30 class GLIBMM_API Interface : virtual public Glib::ObjectBase
31 {
32 public:
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34   using CppObjectType = Interface;
35   using CppClassType = Interface_Class;
36   using BaseClassType = GTypeInterface;
37 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
38 
39   /** A Default constructor.
40    */
41   Interface();
42 
43   Interface(Interface&& src) noexcept;
44   Interface& operator=(Interface&& src) noexcept;
45 
46   /** Called by constructors of derived classes. Provide the result of
47    * the Class object's init() function to ensure that it is properly
48    * initialized.
49    *
50    * @param interface_class The Class object for the derived type.
51    */
52   explicit Interface(const Glib::Interface_Class& interface_class);
53 
54   /** Called by constructors of derived classes.
55    *
56    * @param castitem A C instance that will be wrapped by the new
57    * C++ instance. This does not take a reference, so call reference()
58    * if necessary.
59    */
60   explicit Interface(GObject* castitem);
61   ~Interface() noexcept override;
62 
63   // noncopyable
64   Interface(const Interface&) = delete;
65   Interface& operator=(const Interface&) = delete;
66 
67 // void add_interface(GType gtype_implementer);
68 
69 // Hook for translating API
70 // static Glib::Interface* wrap_new(GTypeInterface*);
71 
72 #ifndef DOXYGEN_SHOULD_SKIP_THIS
73   static GType get_type() G_GNUC_CONST;
74   static GType get_base_type() G_GNUC_CONST;
75 #endif
76 
gobj()77   inline GObject* gobj() { return gobject_; }
gobj()78   inline const GObject* gobj() const { return gobject_; }
79 };
80 
81 GLIBMM_API
82 RefPtr<ObjectBase> wrap_interface(GObject* object, bool take_copy = false);
83 
84 } // namespace Glib
85 
86 #endif /* _GLIBMM_INTERFACE_H */
87