Git init
[framework/uifw/isf.git] / ism / src / scim_frontend_module.h
1 /** @file scim_frontend_module.h
2  * @brief definition of FrontEndModule related classes.
3  */
4
5 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
6
7 /*
8  * Smart Common Input Method
9  *
10  * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn>
11  *
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this program; if not, write to the
25  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
26  * Boston, MA  02111-1307  USA
27  *
28  * $Id: scim_frontend_module.h,v 1.16 2005/01/10 08:30:54 suzhe Exp $
29  */
30
31 #ifndef __SCIM_FRONTEND_MODULE_H
32 #define __SCIM_FRONTEND_MODULE_H
33
34 namespace scim {
35
36 /**
37  * @addtogroup FrontEnd
38  * @ingroup InputServiceFramework
39  * @{
40  */
41
42 /**
43  * @brief Initialize a FrontEnd Module.
44  *
45  * There must be a function called "scim_frontend_module_init"
46  * in each frontend module which complies with this prototype.
47  * This function name can have a prefix like x11_LTX_,
48  * in which "x11" is the module's name.
49  *
50  * @param backend - a BackEnd instance which hold all IMEngineFactory instances.
51  * @param config - a ConfigBase instance to maintain the configuration.
52  */
53 typedef void (*FrontEndModuleInitFunc) (const BackEndPointer &backend,
54                                         const ConfigPointer &config,
55                                         int argc,
56                                         char **argv);
57
58 /**
59  * @brief Run a FrontEnd Module.
60  *
61  * There must be a function called "scim_frontend_module_run"
62  * in each frontend module which complies with this prototype.
63  * This function name can have a prefix like x11_LTX_,
64  * in which "x11" is the module's name.
65  */
66 typedef void (*FrontEndModuleRunFunc)  (void);
67
68 /**
69  * @brief The class to manipulate the frontend modules.
70  *
71  * This is a wrapper of scim::Module class, which is specially
72  * for manipulating the frontend modules.
73  */
74 class FrontEndModule
75 {
76     Module       m_module;
77
78     FrontEndModuleInitFunc m_frontend_init;
79     FrontEndModuleRunFunc m_frontend_run;
80
81     FrontEndModule (const FrontEndModule &);
82     FrontEndModule & operator= (const FrontEndModule &);
83
84 public:
85     /**
86      * @brief Default constructor.
87      */
88     FrontEndModule ();
89
90     /**
91      * @brief Constructor.
92      * @param name - the module's name, eg. "rawcode".
93      * @param backend - a BackEnd instance which holds all IMEngineFactory instances.
94      * @param config - a smart pointer points to a ConfigBase instance.
95      * @param argc - the number of (fake) command line arguments
96      * @param argv - the (fake) command line argument vector
97      */
98     FrontEndModule (const String          &name,
99                     const BackEndPointer  &backend,
100                     const ConfigPointer   &config,
101                     int                    argc,
102                     char                 **argv);
103
104     /**
105      * @brief Load a FrontEnd module by its name.
106      *
107      * Load a module into memory.
108      * If another module has been loaded into this object,
109      * then the old module will be unloaded first.
110      * If the old module is resident, false will be returned,
111      * and the old module will be untouched.
112      *
113      * @param name - the module's name, eg. "rawcode".
114      * @param backend - a BackEnd instance which holds all IMEngineFactory instances.
115      * @param config - a smart pointer points to a ConfigBase instance.
116      * @param argc - the number of (fake) command line arguments
117      * @param argv - the (fake) command line argument vector
118      */
119     bool load  (const String          &name,
120                 const BackEndPointer  &backend,
121                 const ConfigPointer   &config,
122                 int                    argc,
123                 char                 **argv);
124
125     /**
126      * @brief Check if a module is loaded and initialized successfully.
127      * @return true if a module is already loaded and initialized successfully.
128      */
129     bool valid () const;
130
131     /**
132      * @brief run this FrontEnd module.
133      */
134     void run () const;
135 };
136
137 /**
138  * @brief Get a name list of currently available frontend modules.
139  * @param mod_list - the result list will be stored here.
140  * @return the number of the modules, equal to mod_list.size ().
141  */
142 int scim_get_frontend_module_list (std::vector <String>& mod_list);
143
144 /** @} */
145
146 } // namespace scim
147
148 #endif //__SCIM_FRONTEND_MODULE_H
149
150 /*
151 vi:ts=4:ai:nowrap:expandtab
152 */