summaryrefslogtreecommitdiff
path: root/glib/glibmm/class.h
blob: 7092d506ff8fd25ace2ac0694a20d2aa318633e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// -*- c++ -*-
#ifndef _GLIBMM_CLASS_H
#define _GLIBMM_CLASS_H

/* $Id$ */

/* Copyright 2001 Free Software Foundation
 * Copyright (C) 1998-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, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <glib-object.h>
#include <glibmmconfig.h> //Include this here so that the /private/*.h classes have access to GLIBMM_VFUNCS_ENABLED

#include <vector> //For properties that custom types might override.

#ifndef DOXYGEN_SHOULD_SKIP_THIS

namespace Glib
{

class Class
{
public:
  /* No constructor/destructor:
   * Glib::Class objects are used only as static data, which would cause
   * lots of ugly global constructor invocations.  These are avoidable,
   * because the C/C++ standard explicitly specifies that all _static_ data
   * is zero-initialized at program start.
   */
  //Class();
  //~Class();

  //static void class_init_function(BaseClassType *p);
  //static void object_init_function(BaseObjectType *o);
  //GType get_type() = 0; //Creates the GType when this is first called.

  // Hook for translating API
  //static Glib::Object* wrap_new(GObject*);

  inline GType get_type() const;
  GType clone_custom_type(const char* custom_type_name) const;

protected:
  GType           gtype_;
  GClassInitFunc  class_init_func_;

  /** Register a GType, derived from the @a base_type.
   */
  void register_derived_type(GType base_type);

  /** Register a GType, derived from the @a base_type.
   * @param module If this is not 0 then g_type_module_register_type() will be used. Otherwise g_type_register_static() will be used.
   */
  void register_derived_type(GType base_type, GTypeModule* module);

protected:
  static void interface_finalize_function(void* g_iface, void* iface_data);

private:
  static void custom_class_init_function(void* g_class, void* class_data);

public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  // The type that holds the values of the properties of custom types.
  typedef std::vector<GValue*> properties_type;
  // The quark used for storing/getting the properties of custom types.
  static GQuark properties_quark;
#endif
};

inline
GType Class::get_type() const
{
  return gtype_;
}

} // namespace Glib

#endif /* DOXYGEN_SHOULD_SKIP_THIS */

#endif /* _GLIBMM_CLASS_H */