00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */ 00002 00003 /* 00004 * Copyright (c) 2007 Ciaran McCreesh 00005 * 00006 * This file is part of the Paludis package manager. Paludis is free software; 00007 * you can redistribute it and/or modify it under the terms of the GNU General 00008 * Public License version 2, as published by the Free Software Foundation. 00009 * 00010 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY 00011 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00013 * details. 00014 * 00015 * You should have received a copy of the GNU General Public License along with 00016 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00017 * Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00020 #ifndef PALUDIS_GUARD_PALUDIS_QUERY_HH 00021 #define PALUDIS_GUARD_PALUDIS_QUERY_HH 1 00022 00023 #include <paludis/name-fwd.hh> 00024 #include <paludis/query-fwd.hh> 00025 #include <paludis/package_id-fwd.hh> 00026 #include <paludis/environment-fwd.hh> 00027 #include <paludis/dep_spec-fwd.hh> 00028 #include <paludis/query_delegate-fwd.hh> 00029 #include <paludis/util/fs_entry-fwd.hh> 00030 #include <iosfwd> 00031 00032 /** \file 00033 * Declarations for Query and the various query:: classes. 00034 * 00035 * \ingroup g_query 00036 * 00037 * \section Examples 00038 * 00039 * - \ref example_query.cc "example_query.cc" 00040 * - \ref example_query_delegate.cc "example_query_delegate.cc" 00041 * - \ref example_match_package.cc "example_match_package.cc" 00042 */ 00043 00044 namespace paludis 00045 { 00046 /** 00047 * Parameter for a PackageDatabase query. 00048 * 00049 * Holds a QueryDelegate to perform actual operations, so that it can be 00050 * copied without splicing problems. 00051 * 00052 * \see QueryDelegate 00053 * \see PackageDatabase::query 00054 * \ingroup g_query 00055 * \nosubgrouping 00056 */ 00057 class PALUDIS_VISIBLE Query 00058 { 00059 friend Query operator& (const Query &, const Query &); 00060 friend std::ostream & operator<< (std::ostream &, const Query &); 00061 00062 private: 00063 tr1::shared_ptr<const QueryDelegate> _d; 00064 00065 protected: 00066 ///\name Basic operations 00067 ///\{ 00068 00069 Query(tr1::shared_ptr<const QueryDelegate>); 00070 00071 public: 00072 ~Query(); 00073 00074 ///\} 00075 00076 ///\name Delegate-implemented functions 00077 ///\{ 00078 00079 tr1::shared_ptr<RepositoryNameSequence> repositories(const Environment & e) const; 00080 00081 tr1::shared_ptr<CategoryNamePartSet> categories(const Environment & e, 00082 tr1::shared_ptr<const RepositoryNameSequence> r) const; 00083 00084 tr1::shared_ptr<QualifiedPackageNameSet> packages(const Environment & e, 00085 tr1::shared_ptr<const RepositoryNameSequence> r, 00086 tr1::shared_ptr<const CategoryNamePartSet> c) const; 00087 00088 tr1::shared_ptr<PackageIDSequence> ids(const Environment & e, 00089 tr1::shared_ptr<const RepositoryNameSequence> r, 00090 tr1::shared_ptr<const QualifiedPackageNameSet> q) const; 00091 00092 ///\} 00093 }; 00094 00095 /** 00096 * Various Query classes. 00097 * 00098 * \see Query 00099 * \ingroup g_query 00100 */ 00101 namespace query 00102 { 00103 /** 00104 * Fetch packages matching a given PackageDepSpec. 00105 * 00106 * \see Query 00107 * \see PackageDatabase::query 00108 * \ingroup g_query 00109 * \nosubgrouping 00110 */ 00111 class PALUDIS_VISIBLE Matches : 00112 public Query 00113 { 00114 public: 00115 ///\name Basic operations 00116 ///\{ 00117 00118 Matches(const PackageDepSpec &); 00119 00120 ///\} 00121 }; 00122 00123 /** 00124 * Fetch packages with a given package name. 00125 * 00126 * \see Query 00127 * \see PackageDatabase::query 00128 * \ingroup g_query 00129 * \nosubgrouping 00130 */ 00131 class PALUDIS_VISIBLE Package : 00132 public Query 00133 { 00134 public: 00135 ///\name Basic operations 00136 ///\{ 00137 00138 Package(const QualifiedPackageName &); 00139 00140 ///\} 00141 }; 00142 00143 /** 00144 * Fetch packages in a given repository. 00145 * 00146 * \see Query 00147 * \see PackageDatabase::query 00148 * \ingroup g_query 00149 * \nosubgrouping 00150 */ 00151 class PALUDIS_VISIBLE Repository : 00152 public Query 00153 { 00154 public: 00155 ///\name Basic operations 00156 ///\{ 00157 00158 Repository(const RepositoryName &); 00159 00160 ///\} 00161 }; 00162 00163 /** 00164 * Fetch packages in a given category. 00165 * 00166 * \see Query 00167 * \see PackageDatabase::query 00168 * \ingroup g_query 00169 * \nosubgrouping 00170 */ 00171 class PALUDIS_VISIBLE Category : 00172 public Query 00173 { 00174 public: 00175 ///\name Basic operations 00176 ///\{ 00177 00178 Category(const CategoryNamePart &); 00179 00180 ///\} 00181 }; 00182 00183 /** 00184 * Fetch packages that are not masked. 00185 * 00186 * \see Query 00187 * \see PackageDatabase::query 00188 * \ingroup g_query 00189 * \nosubgrouping 00190 */ 00191 class PALUDIS_VISIBLE NotMasked : 00192 public Query 00193 { 00194 public: 00195 ///\name Basic operations 00196 ///\{ 00197 00198 NotMasked(); 00199 00200 ///\} 00201 }; 00202 00203 /** 00204 * Fetch packages that support a particular action. 00205 * 00206 * \see Query 00207 * \see PackageDatabase::query 00208 * \ingroup g_query 00209 * \nosubgrouping 00210 */ 00211 template <typename A_> 00212 class PALUDIS_VISIBLE SupportsAction : 00213 public Query 00214 { 00215 public: 00216 ///\name Basic operations 00217 ///\{ 00218 00219 SupportsAction(); 00220 00221 ///\} 00222 }; 00223 00224 /** 00225 * Fetch packages that maybe support a particular action. 00226 * 00227 * A full SupportsAction<> on an ebuild ID requires a metadata load, 00228 * since unsupported EAPIs don't support any actions. MaybeSupportsAction, 00229 * on the other hand, only uses Repository::some_ids_might_support_action, 00230 * so it does not incur a penalty but may return additional results. 00231 * 00232 * \see Query 00233 * \see PackageDatabase::query 00234 * \ingroup g_query 00235 * \nosubgrouping 00236 */ 00237 template <typename A_> 00238 class PALUDIS_VISIBLE MaybeSupportsAction : 00239 public Query 00240 { 00241 public: 00242 ///\name Basic operations 00243 ///\{ 00244 00245 MaybeSupportsAction(); 00246 00247 ///\} 00248 }; 00249 00250 /** 00251 * Fetch packages that are installed at a particular root. 00252 * 00253 * \see Query 00254 * \see PackageDatabase::query 00255 * \ingroup g_query 00256 * \nosubgrouping 00257 */ 00258 class PALUDIS_VISIBLE InstalledAtRoot : 00259 public Query 00260 { 00261 public: 00262 ///\name Basic operations 00263 ///\{ 00264 00265 InstalledAtRoot(const FSEntry &); 00266 00267 ///} 00268 }; 00269 00270 /** 00271 * Fetch all packages. 00272 * 00273 * \see Query 00274 * \see PackageDatabase::query 00275 * \ingroup g_query 00276 * \nosubgrouping 00277 */ 00278 class PALUDIS_VISIBLE All : 00279 public Query 00280 { 00281 public: 00282 ///\name Basic operations 00283 ///\{ 00284 00285 All(); 00286 00287 ///} 00288 }; 00289 } 00290 } 00291 00292 #endif
1.5.5