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

scim_backend.h

Go to the documentation of this file.
00001 /** @file scim_backend.h
00002  *  @brief scim::BackEndBase Interface.
00003  *
00004  *  Provide an abstract interface class to
00005  *  manage a set of ServerFactory instances.
00006  */
00007 
00008 /* 
00009  * Smart Common Input Method
00010  * 
00011  * Copyright (c) 2004 James Su <suzhe@turbolinux.com.cn>
00012  * Copyright (c) 2003 James Su <suzhe@turbolinux.com.cn>
00013  * Copyright (c) 2002 James Su <suzhe@turbolinux.com.cn>
00014  *
00015  *
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2 of the License, or (at your option) any later version.
00020  *
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  * GNU Lesser General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this program; if not, write to the
00028  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00029  * Boston, MA  02111-1307  USA
00030  *
00031  * $Id: scim_backend.h,v 1.13 2004/02/06 07:53:15 suzhe Exp $
00032  */
00033 
00034 #ifndef __SCIM_BACKEND_H
00035 #define __SCIM_BACKEND_H
00036 
00037 namespace scim {
00038 
00039 /**
00040  * @brief An exception class to hold BackEnd related errors.
00041  *
00042  * scim::BackEndBase and its derived classes must throw
00043  * scim::BackEndError object when error.
00044  */
00045 class BackEndError: public Exception
00046 {
00047 public:
00048     BackEndError (const String& what_arg)
00049         : Exception (String("scim::BackEnd: ") + what_arg) { }
00050 };
00051 
00052 /**
00053  * @brief The interface class to manage a set of ServerFactory instances.
00054  *
00055  * This is mainly a helper interface class used by scim::FrontEndBase.
00056  * Its responsibility is to hold a set of ServerFactory instances
00057  * and manage the locales list supported by them. 
00058  * 
00059  * Most developer should just use the default implementation
00060  * scim::CommonBackEnd.
00061  */
00062 class BackEndBase : public ReferencedObject
00063 {
00064 public:
00065     /**
00066      * @brief Virtual destructor
00067      */
00068     virtual ~BackEndBase ();
00069 
00070     /**
00071      * @brief Get a list of all locales supported by all FrontEnds.
00072      * @return A comma separated locales list.
00073      */
00074     virtual String get_locales () const = 0;
00075 
00076     /**
00077      * @brief Get the total number of ServerFactory instances held by this BackEnd.
00078      * @return The total number of ServerFactory instances in this BackEnd.
00079      */
00080     virtual unsigned int number_of_servers () const = 0;
00081 
00082     /**
00083      * @brief Get a ServerFactory instance by its index.
00084      * @return The ServerFactoryPointer according to the index.
00085      */
00086     virtual ServerFactoryPointer get_server_factory (unsigned int index) = 0;
00087 };
00088 
00089 /**
00090  * @typedef typedef Pointer <BackEndBase> BackEndPointer;
00091  *
00092  * A smart pointer for scim::BackEndBase and its derived classes.
00093  */
00094 typedef Pointer <BackEndBase> BackEndPointer;
00095 
00096 /**
00097  * @brief The default implementation of scim::BackEndBase interface.
00098  */
00099 class CommonBackEnd : public BackEndBase
00100 {
00101     typedef std::vector<ServerFactoryPointer> ServerFactoryPool;
00102 
00103     ServerFactoryPool m_factories;
00104 
00105     String m_supported_unicode_locales;
00106 
00107 public:
00108     virtual String get_locales () const;
00109     virtual unsigned int number_of_servers () const;
00110     virtual ServerFactoryPointer get_server_factory (unsigned int index);
00111 
00112 public:
00113     /**
00114      * @brief Add a ServerFactory instance into this BackEnd.
00115      * @param factory - the smart pointer of the ServerFactory instance.
00116      */
00117     bool add_server_factory (const ServerFactoryPointer &factory);
00118 
00119     /**
00120      * @brief Set the list of unicode locales which should be supported
00121      *        among the other locales.
00122      * @param locales - the comma separated list of unicode locales should be supported.
00123      */
00124     void set_supported_unicode_locales (const String &locales);
00125 
00126     /**
00127      * @brief Get the list of supported unicode locales which set by
00128      *        set_supported_unicode_locales
00129      * @return The comma separated list of supported unicode locales.
00130      */
00131     String get_supported_unicode_locales () const;
00132 };
00133 
00134 } // namespace scim
00135 
00136 #endif //__SCIM_BACKEND_H
00137 
00138 /*
00139 vi:ts=4:nowrap:ai:expandtab
00140 */

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