Resolver.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* Resolver.h
00003  *
00004  * Copyright (C) 2000-2002 Ximian, Inc.
00005  * Copyright (C) 2005 SUSE Linux Products GmbH
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License,
00009  * version 2, as published by the Free Software Foundation.
00010  *
00011  * This program is distributed in the hope that it will be useful, but
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019  * 02111-1307, USA.
00020  */
00021 
00022 #ifndef ZYPP_SOLVER_DETAIL_RESOLVER_H
00023 #define ZYPP_SOLVER_DETAIL_RESOLVER_H
00024 
00025 #include <iosfwd>
00026 #include <list>
00027 #include <map>
00028 #include <string>
00029 
00030 #include "zypp/base/ReferenceCounted.h"
00031 #include "zypp/base/PtrTypes.h"
00032 
00033 #include "zypp/ResPool.h"
00034 
00035 #include "zypp/solver/detail/Types.h"
00036 #include "zypp/solver/detail/ResolverQueue.h"
00037 #include "zypp/solver/detail/ResolverContext.h"
00038 
00039 #include "zypp/ProblemTypes.h"
00040 #include "zypp/ResolverProblem.h"
00041 #include "zypp/ProblemSolution.h"
00042 #include "zypp/UpgradeStatistics.h"
00043 
00044 #include "zypp/CapSet.h"
00045 
00046 
00048 namespace zypp
00049 { 
00050 
00051   namespace solver
00052   { 
00053 
00054     namespace detail
00055     { 
00056 
00058 //
00059 //      CLASS NAME : Resolver
00060 
00061 class Resolver : public base::ReferenceCounted, private base::NonCopyable {
00062 
00063   private:
00064     ResPool _pool;
00065 
00066     int _timeout_seconds;
00067     bool _verifying;
00068     bool _testing;
00069 
00070     // list populated by calls to addPoolItemTo*()
00071     QueueItemList _initial_items;
00072     PoolItemList _items_to_install;
00073     PoolItemList _items_to_establish;
00074     PoolItemList _items_to_remove;
00075     PoolItemList _items_to_verify;
00076 
00077     // list of problematic items after doUpgrade()
00078     PoolItemList _update_items;
00079 
00080 
00081     CapSet _extra_caps;
00082     CapSet _extra_conflicts;
00083 
00084     //typedef std::multimap<PoolItem_Ref,Capability> IgnoreMap;
00085 
00086     // These conflict should be ignored of the concering item
00087     IgnoreMap _ignoreConflicts;
00088     // These requires should be ignored of the concering item    
00089     IgnoreMap _ignoreRequires;
00090     // These obsoletes should be ignored of the concering item    
00091     IgnoreMap _ignoreObsoletes;    
00092     // Ignore architecture of the item
00093     PoolItemList _ignoreArchitecture;
00094     // Ignore the status "installed" of the item
00095     PoolItemList _ignoreInstalledItem;
00096     // Ignore the architecture of the item
00097     PoolItemList _ignoreArchitectureItem;    
00098     
00099 
00100     ResolverQueueList _pending_queues;
00101     ResolverQueueList _pruned_queues;
00102     ResolverQueueList _complete_queues;
00103     ResolverQueueList _deferred_queues;
00104     ResolverQueueList _invalid_queues;
00105 
00106     int _valid_solution_count;
00107 
00108     ResolverContext_Ptr _best_context;
00109     bool _timed_out;
00110 
00111     std::set<Source_Ref> _subscribed;
00112 
00113     Arch _architecture;
00114 
00115     bool _forceResolve; // remove items which are conflicts with others or
00116                         // have unfulfilled requirements.
00117                         // This behaviour is favourited by ZMD
00118     bool _upgradeMode;  // Resolver has been called with doUpgrade    
00119 
00120     // helpers
00121     bool doesObsoleteCapability (PoolItem_Ref candidate, const Capability & cap);
00122     bool doesObsoleteItem (PoolItem_Ref candidate, PoolItem_Ref installed);
00123 
00124   public:
00125 
00126     Resolver (const ResPool & pool);
00127     virtual ~Resolver();
00128 
00129     // ---------------------------------- I/O
00130 
00131     virtual std::ostream & dumpOn( std::ostream & str ) const;
00132     friend std::ostream& operator<<(std::ostream& str, const Resolver & obj)
00133     { return obj.dumpOn (str); }
00134 
00135     // ---------------------------------- accessors
00136 
00137     QueueItemList initialItems () const { return _initial_items; }
00138 
00139     ResolverQueueList pendingQueues () const { return _pending_queues; }
00140     ResolverQueueList prunedQueues () const { return _pruned_queues; }
00141     ResolverQueueList completeQueues () const { return _complete_queues; }
00142     ResolverQueueList deferredQueues () const { return _deferred_queues; }
00143     ResolverQueueList invalidQueues () const { return _invalid_queues; }
00144 
00145     ResolverContext_Ptr bestContext (void) const { return _best_context; }
00146 
00149     ResolverContext_Ptr context (void) const;
00150 
00151     // ---------------------------------- methods
00152 
00153     void setTimeout (int seconds) { _timeout_seconds = seconds; }
00154 
00155     ResPool pool (void) const;
00156     void setPool (const ResPool & pool) { _pool = pool; }
00157 
00158     void addSubscribedSource (Source_Ref source);
00159 
00160     void addPoolItemToInstall (PoolItem_Ref item);
00161     void addPoolItemsToInstallFromList (PoolItemList & rl);
00162 
00163     void addPoolItemToRemove (PoolItem_Ref item);
00164     void addPoolItemsToRemoveFromList (PoolItemList & rl);
00165 
00166     void addPoolItemToEstablish (PoolItem_Ref item);
00167     void addPoolItemsToEstablishFromList (PoolItemList & rl);
00168 
00169     void addPoolItemToVerify (PoolItem_Ref item);
00170 
00171     void addExtraCapability (const Capability & capability);
00172     void addExtraConflict (const Capability & capability);
00173 
00174     void addIgnoreConflict (const PoolItem_Ref item,
00175                             const Capability & capability);
00176     void addIgnoreRequires (const PoolItem_Ref item,
00177                             const Capability & capability);
00178     void addIgnoreObsoletes (const PoolItem_Ref item,
00179                              const Capability & capability);
00180     void addIgnoreInstalledItem (const PoolItem_Ref item);
00181     void addIgnoreArchitectureItem (const PoolItem_Ref item);    
00182 
00183     void setForceResolve (const bool force) { _forceResolve = force; }
00184     const bool forceResolve() { return _forceResolve; }
00185 
00186     bool verifySystem (void);
00187     void establishState (ResolverContext_Ptr context = NULL);
00188     bool establishPool (void);
00189     void freshenState( ResolverContext_Ptr context = NULL );
00190     bool freshenPool( void );
00191     bool resolveDependencies (const ResolverContext_Ptr context = NULL);
00192     bool resolvePool (void);
00193 
00194     bool transactResObject( ResObject::constPtr robj, bool install = true);
00195     bool transactResKind( Resolvable::Kind kind );
00196     void transactReset( ResStatus::TransactByValue causer );
00197 
00198     void doUpgrade( zypp::UpgradeStatistics & opt_stats_r );
00199     PoolItemList problematicUpdateItems( void ) const { return _update_items; }
00200 
00201 
00202     ResolverProblemList problems (void) const;
00203     void applySolutions (const ProblemSolutionList &solutions);
00204 
00205     // reset all SOLVER transaction in pool
00206     void undo(void);
00207 
00208     // only for testsuite
00209     void reset (void);
00210 
00211     Arch architecture() const { return _architecture; }
00212     void setArchitecture( const Arch & arch) { _architecture = arch; }
00213 
00214     bool testing(void) const { return _testing; }
00215     void setTesting( bool testing ) { _testing = testing; }
00216 };
00217 
00219     };// namespace detail
00222   };// namespace solver
00225 };// namespace zypp
00227 
00228 #endif // ZYPP_SOLVER_DETAIL_RESOLVER_H

Generated on Thu Jul 6 00:07:22 2006 for zypp by  doxygen 1.4.6