diff options
author | Peng Wu <alexepico@gmail.com> | 2014-01-28 13:47:31 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-01-28 13:47:31 +0800 |
commit | e5b3d415d3d70495be81f8cfbc6b18340b5310b9 (patch) | |
tree | d9fabbfefb12279d106b822894310643305588f6 /src/ZYObject.h | |
parent | 4585f181a1e46edeeba9f2808b8d55745c0aba98 (diff) | |
download | ibus-libzhuyin-e5b3d415d3d70495be81f8cfbc6b18340b5310b9.tar.gz ibus-libzhuyin-e5b3d415d3d70495be81f8cfbc6b18340b5310b9.tar.xz ibus-libzhuyin-e5b3d415d3d70495be81f8cfbc6b18340b5310b9.zip |
import ZYObject.h
Diffstat (limited to 'src/ZYObject.h')
-rw-r--r-- | src/ZYObject.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/ZYObject.h b/src/ZYObject.h new file mode 100644 index 0000000..5613a07 --- /dev/null +++ b/src/ZYObject.h @@ -0,0 +1,54 @@ +/* vim:set et ts=4 sts=4: + * + * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus + * + * Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef __ZY_OBJECT_H_ +#define __ZY_OBJECT_H_ + +#include <glib-object.h> +#include "ZYPointer.h" + +namespace ZY { + +class Object { +protected: + template <typename T> + Object (T *p) : m_p ((GObject *)p) + { + g_assert (get <GObject *>() != NULL); + } + + operator GObject * (void) const + { + return m_p; + } + + template <typename T> + T * get (void) const + { + return (T *) (GObject *) m_p; + } + +private: + Pointer<GObject> m_p; +}; + +}; + +#endif |