/* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General * Public License version 2, as published by the Free Software Foundation. * * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef PALUDIS_GUARD_PALUDIS_FILTER_HH #define PALUDIS_GUARD_PALUDIS_FILTER_HH 1 #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** \file * Declarations for the Filter class. * * \ingroup g_selections * * \section Examples * * - \ref example_selection.cc "example_selection.cc" */ namespace paludis { /** * A Filter subclass can be used to further restrict the values picked by a * Generator, which when combined together produces a FilteredGenerator * which can be passed to a Selection subclass. * * \ingroup g_selections */ class PALUDIS_VISIBLE Filter { private: Pimp _imp; protected: Filter(const std::shared_ptr &); public: ///\name Basic operations ///\{ /** * Filter subclasses can be copied without losing information. */ Filter(const Filter &); Filter & operator= (const Filter &); ~Filter(); ///\} /** * A Filter can be represented as a string, for use by operator<<. */ std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result)); ///\name For use by Selection ///\{ /** * Return any RepositoryContentMayExcludes that are implied by this * filter. * * \since 0.59 */ const RepositoryContentMayExcludes may_excludes() const PALUDIS_ATTRIBUTE((warn_unused_result)); /** * Filter candidate repository names. */ std::shared_ptr repositories( const Environment * const, const std::shared_ptr &) const PALUDIS_ATTRIBUTE((warn_unused_result)); /** * Filter candidate category names. */ std::shared_ptr categories( const Environment * const, const std::shared_ptr &, const std::shared_ptr &) const PALUDIS_ATTRIBUTE((warn_unused_result)); /** * Filter candidate package names. */ std::shared_ptr packages( const Environment * const, const std::shared_ptr &, const std::shared_ptr &) const PALUDIS_ATTRIBUTE((warn_unused_result)); /** * Filter candidate PackageID instances. */ std::shared_ptr ids( const Environment * const, const std::shared_ptr &) const PALUDIS_ATTRIBUTE((warn_unused_result)); ///\} }; namespace filter { /** * A Filter which accepts all PackageID instances. * * \ingroup g_selections */ class PALUDIS_VISIBLE All : public Filter { public: All(); }; /** * A Filter which accepts only PackageID instances which support a given * Action subclass. * * \ingroup g_selections */ template class PALUDIS_VISIBLE SupportsAction : public Filter { public: SupportsAction(); }; /** * A Filter which accepts only PackageID instances which are not masked. * * \ingroup g_selections */ class PALUDIS_VISIBLE NotMasked : public Filter { public: NotMasked(); }; /** * A Filter which accepts only PackageID instances that are installed to * a particular root. * * \ingroup g_selections */ class PALUDIS_VISIBLE InstalledAtRoot : public Filter { public: InstalledAtRoot(const FSPath &); }; /** * A Filter which accepts only PackageID instances that are installed but * not in a particular root. * * \ingroup g_selections */ class PALUDIS_VISIBLE InstalledNotAtRoot : public Filter { public: InstalledNotAtRoot(const FSPath &); }; /** * A Filter which accepts only PackageID instances that are installed to * the / fs. * * \ingroup g_selections * \since 0.51 */ class PALUDIS_VISIBLE InstalledAtSlash : public Filter { public: InstalledAtSlash(); }; /** * A Filter which accepts only PackageID instances that are installed to * an fs other than /. * * \ingroup g_selections * \since 0.51 */ class PALUDIS_VISIBLE InstalledAtNotSlash : public Filter { public: InstalledAtNotSlash(); }; /** * A Filter which accepts only PackageID instances that are accepted by * two different filters. * * Used internally by FilteredGenerator. * * \ingroup g_selections */ class PALUDIS_VISIBLE And : public Filter { public: And(const Filter &, const Filter &); }; /** * A Filter which accepts only PackageID instances that have the same * slot as the specified PackageID, or, if the specified PackageID has * no slot, that have no slot. * * \ingroup g_selections */ class PALUDIS_VISIBLE SameSlot : public Filter { public: SameSlot(const std::shared_ptr &); }; /** * A Filter which accepts only PackageID instances that have a * particular slot. * * \ingroup g_selections */ class PALUDIS_VISIBLE Slot : public Filter { public: Slot(const SlotName &); }; /** * A Filter which accepts only PackageID instances that have no slot. * * \ingroup g_selections */ class PALUDIS_VISIBLE NoSlot : public Filter { public: NoSlot(); }; /** * A Filter which accepts only PackageID instances that match a * particular PackageDepSpec. * * \ingroup g_selections */ class PALUDIS_VISIBLE Matches : public Filter { public: /** * \param spec_id The PackageID the spec comes from. May be null. Used * for [use=] style dependencies. * * \since 0.58 takes spec_id */ Matches( const PackageDepSpec &, const std::shared_ptr & from_id, const MatchPackageOptions &); }; } extern template class Pimp; extern template class filter::SupportsAction; extern template class filter::SupportsAction; extern template class filter::SupportsAction; extern template class filter::SupportsAction; extern template class filter::SupportsAction; extern template class filter::SupportsAction; extern template class filter::SupportsAction; } #endif