3 * Easy-to use interface to the ZYPP dependency resolver
5 * Author: Stefan Hundhammer <sh@suse.de>
9 #ifndef ZYPP_SOLVER_DETAIL_SOLUTIONACTION_H
10 #define ZYPP_SOLVER_DETAIL_SOLUTIONACTION_H
11 #ifndef ZYPP_USE_RESOLVER_INTERNALS
12 #error Do not directly include this file!
18 #include "zypp/base/ReferenceCounted.h"
19 #include "zypp/base/PtrTypes.h"
21 #include "zypp/PoolItem.h"
23 /////////////////////////////////////////////////////////////////////////
25 { ///////////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////////
29 /////////////////////////////////////////////////////////////////////
31 { ///////////////////////////////////////////////////////////////////
35 DEFINE_PTR_TYPE(SolverQueueItem);
37 DEFINE_PTR_TYPE(SolutionAction);
38 typedef std::list<SolutionAction_Ptr> SolutionActionList;
41 * Abstract base class for one action of a problem solution.
43 class SolutionAction : public base::ReferenceCounted
46 typedef Resolver ResolverInternal;
49 virtual ~SolutionAction();
51 // ---------------------------------- I/O
52 virtual std::ostream & dumpOn( std::ostream & str ) const;
53 friend std::ostream& operator<<(std::ostream & str, const SolutionAction & action)
54 { return action.dumpOn (str); }
55 friend std::ostream& operator<<(std::ostream & str, const SolutionActionList & actionlist);
57 // ---------------------------------- methods
59 * Execute this action.
60 * Returns 'true' on success, 'false' on error.
62 virtual bool execute (ResolverInternal & resolver) const = 0;
67 * A problem solution action that performs a transaction
68 * (installs, removes, keep ...) one resolvable
69 * (package, patch, pattern, product).
79 REMOVE_EXTRA_CONFLICT,
81 REMOVE_SOLVE_QUEUE_ITEM,
85 class TransactionSolutionAction: public SolutionAction
88 TransactionSolutionAction( PoolItem item,
89 TransactionKind action )
91 _item( item ), _action( action ) {}
93 TransactionSolutionAction( Capability capability,
94 TransactionKind action )
96 _capability( capability ), _action( action ) {}
99 TransactionSolutionAction( SolverQueueItem_Ptr item,
100 TransactionKind action )
102 _solverQueueItem( item ), _action( action ) {}
104 TransactionSolutionAction( TransactionKind action )
106 _item(), _action( action ) {}
108 // ---------------------------------- I/O
109 virtual std::ostream & dumpOn( std::ostream & str ) const;
110 friend std::ostream& operator<<(std::ostream& str, const TransactionSolutionAction & action)
111 { return action.dumpOn (str); }
113 // ---------------------------------- accessors
115 const PoolItem item() const { return _item; }
116 const Capability capability() const { return _capability; }
117 TransactionKind action() const { return _action; }
119 // ---------------------------------- methods
120 virtual bool execute(ResolverInternal & resolver) const;
125 Capability _capability;
126 SolverQueueItem_Ptr _solverQueueItem;
128 const TransactionKind _action;
133 * Type of ignoring; currently only WEAK
139 } InjectSolutionKind;
143 * A problem solution action that injects an artificial "provides" to
144 * the pool to satisfy open requirements or remove the conflict of
145 * concerning resolvable
147 * This is typically used by "ignore" (user override) solutions.
149 class InjectSolutionAction: public SolutionAction
153 InjectSolutionAction( PoolItem item,
154 const InjectSolutionKind & kind)
159 // ---------------------------------- I/O
160 virtual std::ostream & dumpOn( std::ostream & str ) const;
161 friend std::ostream& operator<<(std::ostream& str, const InjectSolutionAction & action)
162 { return action.dumpOn (str); }
164 // ---------------------------------- accessors
165 const PoolItem item() const { return _item; }
167 // ---------------------------------- methods
168 virtual bool execute(ResolverInternal & resolver) const;
172 const InjectSolutionKind _kind;
176 ///////////////////////////////////////////////////////////////////
177 };// namespace detail
178 /////////////////////////////////////////////////////////////////////
179 /////////////////////////////////////////////////////////////////////
180 };// namespace solver
181 ///////////////////////////////////////////////////////////////////////
182 ///////////////////////////////////////////////////////////////////////
184 /////////////////////////////////////////////////////////////////////////
185 #endif // ZYPP_USE_RESOLVER_INTERNALS
186 #endif // ZYPP_SOLVER_DETAIL_SOLUTIONACTION_H