1 /** @file scim_backend.h
2 * @brief definition of scim::BackEnd class.
4 * Class scim::BackEnd is used to load and manage IMEngine
5 * modules and IMEngineFactories.
8 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
11 * Smart Common Input Method
13 * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn>
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.
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.
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
31 * $Id: scim_backend.h,v 1.26 2005/10/06 18:02:06 liuspider Exp $
34 #ifndef __SCIM_BACKEND_H
35 #define __SCIM_BACKEND_H
40 * @brief An exception class to hold BackEnd related errors.
42 * scim::BackEndBase and its derived classes must throw
43 * scim::BackEndError object when error.
45 class BackEndError: public Exception
48 BackEndError (const String& what_arg)
49 : Exception (String("scim::BackEnd: ") + what_arg) { }
53 * @brief The interface class to manage a set of IMEngineFactory
54 * and IMEngineInstance objects.
56 * This is mainly an accessory interface class used by scim::FrontEndBase.
57 * Its responsibility is to hold a set of IMEngineFactory instances
58 * and manage the locales list supported by them.
60 * Most developer should just use the default implementation
61 * scim::CommonBackEnd.
63 class BackEndBase : public ReferencedObject
65 class BackEndBaseImpl;
67 BackEndBaseImpl *m_impl;
71 * @brief Default constructor.
73 * @param config Config object to be used.
75 BackEndBase (const ConfigPointer &config);
77 virtual ~BackEndBase ();
81 * @brief Get a list of all locales supported by all IMEngineFactories.
82 * @return A comma separated locales list.
84 String get_all_locales () const;
87 * @return Return the pointer of a Factory.
89 * @param uuid The uuid of the IMEngineFactory.
91 IMEngineFactoryPointer get_factory (const String &uuid) const;
94 virtual void initialize (const ConfigPointer &config,
95 const std::vector<String> &modules,
96 const bool is_load_resource,
97 const bool is_load_info) = 0;
99 virtual int add_module (const ConfigPointer &config,
101 bool is_load_resource) = 0;
103 virtual void add_module_info (const ConfigPointer &config,
104 const String module_name) = 0;
106 virtual void add_factory_by_uuid (const ConfigPointer &config,
107 const String uuid) = 0;
109 virtual void release_module (const std::vector<String> &use_uuids,
110 const String del_uuid) = 0;
114 * @name Methods to manipulate IMEngine Factories.
120 * @brief Get the IMEngine factories list for specific encoding
122 * @param factories the vector to store the factories which
123 * support the encoding.
124 * @param encoding the encoding to be queried. If empty,
125 * all IMEngine factories will be returned.
127 * @return the number of IMEngine factories found.
129 uint32 get_factories_for_encoding (std::vector<IMEngineFactoryPointer> &factories, const String &encoding = String ("")) const;
132 * @brief Get the IMEngine factories list for specific language
134 * @param factories the vector to store the factories which
135 * support the encoding.
136 * @param language the language to be queried. If empty,
137 * all IMEngine factories will be returned.
139 * @return the number of IMEngine factories found.
141 uint32 get_factories_for_language (std::vector<IMEngineFactoryPointer> &factories, const String &language = String ("")) const;
143 uint32 get_factory_list (std::vector<String> &uuids) const;
146 * @brief Get the default IMEngineFactory for a specific language and encoding.
148 * @param language the language to be queried.
149 * @param encoding the encoding to be queried, if empty then don't match encoding.
151 * @return the pointer of the default IMEngineFactory for this language.
153 IMEngineFactoryPointer get_default_factory (const String &language, const String &encoding) const;
156 * @brief Set the default IMEngineFactory for a specific language.
158 * @param language the language to be set.
159 * @param uuid the uuid of the default IMEngineFactory for this language.
161 void set_default_factory (const String &language, const String &uuid);
164 * @brief Get the next IMEngineFactory for a specific language and encoding.
166 * @param language the language to be queried, if empty then don't match language.
167 * @param encoding the encoding to be queried, if empty then don't match encoding.
168 * @param cur_uuid the UUID of current IMEngineFactory.
170 * @return the pointer of the next IMEngineFactory for this language and encoding
171 * corresponding to the current IMEngineFactory.
173 IMEngineFactoryPointer get_next_factory (const String &language, const String &encoding, const String &cur_uuid) const;
176 * @brief Get the previous IMEngineFactory for a specific language and encoding.
178 * @param language the language to be queried, if empty then don't match language.
179 * @param encoding the encoding to be queried, if empty then don't match encoding.
180 * @param cur_uuid the UUID of current IMEngineFactory.
182 * @return the pointer of the previous IMEngineFactory for this language and encoding
183 * corresponding to the current IMEngineFactory.
185 IMEngineFactoryPointer get_previous_factory (const String &language, const String &encoding, const String &cur_uuid) const;
193 bool add_factory (const IMEngineFactoryPointer &factory);
195 void add_specific_factory (const String &uuid, const IMEngineFactoryPointer &factory);
200 void dump_factories ();
204 * @typedef typedef Pointer <BackEnd> BackEndPointer;
206 * A smart pointer for scim::BackEndBase and its derived classes.
208 typedef Pointer <BackEndBase> BackEndPointer;
211 * @brief The default implementation of scim::BackEndBase interface.
213 class CommonBackEnd : public BackEndBase
215 class CommonBackEndImpl;
216 CommonBackEndImpl *m_impl;
222 * @param config The pointer to the Config object.
223 * @param modules The list of the IMEngine modules to be loaded.
225 CommonBackEnd (const ConfigPointer &config,
226 const std::vector<String> &modules);
227 virtual ~CommonBackEnd ();
229 virtual void initialize (const ConfigPointer &config,
230 const std::vector<String> &modules,
231 const bool is_load_resource,
232 const bool is_load_info);
234 virtual int add_module (const ConfigPointer &config,
236 bool is_load_resource);
238 virtual void add_module_info (const ConfigPointer &config,
239 const String module_name);
241 virtual void add_factory_by_uuid (const ConfigPointer &config,
244 virtual void release_module (const std::vector<String> &use_uuids,
245 const String del_uuid);
247 void add_module_info_from_cache_file (const ConfigPointer &config,
248 std::vector<String> &modules);
250 void update_module_info (const ConfigPointer &config,
251 std::vector<String> ¤t_modules,
252 std::vector<String> &modules);
254 void add_imengine_module_info (const String module_name,
255 const ConfigPointer &config);
259 } /* namespace scim */
261 #endif /*__SCIM_BACKEND_H */
264 vi:ts=4:nowrap:ai:expandtab