fixes compile
[platform/upstream/ibus-libpinyin.git] / src / PYObject.h
1 /* vim:set et ts=4 sts=4:
2  *
3  * ibus-libpinyin - Intelligent Pinyin engine based on libpinyin for IBus
4  *
5  * Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20  */
21 #ifndef __PY_OBJECT_H_
22 #define __PY_OBJECT_H_
23
24 #include <glib-object.h>
25 #include "PYPointer.h"
26
27 namespace PY {
28
29 class Object {
30 protected:
31     template <typename T>
32     Object (T *p) : m_p ((GObject *)p)
33     {
34         g_assert (get <GObject *>() != NULL);
35     }
36
37     operator GObject * (void) const
38     {
39         return m_p;
40     }
41
42     template <typename T>
43     T * get (void) const
44     {
45         return (T *) (GObject *) m_p;
46     }
47
48 private:
49     Pointer<GObject> m_p;
50 };
51
52 };
53
54 #endif