Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# type.h

Go to the documentation of this file.

    00001 /*  Inti: Integrated Foundation Classes
    00002  *  Copyright (C) 2002 The Inti Development Team.
    00003  *
    00004  *  This program is free software; you can redistribute it and/or modify
    00005  *  it under the terms of the GNU General Public License as published by
    00006  *  the Free Software Foundation; either version 2 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  This program is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Library General Public License
    00015  *  along with this program; if not, write to the Free Software
    00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00017  */
    00018
    00021
    00022 #ifndef INTI_G_TYPE_H
    00023 #define INTI_G_TYPE_H
    00024
    00025 #ifndef INTI_BASE_H
    00026 #include <inti/base.h>
    00027 #endif
    00028
    00029 #ifndef INTI_G_SIGNALS_H
    00030 #include <inti/glib/signals.h>
    00031 #endif
    00032
    00033 #ifndef INTI_UTF_STRING_H
    00034 #include <inti/utf-string.h>
    00035 #endif
    00036
    00037 namespace Inti {
    00038
    00039 namespace G {
    00040
    00050
    00051 class TypeInstance : virtual public ReferencedBase
    00052 {
    00053         TypeInstance(const TypeInstance&);
    00054         TypeInstance& operator=(const TypeInstance&);
    00055
    00056 protected:
    00057         TypeInstance();
    00059
    00060         virtual ~TypeInstance() = 0;
    00062
    00063         GTypeInstance *instance;
    00065
    00066 public:
    00069
    00070         GTypeInstance* g_type_instance() const { return instance; }
    00072
    00073         template<typename T>
    00074         T* get_class() const
    00075         { return reinterpret_cast<T*>(instance->g_class); }
    00078
    00079         bool is_a(GType type) const;
    00083
    00084         GType type() const;
    00086
    00087         String type_name() const;
    00089
    00090         bool is_a_type(GType ancestor_type) const;
    00094
    00095         GType parent_type() const;
    00096         // Get the GType of the immediate parent for the instance, or 0 if it has no parent.
    00097
    00101
    00102         void add_interface(GType interface_type, GInterfaceInitFunc interface_init);
    00106
    00108
    00109         static void add_interface(GType instance_type, GType interface_type, GInterfaceInitFunc interface_init);
    00114
    00115         static GType register_type(GType parent_type, GClassInitFunc class_init);
    00120
    00121         template<typename T>
    00122         static T* class_peek_parent(void *g_class)
    00123         { return static_cast<T*>(g_type_class_peek_parent(g_class)); }
    00132
    00133 };
    00134
    00137
    00138 class TypeInterface : virtual public TypeInstance
    00139 {
    00140 public:
    00143
    00144         virtual ~TypeInterface() = 0;
    00146
    00147         GTypeInterface* g_type_interface() const;
    00149
    00150         template<typename T>
    00151         T* peek(GType type) const
    00152         { return static_cast<T*>(g_type_interface_peek(instance->g_class, type)); }
    00156
    00158
    00159         template<typename T>
    00160         static T* peek_parent(void *g_iface)
    00161         { return static_cast<T*>(g_type_interface_peek_parent(g_iface)); }
    00165 };
    00166
    00167 } // namespace G
    00168
    00169 } // namespace Inti
    00170
    00171 #endif // INTI_G_TYPE_H
    00172

Main Page - Footer