00001 /** @file scim_frontend_module.h 00002 * @brief definition of FrontEndModule 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_frontend_module.h,v 1.12 2004/02/12 09:40:12 suzhe Exp $ 00029 */ 00030 00031 #ifndef __SCIM_FRONTEND_MODULE_H 00032 #define __SCIM_FRONTEND_MODULE_H 00033 00034 namespace scim { 00035 00036 /** 00037 * @addtogroup FrontEnd 00038 * @{ 00039 */ 00040 00041 /** 00042 * @brief Initialize a FrontEnd Module. 00043 * 00044 * There must be a function called "scim_frontend_module_init" 00045 * in each frontend module which complies with this prototype. 00046 * This function name can have a prefix like x11_LTX_, 00047 * in which "x11" is the module's name. 00048 * 00049 * @param backend - a BackEnd instance which hold all ServerFactory instances. 00050 * @param config - a ConfigBase instance to maintain the configuration. 00051 */ 00052 typedef void (*FrontEndModuleInitFunc) (const BackEndPointer &backend, 00053 const ConfigPointer &config, 00054 int argc, 00055 char **argv); 00056 00057 /** 00058 * @brief Run a FrontEnd Module. 00059 * 00060 * There must be a function called "scim_frontend_module_run" 00061 * in each frontend module which complies with this prototype. 00062 * This function name can have a prefix like x11_LTX_, 00063 * in which "x11" is the module's name. 00064 */ 00065 typedef void (*FrontEndModuleRunFunc) (void); 00066 00067 /** 00068 * @brief The class to manipulate the frontend modules. 00069 * 00070 * This is a wrapper of scim::Module class, which is specially 00071 * for manipulating the frontend modules. 00072 */ 00073 class FrontEndModule 00074 { 00075 Module m_module; 00076 00077 FrontEndModuleInitFunc m_frontend_init; 00078 FrontEndModuleRunFunc m_frontend_run; 00079 00080 FrontEndModule (const FrontEndModule &); 00081 FrontEndModule & operator= (const FrontEndModule &); 00082 00083 public: 00084 /** 00085 * @brief Default constructor. 00086 */ 00087 FrontEndModule (); 00088 00089 /** 00090 * @brief Constructor. 00091 * @param name - the module's name, eg. "rawcode". 00092 * @param backend - a BackEnd instance which holds all ServerFactory instances. 00093 * @param config - a smart pointer points to a ConfigBase instance. 00094 */ 00095 FrontEndModule (const String &name, 00096 const BackEndPointer &backend, 00097 const ConfigPointer &config, 00098 int argc, 00099 char **argv); 00100 00101 /** 00102 * @brief Load a FrontEnd module by its name. 00103 * 00104 * Load a module into memory. 00105 * If another module has been loaded into this object, 00106 * then the old module will be unloaded first. 00107 * If the old module is resident, false will be returned, 00108 * and the old module will be untouched. 00109 * 00110 * @param name - the module's name, eg. "rawcode". 00111 * @param backend - a BackEnd instance which holds all ServerFactory instances. 00112 * @param config - a smart pointer points to a ConfigBase instance. 00113 */ 00114 bool load (const String &name, 00115 const BackEndPointer &backend, 00116 const ConfigPointer &config, 00117 int argc, 00118 char **argv); 00119 00120 /** 00121 * @brief Check if a module is loaded and initialized successfully. 00122 * @return true if a module is already loaded and initialized successfully. 00123 */ 00124 bool valid () const; 00125 00126 /** 00127 * @brief run this FrontEnd module. 00128 */ 00129 void run () const; 00130 }; 00131 00132 /** 00133 * @brief Get a name list of currently available frontend modules. 00134 * @param mod_list - the result list will be stored here. 00135 * @return the number of the modules, equal to mod_list.size (). 00136 */ 00137 int scim_get_frontend_module_list (std::vector <String>& mod_list); 00138 00139 /** @} */ 00140 00141 } // namespace scim 00142 00143 #endif //__SCIM_FRONTEND_MODULE_H 00144 00145 /* 00146 vi:ts=4:ai:nowrap:expandtab 00147 */