uninstall_list.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2006, 2007, 2008, 2009 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_UNUSED_LIST_HH
00021 #define PALUDIS_GUARD_PALUDIS_UNUSED_LIST_HH 1
00022 
00023 #include <paludis/util/instantiation_policy.hh>
00024 #include <paludis/util/private_implementation_pattern.hh>
00025 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
00026 #include <paludis/util/named_value.hh>
00027 #include <paludis/package_id-fwd.hh>
00028 #include <paludis/dep_tag-fwd.hh>
00029 
00030 /** \file
00031  * Declarations for UninstallList and related classes.
00032  *
00033  * \ingroup g_dep_list
00034  *
00035  * \section Examples
00036  *
00037  * - None at this time. Use UninstallTask if you need to uninstall things.
00038  */
00039 
00040 namespace paludis
00041 {
00042 #include <paludis/uninstall_list-se.hh>
00043 
00044     namespace n
00045     {
00046         struct kind;
00047         struct package_id;
00048         struct tags;
00049         struct with_dependencies_as_errors;
00050         struct with_dependencies_included;
00051         struct with_unused_dependencies;
00052     }
00053 
00054     /**
00055      * Parameters for an UninstallList.
00056      *
00057      * \see UninstallList
00058      * \ingroup g_dep_list
00059      * \nosubgrouping
00060      */
00061     struct UninstallListOptions
00062     {
00063         NamedValue<n::with_dependencies_as_errors, bool> with_dependencies_as_errors;
00064         NamedValue<n::with_dependencies_included, bool> with_dependencies_included;
00065         NamedValue<n::with_unused_dependencies, bool> with_unused_dependencies;
00066     };
00067 
00068     /**
00069      * An entry in an UninstallList.
00070      *
00071      * \see UninstallList
00072      * \ingroup g_dep_list
00073      * \nosubgrouping
00074      */
00075     struct UninstallListEntry
00076     {
00077         NamedValue<n::kind, UninstallListEntryKind> kind;
00078         NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
00079         NamedValue<n::tags, std::tr1::shared_ptr<Set<std::tr1::shared_ptr<DepTag> > > > tags;
00080     };
00081 
00082     class Environment;
00083 
00084     /**
00085      * Work out uninstall ordering for packages.
00086      *
00087      * \ingroup g_dep_list
00088      * \nosubgrouping
00089      */
00090     class PALUDIS_VISIBLE UninstallList :
00091         private PrivateImplementationPattern<UninstallList>,
00092         public InstantiationPolicy<UninstallList, instantiation_method::NonCopyableTag>
00093     {
00094         private:
00095             void add_package(const std::tr1::shared_ptr<const PackageID> &, const std::tr1::shared_ptr<DepTag> &,
00096                     const UninstallListEntryKind k);
00097             void real_add(const std::tr1::shared_ptr<const PackageID> &,
00098                     const std::tr1::shared_ptr<DepTag> &, const bool);
00099             void move_package_to_end(const std::tr1::shared_ptr<const PackageID> &);
00100             void add_unused_dependencies();
00101             void add_dependencies(const PackageID &, const bool);
00102 
00103             std::tr1::shared_ptr<const PackageIDSet> collect_depped_upon(
00104                     const std::tr1::shared_ptr<const PackageIDSet> targets) const;
00105 
00106             std::tr1::shared_ptr<const PackageIDSet> collect_all_installed() const;
00107 
00108             std::tr1::shared_ptr<const PackageIDSet> collect_world() const;
00109 
00110         public:
00111             ///\name Basic operations
00112             ///\{
00113 
00114             UninstallList(const Environment * const, const UninstallListOptions &);
00115             virtual ~UninstallList();
00116 
00117             ///\}
00118 
00119             /**
00120              * Our options.
00121              */
00122             UninstallListOptions & options;
00123 
00124             /**
00125              * Add a package, optionally with a reason.
00126              */
00127             void add(const std::tr1::shared_ptr<const PackageID> &,
00128                     const std::tr1::shared_ptr<DepTag> & = std::tr1::shared_ptr<DepTag>());
00129 
00130             /**
00131              * Add errors for any package on our uninstall list that is required by system.
00132              */
00133             void add_errors_for_system();
00134 
00135             /**
00136              * Add any unused packages that are dependencies of packages to uninstall.
00137              */
00138             void add_unused();
00139 
00140             /**
00141              * Whether we have any errors.
00142              */
00143             bool has_errors() const;
00144 
00145             ///\name Iterate over our items to remove
00146             ///\{
00147 
00148             struct UninstallListTag;
00149             typedef WrappedForwardIterator<UninstallListTag, const UninstallListEntry> ConstIterator;
00150             ConstIterator begin() const;
00151             ConstIterator end() const;
00152 
00153             ///\}
00154     };
00155 }
00156 
00157 #endif

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