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

scim_frontend_module.h

Go to the documentation of this file.
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.13.2.1 2004/09/28 05:18:32 liuspider 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 IMEngineFactory 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 IMEngineFactory instances.
00093      * @param config - a smart pointer points to a ConfigBase instance.
00094      * @param argc - the number of (fake) command line arguments
00095      * @param argv - the (fake) command line argument vector
00096      */
00097     FrontEndModule (const String          &name,
00098                     const BackEndPointer  &backend,
00099                     const ConfigPointer   &config,
00100                     int                    argc,
00101                     char                 **argv);
00102 
00103     /**
00104      * @brief Load a FrontEnd module by its name.
00105      *
00106      * Load a module into memory.
00107      * If another module has been loaded into this object,
00108      * then the old module will be unloaded first.
00109      * If the old module is resident, false will be returned,
00110      * and the old module will be untouched.
00111      *
00112      * @param name - the module's name, eg. "rawcode".
00113      * @param backend - a BackEnd instance which holds all IMEngineFactory instances.
00114      * @param config - a smart pointer points to a ConfigBase instance.
00115      * @param argc - the number of (fake) command line arguments
00116      * @param argv - the (fake) command line argument vector
00117      */
00118     bool load  (const String          &name,
00119                 const BackEndPointer  &backend,
00120                 const ConfigPointer   &config,
00121                 int                    argc,
00122                 char                 **argv);
00123 
00124     /**
00125      * @brief Check if a module is loaded and initialized successfully.
00126      * @return true if a module is already loaded and initialized successfully.
00127      */
00128     bool valid () const;
00129 
00130     /**
00131      * @brief run this FrontEnd module.
00132      */
00133     void run () const;
00134 };
00135 
00136 /**
00137  * @brief Get a name list of currently available frontend modules.
00138  * @param mod_list - the result list will be stored here.
00139  * @return the number of the modules, equal to mod_list.size ().
00140  */
00141 int scim_get_frontend_module_list (std::vector <String>& mod_list);
00142 
00143 /** @} */
00144 
00145 } // namespace scim
00146 
00147 #endif //__SCIM_FRONTEND_MODULE_H
00148 
00149 /*
00150 vi:ts=4:ai:nowrap:expandtab
00151 */

Generated on Tue Apr 19 00:10:59 2005 for scim by  doxygen 1.4.1