Git init
[profile/ivi/isf.git] / ism / src / scim_imengine_module.h
1 /** @file scim_imengine_module.h
2  *  @brief definition of IMEngineModule 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_imengine_module.h,v 1.4 2005/01/10 08:30:54 suzhe Exp $
29  */
30
31 #ifndef __SCIM_IMENGINE_MODULE_H
32 #define __SCIM_IMENGINE_MODULE_H
33
34 namespace scim {
35 /**
36  * @addtogroup IMEngine
37  * @ingroup InputServiceFramework
38  * @{
39  */
40
41 /**
42  * @brief Initialize a IMEngine Module.
43  *
44  * There must be a function called "scim_imengine_module_init"
45  * in each imengine module which complies with this prototype.
46  * This function name can have a prefix like table_LTX_,
47  * in which "table" is the module's name.
48  *
49  * @param config - a ConfigBase instance to maintain the configuration.
50  * @return the number of factories supported by this IMEngine Module.
51  */
52 typedef unsigned int (*IMEngineModuleInitFunc) (const ConfigPointer &config);
53
54 /**
55  * @brief Create a factory instance for an engine,
56  *
57  * There must be a function called "scim_imengine_module_create_factory"
58  * which complies with this prototype.
59  * This function name can have a prefix like table_LTX_,
60  * in which "table" is the module's name.
61  *
62  * @param engine - the index of the engine for which a factory object will be created.
63  * @return the pointer of the factory object.
64  */
65 typedef IMEngineFactoryPointer (*IMEngineModuleCreateFactoryFunc) (unsigned int engine);
66
67 /**
68  * @brief The class to manipulate the IMEngine modules.
69  *
70  * This is a wrapper of scim::Module class, which is specially
71  * for manipulating the IMEngine modules.
72  */
73 class IMEngineModule
74 {
75     Module m_module;
76     String m_module_name;
77
78     IMEngineModuleInitFunc m_imengine_init;
79     IMEngineModuleCreateFactoryFunc m_imengine_create_factory;
80
81     unsigned int m_number_of_factories;
82
83     IMEngineModule (const IMEngineModule &);
84     IMEngineModule & operator= (const IMEngineModule &);
85
86 public:
87     /**
88      * @brief Default constructor.
89      */
90     IMEngineModule ();
91
92     /**
93      * @brief Constructor.
94      * @param name - the module's name, eg. "rawcode".
95      * @param config - a smart pointer points to a ConfigBase instance.
96      */
97     IMEngineModule (const String &name, const ConfigPointer &config);
98
99     /**
100      * @brief Load a IMEngine Module by its name.
101      *
102      * Load a module into memory.
103      * If another module has been loaded into this object,
104      * then the old module will be unloaded first.
105      * If the old module is resident, false will be returned,
106      * and the old module will be untouched.
107      *
108      * @param name - the name of the IMEngine Module.
109      * @param config - the ConfigBase instance to be used for storing/loading configs.
110      * @return true if success.
111      */
112     bool load  (const String &name, const ConfigPointer &config);
113
114     /**
115      * @brief Unload the IMEngine Module.
116      * @return true if sucessfully unloaded.
117      */
118     bool unload ();
119
120     /**
121      * @brief Check if a module is loaded and initialized successfully.
122      * @return true if a module is already loaded and initialized successfully.
123      */
124     bool valid () const;
125
126     /**
127      * @brief Get how many IMEngine factories supported by this module.
128      *
129      * @return the number of IMEngine factories.
130      */
131     unsigned int number_of_factories ();
132
133     /**
134      * @brief Create an object for an IMEngine factory.
135      *
136      * @param engine - the index of this IMEngine factory,
137      *                 must be less than the result of number_of_factories method
138      *                 and greater than or equal to zero.
139      * @return A smart pointer to the factory object, NULL if failed.
140      */
141     IMEngineFactoryPointer create_factory (unsigned int engine) const;
142
143     String get_module_name () const;
144 };
145
146 /**
147  * @brief Get a name list of currently available IMEngine modules.
148  * @param mod_list - the result list will be stored here.
149  * @return the number of the modules, equal to mod_list.size ().
150  */
151 int scim_get_imengine_module_list (std::vector <String> &mod_list);
152
153 /** @} */
154
155 } // namespace scim
156
157 #endif //__SCIM_IMENGINE_MODULE_H
158
159 /*
160 vi:ts=4:ai:nowrap:expandtab
161 */