1 /** @file scim_imengine_module.h
2 * @brief definition of IMEngineModule related classes.
5 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
8 * Smart Common Input Method
10 * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn>
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.
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.
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
28 * $Id: scim_imengine_module.h,v 1.4 2005/01/10 08:30:54 suzhe Exp $
31 #ifndef __SCIM_IMENGINE_MODULE_H
32 #define __SCIM_IMENGINE_MODULE_H
36 * @addtogroup IMEngine
37 * @ingroup InputServiceFramework
42 * @brief Initialize a IMEngine Module.
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.
49 * @param config - a ConfigBase instance to maintain the configuration.
50 * @return the number of factories supported by this IMEngine Module.
52 typedef unsigned int (*IMEngineModuleInitFunc) (const ConfigPointer &config);
55 * @brief Create a factory instance for an engine,
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.
62 * @param engine - the index of the engine for which a factory object will be created.
63 * @return the pointer of the factory object.
65 typedef IMEngineFactoryPointer (*IMEngineModuleCreateFactoryFunc) (unsigned int engine);
68 * @brief The class to manipulate the IMEngine modules.
70 * This is a wrapper of scim::Module class, which is specially
71 * for manipulating the IMEngine modules.
78 IMEngineModuleInitFunc m_imengine_init;
79 IMEngineModuleCreateFactoryFunc m_imengine_create_factory;
81 unsigned int m_number_of_factories;
83 IMEngineModule (const IMEngineModule &);
84 IMEngineModule & operator= (const IMEngineModule &);
88 * @brief Default constructor.
94 * @param name - the module's name, eg. "rawcode".
95 * @param config - a smart pointer points to a ConfigBase instance.
97 IMEngineModule (const String &name, const ConfigPointer &config);
100 * @brief Load a IMEngine Module by its name.
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.
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.
112 bool load (const String &name, const ConfigPointer &config);
115 * @brief Unload the IMEngine Module.
116 * @return true if sucessfully unloaded.
121 * @brief Check if a module is loaded and initialized successfully.
122 * @return true if a module is already loaded and initialized successfully.
127 * @brief Get how many IMEngine factories supported by this module.
129 * @return the number of IMEngine factories.
131 unsigned int number_of_factories ();
134 * @brief Create an object for an IMEngine factory.
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.
141 IMEngineFactoryPointer create_factory (unsigned int engine) const;
143 String get_module_name () const;
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 ().
151 int scim_get_imengine_module_list (std::vector <String> &mod_list);
157 #endif //__SCIM_IMENGINE_MODULE_H
160 vi:ts=4:ai:nowrap:expandtab