Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

scim_imengine_module.h

Go to the documentation of this file.
00001 /** @file scim_imengine_module.h 00002 * @brief definition of IMEngineModule related classes. 00003 */ 00004 00005 /* 00006 * Smart Common Input Method 00007 * 00008 * Copyright (c) 2004 James Su <suzhe@turbolinux.com.cn> 00009 * Copyright (c) 2003 James Su <suzhe@turbolinux.com.cn> 00010 * Copyright (c) 2002 James Su <suzhe@turbolinux.com.cn> 00011 * 00012 * 00013 * This library is free software; you can redistribute it and/or 00014 * modify it under the terms of the GNU Lesser General Public 00015 * License as published by the Free Software Foundation; either 00016 * version 2 of the License, or (at your option) any later version. 00017 * 00018 * This library is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU Lesser General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public 00024 * License along with this program; if not, write to the 00025 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00026 * Boston, MA 02111-1307 USA 00027 * 00028 * $Id: scim_imengine_module.h,v 1.1.2.1 2004/09/28 05:18:32 liuspider Exp $ 00029 */ 00030 00031 #ifndef __SCIM_IMENGINE_MODULE_H 00032 #define __SCIM_IMENGINE_MODULE_H 00033 00034 namespace scim { 00035 /** 00036 * @addtogroup IMEngine 00037 * @{ 00038 */ 00039 00040 /** 00041 * @brief Initialize a IMEngine Module. 00042 * 00043 * There must be a function called "scim_imengine_module_init" 00044 * in each imengine module which complies with this prototype. 00045 * This function name can have a prefix like table_LTX_, 00046 * in which "table" is the module's name. 00047 * 00048 * @param config - a ConfigBase instance to maintain the configuration. 00049 * @return the number of factories supported by this IMEngine Module. 00050 */ 00051 typedef unsigned int (*IMEngineModuleInitFunc) (const ConfigPointer &config); 00052 00053 /** 00054 * @brief Create a factory instance for an engine, 00055 * 00056 * There must be a function called "scim_imengine_module_create_factory" 00057 * which complies with this prototype. 00058 * This function name can have a prefix like table_LTX_, 00059 * in which "table" is the module's name. 00060 * 00061 * @param engine - the index of the engine for which a factory object will be created. 00062 * @return the pointer of the factory object. 00063 */ 00064 typedef IMEngineFactoryPointer (*IMEngineModuleCreateFactoryFunc) (unsigned int engine); 00065 00066 /** 00067 * @brief The class to manipulate the IMEngine modules. 00068 * 00069 * This is a wrapper of scim::Module class, which is specially 00070 * for manipulating the IMEngine modules. 00071 */ 00072 class IMEngineModule 00073 { 00074 Module m_module; 00075 00076 IMEngineModuleInitFunc m_imengine_init; 00077 IMEngineModuleCreateFactoryFunc m_imengine_create_factory; 00078 00079 unsigned int m_number_of_factories; 00080 00081 IMEngineModule (const IMEngineModule &); 00082 IMEngineModule & operator= (const IMEngineModule &); 00083 00084 public: 00085 /** 00086 * @brief Default constructor. 00087 */ 00088 IMEngineModule (); 00089 00090 /** 00091 * @brief Constructor. 00092 * @param name - the module's name, eg. "rawcode". 00093 * @param config - a smart pointer points to a ConfigBase instance. 00094 */ 00095 IMEngineModule (const String &name, const ConfigPointer &config); 00096 00097 /** 00098 * @brief Load a IMEngine Module by its name. 00099 * 00100 * Load a module into memory. 00101 * If another module has been loaded into this object, 00102 * then the old module will be unloaded first. 00103 * If the old module is resident, false will be returned, 00104 * and the old module will be untouched. 00105 * 00106 * @param name - the name of the IMEngine Module. 00107 * @param config - the ConfigBase instance to be used for storing/loading configs. 00108 * @return true if success. 00109 */ 00110 bool load (const String &name, const ConfigPointer &config); 00111 00112 /** 00113 * @brief Unload the IMEngine Module. 00114 * @return true if sucessfully unloaded. 00115 */ 00116 bool unload (); 00117 00118 /** 00119 * @brief Check if a module is loaded and initialized successfully. 00120 * @return true if a module is already loaded and initialized successfully. 00121 */ 00122 bool valid () const; 00123 00124 /** 00125 * @brief Get how many IMEngine factories supported by this module. 00126 * 00127 * @return the number of IMEngine factories. 00128 */ 00129 unsigned int number_of_factories () const; 00130 00131 /** 00132 * @brief Create an object for an IMEngine factory. 00133 * 00134 * @param engine - the index of this IMEngine factory, 00135 * must be less than the result of number_of_factories method 00136 * and greater than or equal to zero. 00137 * @return A smart pointer to the factory object, NULL if failed. 00138 */ 00139 IMEngineFactoryPointer create_factory (unsigned int engine) const; 00140 }; 00141 00142 /** 00143 * @brief Get a name list of currently available IMEngine modules. 00144 * @param engine_list - the result list will be stored here. 00145 * @return the number of the modules, equal to mod_list.size (). 00146 */ 00147 int scim_get_imengine_module_list (std::vector <String>& engine_list); 00148 00149 /** @} */ 00150 00151 } // namespace scim 00152 00153 #endif //__SCIM_IMENGINE_MODULE_H 00154 00155 /* 00156 vi:ts=4:ai:nowrap:expandtab 00157 */

Generated on Thu Dec 30 21:03:19 2004 for scim by doxygen 1.3.8