1 /**
2  * @file scim_filter_manager.h
3  * @brief Defines scim::FilterManager.
4  *
5  * scim::FilterManager is a class used to manage all Filter modules.
6  *
7  */
8 
9 /*
10  * Smart Common Input Method
11  *
12  * Copyright (c) 2005 James Su <suzhe@tsinghua.org.cn>
13  *
14  *
15  * This library is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU Lesser General Public
17  * License as published by the Free Software Foundation; either
18  * version 2 of the License, or (at your option) any later version.
19  *
20  * This library is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU Lesser General Public License for more details.
24  *
25  * You should have received a copy of the GNU Lesser General Public
26  * License along with this program; if not, write to the
27  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
28  * Boston, MA  02111-1307  USA
29  *
30  * $Id: scim_filter_manager.h,v 1.3 2005/05/28 13:54:59 suzhe Exp $
31  */
32 
33 #ifndef __SCIM_FILTER_MANAGER_H
34 #define __SCIM_FILTER_MANAGER_H
35 
36 namespace scim {
37 
38 /**
39  * @addtogroup IMEngine
40  * @{
41  */
42 
43 class FilterManager
44 {
45     class FilterManagerImpl;
46     FilterManagerImpl *m_impl;
47 
48     FilterManager (const FilterManager &);
49     const FilterManager & operator = (const FilterManager &);
50 
51 public:
52     FilterManager (const ConfigPointer &config);
53 
54     ~FilterManager ();
55 
56     /**
57      * @brief Get the total number of Filters supported by all filter modules.
58      */
59     unsigned int number_of_filters () const;
60 
61     /**
62      * @brief Get the information of a specific filter by its index.
63      *
64      * @param idx The index of the filter, must between 0 to number_of_filters () - 1.
65      * @param info The FilterInfo object to store the information.
66      * @return true if this filter is ok and the information is stored correctly.
67      */
68     bool get_filter_info (unsigned int idx, FilterInfo &info) const;
69 
70     /**
71      * @brief Get the information of a specific filter by its uuid.
72      *
73      * @param uuid The uuid of the filter.
74      * @param info The FilterInfo object to store the information.
75      * @return true if this filter is ok and the information is stored correctly.
76      */
77     bool get_filter_info (const String &uuid, FilterInfo &info) const;
78 
79     /**
80      * @brief Clear all Filter settings for IMEngines.
81      */
82     void   clear_all_filter_settings () const;
83 
84     /**
85      * @brief Get a list of Filters binded to an IMEngine.
86      *
87      * @param uuid The uuid of the IMEngine to be queried.
88      * @param filters The list of Filters' UUIDs binded to the IMEngine will be stored here.
89      *
90      * @return How many filters binded to this IMEngine.
91      */
92     size_t get_filters_for_imengine (const String &uuid, std::vector <String> &filters) const;
93 
94     /**
95      * @brief Bind one or more Filters to an IMEngine.
96      *
97      * @param uuid The uuid of the IMEngine to be binded.
98      * @param filters The list of Filters' UUIDs to be binded to the IMEngine.
99      */
100     void   set_filters_for_imengine (const String &uuid, const std::vector <String> &filters) const;
101 
102     /**
103      * @brief Get a list of imengines which have one or more filters attached.
104      *
105      * @param imengines The UUIDs of filtered imengines will be stored here.
106      * @return How many imengines are being filtered.
107      */
108     size_t get_filtered_imengines (std::vector <String> &imengines) const;
109 
110     /**
111      * @brief Create a FilterFactory according to its index.
112      *
113      * @param idx The index of the filter to be created, must be less than number_of_filters() - 1.
114      * @return The pointer of the FilterFactory object.
115      */
116     FilterFactoryPointer create_filter (unsigned int idx) const;
117 
118     /**
119      * @brief Create a FilterFactory according to its UUID.
120      *
121      * @param uuid The UUID of the filter to be created.
122      * @return The pointer of the FilterFactory object.
123      */
124     FilterFactoryPointer create_filter (const String &uuid) const;
125 
126     /**
127      * @brief Attach all binded Filters to an IMEngineFactory object.
128      *
129      * @param factory The pointer to an IMEngineFactory object which would be filtered.
130      *
131      * @return New pointer of IMEngineFactory object which has Filters binded.
132      */
133     IMEngineFactoryPointer attach_filters_to_factory (const IMEngineFactoryPointer &factory) const;
134 };
135 
136 /** @} */
137 
138 } // namespace scim
139 
140 #endif //__SCIM_FILTER_MANAGER_H
141 
142 /*
143 vi:ts=4:nowrap:ai:expandtab
144 */
145 
146