dep_list.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2005, 2006, 2007, 2008 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_DEP_LIST_HH
00021 #define PALUDIS_GUARD_PALUDIS_DEP_LIST_HH 1
00022 
00023 #include <paludis/dep_spec-fwd.hh>
00024 #include <paludis/mask-fwd.hh>
00025 #include <paludis/dep_tag.hh>
00026 #include <paludis/dep_list_options.hh>
00027 #include <paludis/dep_list-fwd.hh>
00028 #include <paludis/handled_information-fwd.hh>
00029 #include <paludis/name.hh>
00030 #include <paludis/environment.hh>
00031 #include <paludis/match_package.hh>
00032 #include <paludis/util/instantiation_policy.hh>
00033 #include <paludis/util/private_implementation_pattern.hh>
00034 #include <paludis/util/options.hh>
00035 #include <paludis/version_spec.hh>
00036 #include <tr1/functional>
00037 #include <iosfwd>
00038 
00039 /** \file
00040  * Declarations for DepList and related classes.
00041  *
00042  * \ingroup g_dep_list
00043  *
00044  * \section Examples
00045  *
00046  * - None at this time. Use InstallTask if you need to install things.
00047  */
00048 
00049 namespace paludis
00050 {
00051     namespace n
00052     {
00053         struct associated_entry;
00054         struct blocks;
00055         struct circular;
00056         struct dependency_tags;
00057         struct destination;
00058         struct downgrade;
00059         struct fall_back;
00060         struct generation;
00061         struct handled;
00062         struct installed_deps_post;
00063         struct installed_deps_pre;
00064         struct installed_deps_runtime;
00065         struct kind;
00066         struct match_package_options;
00067         struct new_slots;
00068         struct override_masks;
00069         struct package_id;
00070         struct reinstall;
00071         struct reinstall_scm;
00072         struct state;
00073         struct suggested;
00074         struct tags;
00075         struct target_type;
00076         struct uninstalled_deps_post;
00077         struct uninstalled_deps_pre;
00078         struct uninstalled_deps_runtime;
00079         struct uninstalled_deps_suggested;
00080         struct upgrade;
00081         struct use;
00082     }
00083 
00084     /**
00085      * A sequence of functions to try, in order, when overriding masks.
00086      *
00087      * \ingroup g_dep_list
00088      */
00089     typedef Sequence<std::tr1::function<bool (const PackageID &, const Mask &)> > DepListOverrideMasksFunctions;
00090 
00091     /**
00092      * An entry in a DepList.
00093      *
00094      * \see DepList
00095      * \ingroup g_dep_list
00096      * \nosubgrouping
00097      */
00098     struct DepListEntry
00099     {
00100         NamedValue<n::associated_entry, const DepListEntry *> associated_entry;
00101         NamedValue<n::destination, std::tr1::shared_ptr<Repository> > destination;
00102         NamedValue<n::generation, long> generation;
00103         NamedValue<n::handled, std::tr1::shared_ptr<const DepListEntryHandled> > handled;
00104         NamedValue<n::kind, DepListEntryKind> kind;
00105         NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
00106         NamedValue<n::state, DepListEntryState> state;
00107         NamedValue<n::tags, std::tr1::shared_ptr<DepListEntryTags> > tags;
00108     };
00109 
00110     /**
00111      * Parameters for a DepList.
00112      *
00113      * \see DepList
00114      * \ingroup g_dep_list
00115      * \nosubgrouping
00116      */
00117     struct PALUDIS_VISIBLE DepListOptions
00118     {
00119         DepListOptions();
00120 
00121         NamedValue<n::blocks, DepListBlocksOption> blocks;
00122         NamedValue<n::circular, DepListCircularOption> circular;
00123         NamedValue<n::dependency_tags, bool> dependency_tags;
00124         NamedValue<n::downgrade, DepListDowngradeOption> downgrade;
00125         NamedValue<n::fall_back, DepListFallBackOption> fall_back;
00126         NamedValue<n::installed_deps_post, DepListDepsOption> installed_deps_post;
00127         NamedValue<n::installed_deps_pre, DepListDepsOption> installed_deps_pre;
00128         NamedValue<n::installed_deps_runtime, DepListDepsOption> installed_deps_runtime;
00129         NamedValue<n::match_package_options, MatchPackageOptions> match_package_options;
00130         NamedValue<n::new_slots, DepListNewSlotsOption> new_slots;
00131         NamedValue<n::override_masks, std::tr1::shared_ptr<DepListOverrideMasksFunctions> > override_masks;
00132         NamedValue<n::reinstall, DepListReinstallOption> reinstall;
00133         NamedValue<n::reinstall_scm, DepListReinstallScmOption> reinstall_scm;
00134         NamedValue<n::suggested, DepListSuggestedOption> suggested;
00135         NamedValue<n::target_type, DepListTargetType> target_type;
00136         NamedValue<n::uninstalled_deps_post, DepListDepsOption> uninstalled_deps_post;
00137         NamedValue<n::uninstalled_deps_pre, DepListDepsOption> uninstalled_deps_pre;
00138         NamedValue<n::uninstalled_deps_runtime, DepListDepsOption> uninstalled_deps_runtime;
00139         NamedValue<n::uninstalled_deps_suggested, DepListDepsOption> uninstalled_deps_suggested;
00140         NamedValue<n::upgrade, DepListUpgradeOption> upgrade;
00141         NamedValue<n::use, DepListUseOption> use;
00142     };
00143 
00144     /**
00145      * Holds a list of dependencies in merge order.
00146      *
00147      * \ingroup g_dep_list
00148      * \nosubgrouping
00149      */
00150     class PALUDIS_VISIBLE DepList :
00151         private InstantiationPolicy<DepList, instantiation_method::NonCopyableTag>,
00152         private PrivateImplementationPattern<DepList>
00153     {
00154         protected:
00155             class AddVisitor;
00156             friend class AddVisitor;
00157 
00158             /**
00159              * Find an appropriate destination for a package.
00160              */
00161             std::tr1::shared_ptr<Repository> find_destination(const PackageID &,
00162                     const std::tr1::shared_ptr<const DestinationsSet> &);
00163 
00164             /**
00165              * Add a DepSpec with role context.
00166              */
00167             void add_in_role(const bool only_if_not_suggested_label, const DependencySpecTree::BasicNode &, const std::string & role,
00168                     const std::tr1::shared_ptr<const DestinationsSet> &);
00169 
00170             /**
00171              * Return whether we prefer the first parameter, which is installed,
00172              * over the second, which isn't.
00173              */
00174             bool prefer_installed_over_uninstalled(const PackageID &,
00175                     const PackageID &);
00176 
00177             /**
00178              * Add a package to the list.
00179              */
00180             void add_package(const std::tr1::shared_ptr<const PackageID> &, const std::tr1::shared_ptr<const DepTag> &,
00181                     const PackageDepSpec &, const std::tr1::shared_ptr<const DestinationsSet> & destinations);
00182 
00183             /**
00184              * Add an already installed package to the list.
00185              */
00186             void add_already_installed_package(const std::tr1::shared_ptr<const PackageID> &, const std::tr1::shared_ptr<const DepTag> &,
00187                     const PackageDepSpec &, const std::tr1::shared_ptr<const DestinationsSet> & destinations);
00188 
00189             /**
00190              * Add an error package to the list.
00191              */
00192             void add_error_package(const std::tr1::shared_ptr<const PackageID> &, const DepListEntryKind, const PackageDepSpec &);
00193 
00194             /**
00195              * Add predependencies.
00196              */
00197             void add_predeps(const DependencySpecTree::BasicNode &, const DepListDepsOption, const std::string &,
00198                     const std::tr1::shared_ptr<const DestinationsSet> & destinations, const bool only_if_not_suggested_label);
00199 
00200             /**
00201              * Add postdependencies.
00202              */
00203             void add_postdeps(const DependencySpecTree::BasicNode &, const DepListDepsOption, const std::string &,
00204                     const std::tr1::shared_ptr<const DestinationsSet> & destinations, const bool only_if_not_suggested_label);
00205 
00206             /**
00207              * Return whether the specified PackageID is matched by
00208              * the top level target.
00209              */
00210             bool is_top_level_target(const PackageID &) const;
00211 
00212             void add_not_top_level(
00213                     const bool only_if_not_suggested_label,
00214                     const DependencySpecTree::BasicNode &,
00215                     const std::tr1::shared_ptr<const DestinationsSet> & target_destinations);
00216 
00217         public:
00218             ///\name Basic operations
00219             ///\{
00220 
00221             DepList(const Environment * const, const DepListOptions &);
00222 
00223             virtual ~DepList();
00224 
00225             ///\}
00226 
00227             ///\name Iterate over our dependency list entries.
00228             ///\{
00229 
00230             struct IteratorTag;
00231             typedef WrappedForwardIterator<IteratorTag, DepListEntry> Iterator;
00232 
00233             struct ConstIteratorTag;
00234             typedef WrappedForwardIterator<ConstIteratorTag, const DepListEntry> ConstIterator;
00235 
00236             Iterator begin();
00237             Iterator end();
00238 
00239             ConstIterator begin() const;
00240             ConstIterator end() const;
00241 
00242             ///\}
00243 
00244             /**
00245              * Our options.
00246              */
00247             std::tr1::shared_ptr<DepListOptions> options();
00248 
00249             /**
00250              * Our options.
00251              */
00252             const std::tr1::shared_ptr<const DepListOptions> options() const;
00253 
00254             /**
00255              * Add the packages required to resolve an additional dependency
00256              * spec.
00257              */
00258             void add(const SetSpecTree &,
00259                     const std::tr1::shared_ptr<const DestinationsSet> & target_destinations);
00260 
00261             /**
00262              * Add the packages required to resolve an additional dependency
00263              * spec.
00264              */
00265             void add(const PackageDepSpec &,
00266                     const std::tr1::shared_ptr<const DestinationsSet> & target_destinations);
00267 
00268             /**
00269              * Manually add a DepListEntry to the list.
00270              *
00271              * Does not work well with ordered resolution, and does not do much
00272              * sanity checking. This is used by InstallTask to implement resume
00273              * commands and the exec command.
00274              */
00275             Iterator push_back(const DepListEntry &);
00276 
00277             /**
00278              * Clear the list.
00279              */
00280             void clear();
00281 
00282             /**
00283              * Return whether a spec structure is already installed.
00284              */
00285             bool already_installed(const DependencySpecTree::BasicNode &,
00286                     const std::tr1::shared_ptr<const DestinationsSet> & target_destinations) const;
00287 
00288             /**
00289              * Return whether a PackageID has been replaced.
00290              */
00291             bool replaced(const PackageID &) const;
00292 
00293             /**
00294              * Return whether a spec matches an item in the list.
00295              */
00296             bool match_on_list(const PackageDepSpec &) const;
00297 
00298             /**
00299              * Whether we have any errors.
00300              */
00301             bool has_errors() const;
00302 
00303             /**
00304              * Add a suggested package to the list.
00305              */
00306             void add_suggested_package(const std::tr1::shared_ptr<const PackageID> &,
00307                     const PackageDepSpec &, const std::tr1::shared_ptr<const DestinationsSet> & destinations);
00308     };
00309 
00310 #ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
00311     extern template class PrivateImplementationPattern<DepList>;
00312 #endif
00313 }
00314 
00315 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4