Git init
[framework/uifw/isf.git] / ism / src / scim_config_module.h
1 /** @file scim_config_module.h
2  *  @brief Define scim::ConfigModule class for manipulating the config modules.
3  *
4  *  Class scim::ConfigModule is a wrapper of class scim::Module,
5  *  which is for manipulating the configuration modules.
6  */
7
8 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
9
10 /*
11  * Smart Common Input Method
12  *
13  * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn>
14  *
15  *
16  * This library is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU Lesser General Public
18  * License as published by the Free Software Foundation; either
19  * version 2 of the License, or (at your option) any later version.
20  *
21  * This library is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU Lesser General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public
27  * License along with this program; if not, write to the
28  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
29  * Boston, MA  02111-1307  USA
30  *
31  * $Id: scim_config_module.h,v 1.15 2005/04/09 15:38:39 suzhe Exp $
32  */
33
34 #ifndef __SCIM_CONFIG_MODULE_H
35 #define __SCIM_CONFIG_MODULE_H
36
37 namespace scim {
38 /**
39  * @addtogroup Config
40  * @ingroup InputServiceFramework
41  * @{
42  */
43
44 /**
45  * @brief The prototype of initialization function in config modules.
46  *
47  * There must be a function called "scim_config_module_init"
48  * which complies with this prototype.
49  * This function name can have a prefix like simple_LTX_,
50  * in which "simple" is the module's name.
51  */
52 typedef void (*ConfigModuleInitFunc) (void);
53
54 /**
55  * @brief The prototype of configure object creation function in config modules.
56  *
57  * There must be a function called "scim_config_module_create_config"
58  * which complies with this prototype.
59  * This function name can have a prefix like simple_LTX_,
60  * in which "simple" is the module's name.
61  */
62 typedef ConfigPointer (*ConfigModuleCreateConfigFunc) ();
63
64 /**
65  * @brief The class to manipulate the config modules.
66  *
67  * This is a wrapper of scim::Module class, which is specially
68  * for manipulating the config modules.
69  */
70 class ConfigModule
71 {
72     Module      m_module;
73
74     ConfigModuleInitFunc m_config_init;
75     ConfigModuleCreateConfigFunc m_config_create_config;
76
77     ConfigModule (const ConfigModule &);
78     ConfigModule & operator= (const ConfigModule &);
79
80 public:
81     /**
82      * @brief Default constructor.
83      */
84     ConfigModule ();
85
86     /**
87      * @brief Constructor.
88      * @param name - the module's name, eg. "simple".
89      */
90     ConfigModule (const String &name);
91
92     /**
93      * @brief Load a module by its name.
94      *
95      * Load a module into memory.
96      * If another module has been loaded into this object,
97      * then the old module will be unloaded first.
98      * If the old module is resident, false will be returned,
99      * and the old module will be untouched.
100      *
101      * @param name - the module's name, eg. "simple".
102      * @return true if success.
103      */
104     bool load  (const String &name);
105
106     /**
107      * @brief Check if a module is loaded and initialized successfully.
108      * @return true if a module is already loaded and initialized successfully.
109      */
110     bool valid () const;
111
112     /**
113      * @brief Create a configuration object from this module.
114      *
115      * The type of newly created configuration object
116      * must be a derived class of scim::ConfigBase.
117      *
118      * @return a smart pointer points to the configuration object.
119      */
120     ConfigPointer create_config () const;
121 };
122
123 /**
124  * @brief Get a name list of currently available configuration modules.
125  * @param mod_list - the result list will be stored here.
126  * @return the number of the modules, equal to mod_list.size ().
127  */
128 int scim_get_config_module_list (std::vector <String>& mod_list);
129
130 /** @} */
131
132 } // namespace scim
133
134 #endif //__SCIM_CONFIG_MODULE_H
135
136 /*
137 vi:ts=4:ai:nowrap:expandtab
138 */