clean up PYConfig.h/cc
[platform/upstream/ibus-libpinyin.git] / src / PYLibPinyin.h
1 /* vim:set et ts=4 sts=4:
2  *
3  * ibus-pinyin - The Chinese PinYin engine for IBus
4  *
5  * Copyright (c) 2011 Peng Wu <alexepico@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., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #ifndef __PY_LIB_PINYIN_H_
23 #define __PY_LIB_PINYIN_H_
24
25 #include <memory>
26 #include <glib.h>
27
28 typedef struct _pinyin_context_t pinyin_context_t;
29 typedef struct _pinyin_instance_t pinyin_instance_t;
30
31 namespace PY {
32
33 class Config;
34
35 class LibPinyinBackEnd{
36
37 public:
38     LibPinyinBackEnd();
39     ~LibPinyinBackEnd();
40
41     gboolean setPinyinOptions (Config *config);
42     gboolean setChewingOptions (Config *config);
43
44     pinyin_instance_t *allocPinyinInstance ();
45     void freePinyinInstance (pinyin_instance_t *instance);
46     pinyin_instance_t *allocChewingInstance ();
47     void freeChewingInstance (pinyin_instance_t *instance);
48     void modified (void);
49
50     /* use static initializer in C++. */
51     static LibPinyinBackEnd & instance (void) { return *m_instance; }
52
53     static void init (void);
54     static void finalize (void);
55
56
57 private:
58     gboolean saveUserDB (void);
59     static gboolean timeoutCallback (gpointer data);
60
61 private:
62     /* libpinyin context */
63     pinyin_context_t *m_pinyin_context;
64     pinyin_context_t *m_chewing_context;
65
66     guint m_timeout_id;
67     GTimer *m_timer;
68
69 private:
70     static std::unique_ptr<LibPinyinBackEnd> m_instance;
71 };
72
73 };
74
75 #endif