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

scim_server_module.h

Go to the documentation of this file.
00001 /** @file scim_server_module.h
00002  *  @brief definition of ServerModule 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_server_module.h,v 1.14 2004/03/06 15:48:11 suzhe Exp $
00029  */
00030 
00031 #ifndef __SCIM_SERVER_MODULE_H
00032 #define __SCIM_SERVER_MODULE_H
00033 
00034 namespace scim {
00035 /**
00036  * @addtogroup Server
00037  * @{
00038  */
00039 
00040 /**
00041  * @brief Initialize a Server Module.
00042  *
00043  * There must be a function called "scim_server_module_init"
00044  * in each server 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 Server Module.
00050  */
00051 typedef unsigned int (*ServerModuleInitFunc) (const ConfigPointer &config);
00052 
00053 /**
00054  * @brief Create a factory instance for a server,
00055  *
00056  * There must be a function called "scim_server_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 server - the number of the server for which a factory instance will be created.
00062  * @return the pointer of the factory instance.
00063  */
00064 typedef ServerFactoryPointer (*ServerModuleCreateFactoryFunc) (unsigned int server);
00065 
00066 /**
00067  * @brief The class to manipulate the server modules.
00068  *
00069  * This is a wrapper of scim::Module class, which is specially
00070  * for manipulating the server modules.
00071  */
00072 class ServerModule
00073 {
00074     Module m_module;
00075 
00076     ServerModuleInitFunc m_server_init;
00077     ServerModuleCreateFactoryFunc m_server_create_factory;
00078 
00079     unsigned int m_number_of_servers;
00080 
00081     ServerModule (const ServerModule &);
00082     ServerModule & operator= (const ServerModule &);
00083 
00084 public:
00085     /**
00086      * @brief Default constructor.
00087      */
00088     ServerModule ();
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     ServerModule (const String &name, const ConfigPointer &config);
00096 
00097     /**
00098      * @brief Load a Server 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 Server 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 Server 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 server factories supported by this module.
00126      *
00127      * @return the number of server factories.
00128      */
00129     unsigned int number_of_servers () const;
00130 
00131     /**
00132      * @brief Create a server instance for a server factory.
00133      *
00134      * @param server - the sequence number of this server factory,
00135      *                 must be less than the result of number_of_servers method
00136      *                 and greater than zero.
00137      * @return A smart pointer to the server instance, NULL if failed.
00138      */
00139     ServerFactoryPointer create_factory (unsigned int server) const;
00140 };
00141 
00142 /**
00143  * @brief Get a name list of currently available server modules.
00144  * @param mod_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_server_module_list (std::vector <String>& mod_list);
00148 
00149 /** @} */
00150 
00151 } // namespace scim
00152 
00153 #endif //__SCIM_SERVER_MODULE_H
00154 
00155 /*
00156 vi:ts=4:ai:nowrap:expandtab
00157 */

Generated on Fri May 7 17:27:25 2004 for scim by doxygen 1.3.6