paludis  Version 2.6.0
filter.hh
Go to the documentation of this file.
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2008, 2009, 2010, 2011, 2014 Ciaran McCreesh
5  *
6  * This file is part of the Paludis package manager. Paludis is free software;
7  * you can redistribute it and/or modify it under the terms of the GNU General
8  * Public License version 2, as published by the Free Software Foundation.
9  *
10  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17  * Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef PALUDIS_GUARD_PALUDIS_FILTER_HH
21 #define PALUDIS_GUARD_PALUDIS_FILTER_HH 1
22 
23 #include <paludis/filter-fwd.hh>
24 #include <paludis/filter_handler-fwd.hh>
26 #include <paludis/util/pimp.hh>
27 #include <paludis/util/set-fwd.hh>
28 #include <paludis/util/fs_path-fwd.hh>
29 #include <paludis/name-fwd.hh>
32 #include <paludis/action-fwd.hh>
33 #include <paludis/dep_spec-fwd.hh>
34 #include <paludis/match_package-fwd.hh>
36 #include <memory>
37 
38 /** \file
39  * Declarations for the Filter class.
40  *
41  * \ingroup g_selections
42  *
43  * \section Examples
44  *
45  * - \ref example_selection.cc "example_selection.cc"
46  */
47 
48 namespace paludis
49 {
50  /**
51  * A Filter subclass can be used to further restrict the values picked by a
52  * Generator, which when combined together produces a FilteredGenerator
53  * which can be passed to a Selection subclass.
54  *
55  * \ingroup g_selections
56  */
58  {
59  private:
60  Pimp<Filter> _imp;
61 
62  protected:
63  Filter(const std::shared_ptr<const FilterHandler> &);
64 
65  public:
66  ///\name Basic operations
67  ///\{
68 
69  /**
70  * Filter subclasses can be copied without losing information.
71  */
72  Filter(const Filter &);
73  Filter & operator= (const Filter &);
74  ~Filter();
75 
76  ///\}
77 
78  /**
79  * A Filter can be represented as a string, for use by operator<<.
80  */
81  std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
82 
83  ///\name For use by Selection
84  ///\{
85 
86  /**
87  * Return any RepositoryContentMayExcludes that are implied by this
88  * filter.
89  *
90  * \since 0.59
91  */
92  const RepositoryContentMayExcludes may_excludes() const PALUDIS_ATTRIBUTE((warn_unused_result));
93 
94  /**
95  * Filter candidate repository names.
96  */
97  std::shared_ptr<const RepositoryNameSet> repositories(
98  const Environment * const,
99  const std::shared_ptr<const RepositoryNameSet> &) const
100  PALUDIS_ATTRIBUTE((warn_unused_result));
101 
102  /**
103  * Filter candidate category names.
104  */
105  std::shared_ptr<const CategoryNamePartSet> categories(
106  const Environment * const,
107  const std::shared_ptr<const RepositoryNameSet> &,
108  const std::shared_ptr<const CategoryNamePartSet> &) const
109  PALUDIS_ATTRIBUTE((warn_unused_result));
110 
111  /**
112  * Filter candidate package names.
113  */
114  std::shared_ptr<const QualifiedPackageNameSet> packages(
115  const Environment * const,
116  const std::shared_ptr<const RepositoryNameSet> &,
117  const std::shared_ptr<const QualifiedPackageNameSet> &) const
118  PALUDIS_ATTRIBUTE((warn_unused_result));
119 
120  /**
121  * Filter candidate PackageID instances.
122  */
123  std::shared_ptr<const PackageIDSet> ids(
124  const Environment * const,
125  const std::shared_ptr<const PackageIDSet> &) const
126  PALUDIS_ATTRIBUTE((warn_unused_result));
127 
128  ///\}
129  };
130 
131  namespace filter
132  {
133  /**
134  * A Filter which accepts all PackageID instances.
135  *
136  * \ingroup g_selections
137  */
139  public Filter
140  {
141  public:
142  All();
143  };
144 
145  /**
146  * A Filter which accepts only PackageID instances which support a given
147  * Action subclass.
148  *
149  * \ingroup g_selections
150  */
151  template <typename>
152  class PALUDIS_VISIBLE SupportsAction :
153  public Filter
154  {
155  public:
156  SupportsAction();
157  };
158 
159  /**
160  * A Filter which accepts only PackageID instances which are not masked.
161  *
162  * \ingroup g_selections
163  */
165  public Filter
166  {
167  public:
168  NotMasked();
169  };
170 
171  /**
172  * A Filter which accepts only PackageID instances that are installed to
173  * a particular root.
174  *
175  * \ingroup g_selections
176  */
178  public Filter
179  {
180  public:
181  InstalledAtRoot(const FSPath &);
182  };
183 
184  /**
185  * A Filter which accepts only PackageID instances that are installed but
186  * not in a particular root.
187  *
188  * \ingroup g_selections
189  */
191  public Filter
192  {
193  public:
194  InstalledNotAtRoot(const FSPath &);
195  };
196 
197  /**
198  * A Filter which accepts only PackageID instances that are installed to
199  * the / fs.
200  *
201  * \ingroup g_selections
202  * \since 0.51
203  */
205  public Filter
206  {
207  public:
209  };
210 
211  /**
212  * A Filter which accepts only PackageID instances that are installed to
213  * an fs other than /.
214  *
215  * \ingroup g_selections
216  * \since 0.51
217  */
219  public Filter
220  {
221  public:
223  };
224 
225  /**
226  * A Filter which accepts only PackageID instances that are accepted by
227  * two different filters.
228  *
229  * Used internally by FilteredGenerator.
230  *
231  * \ingroup g_selections
232  */
234  public Filter
235  {
236  public:
237  And(const Filter &, const Filter &);
238  };
239 
240  /**
241  * A Filter which accepts only PackageID instances that have the same
242  * slot as the specified PackageID, or, if the specified PackageID has
243  * no slot, that have no slot.
244  *
245  * \ingroup g_selections
246  */
248  public Filter
249  {
250  public:
251  SameSlot(const std::shared_ptr<const PackageID> &);
252  };
253 
254  /**
255  * A Filter which accepts only PackageID instances that have a
256  * particular slot.
257  *
258  * \ingroup g_selections
259  */
261  public Filter
262  {
263  public:
264  Slot(const SlotName &);
265  };
266 
267  /**
268  * A Filter which accepts only PackageID instances that have no slot.
269  *
270  * \ingroup g_selections
271  */
273  public Filter
274  {
275  public:
276  NoSlot();
277  };
278 
279  /**
280  * A Filter which accepts only PackageID instances that match a
281  * particular PackageDepSpec.
282  *
283  * \ingroup g_selections
284  */
286  public Filter
287  {
288  public:
289  /**
290  * \param spec_id The PackageID the spec comes from. May be null. Used
291  * for [use=] style dependencies.
292  *
293  * \since 0.58 takes spec_id
294  */
295  Matches(
296  const PackageDepSpec &,
297  const std::shared_ptr<const PackageID> & from_id,
298  const MatchPackageOptions &);
299  };
300 
301  /**
302  * A Filter which rejects PackageIDs using a function.
303  *
304  * \ingroup g_selections
305  * \since 2.0
306  */
308  public Filter
309  {
310  public:
311  ByFunction(
312  const std::function<bool (const std::shared_ptr<const PackageID> &)> &,
313  const std::string &);
314  };
315  }
316 
317  extern template class Pimp<Filter>;
325 }
326 
327 #endif
Definition: pimp.hh:51
Definition: filter.hh:247
Definition: about_metadata-fwd.hh:23
Definition: filter.hh:218
Definition: filter.hh:177
Definition: filter.hh:138
Definition: filter.hh:233
Definition: filter.hh:57
Definition: filter.hh:285
Definition: filter.hh:307
Definition: dep_spec.hh:345
Definition: environment.hh:200
Definition: filter.hh:272
Definition: filter.hh:164
Definition: wrapped_value-fwd.hh:29
Definition: options-fwd.hh:34
Definition: filter.hh:260
Definition: fs_path.hh:33
Definition: filter.hh:190
Definition: filter.hh:204
Definition: filter-fwd.hh:39
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59