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
15 #include "zypp/base/ReferenceCounted.h"
16 #include "zypp/base/PtrTypes.h"
18 #include "zypp/Capability.h"
19 #include "zypp/solver/detail/Resolver.h"
20 #include "zypp/solver/detail/ProblemSolutionPtr.h"
21 #include "zypp/solver/detail/ResolverProblemPtr.h"
22 #include "zypp/solver/detail/SolutionActionPtr.h"
24 /////////////////////////////////////////////////////////////////////////
26 { ///////////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////////
30 /////////////////////////////////////////////////////////////////////
32 { ///////////////////////////////////////////////////////////////////
35 * Abstract base class for one action of a problem solution.
37 class SolutionAction : public base::ReferenceCounted
41 virtual ~SolutionAction();
43 // ---------------------------------- I/O
45 static std::string toString (const SolutionAction & action);
46 static std::string toString (const SolutionActionList & actionlist);
47 static std::string toString (const CSolutionActionList & actionlist);
49 virtual std::ostream & dumpOn(std::ostream & str ) const = 0;
51 friend std::ostream& operator<<(std::ostream&, const SolutionAction & action);
53 virtual std::string asString (void) const = 0;
55 // ---------------------------------- methods
57 * Execute this action.
58 * Returns 'true' on success, 'false' on error.
60 virtual bool execute() = 0;
65 * A problem solution action that performs a transaction
66 * (installs, updates, removes, ...) one resolvable
67 * (package, patch, pattern, product).
69 class TransactionSolutionAction: public SolutionAction
75 // TO DO: use some already existing enum (?)
83 TransactionSolutionAction( ResItem_constPtr resolvable,
84 TransactionKind action )
85 : SolutionAction(), _resolvable( resolvable ), _action( action ) {}
87 // ---------------------------------- I/O
89 static std::string toString (const TransactionSolutionAction & action);
91 virtual std::ostream & dumpOn(std::ostream & str ) const;
93 friend std::ostream& operator<<(std::ostream&, const TransactionSolutionAction & action);
95 std::string asString (void) const;
97 // ---------------------------------- accessors
98 ResItem_constPtr resolvable() const { return _resolvable; }
99 TransactionKind action() const { return _action; }
101 // ---------------------------------- methods
102 virtual bool execute();
107 ResItem_constPtr _resolvable;
108 TransactionKind _action;
113 * A problem solution action that injects an artificial "provides" to
114 * the pool to satisfy open requirements.
116 * This is typically used by "ignore" (user override) solutions.
118 class InjectSolutionAction: public SolutionAction
122 InjectSolutionAction( const Capability & provides )
123 : SolutionAction(), _capability( provides ) {}
125 // ---------------------------------- I/O
127 static std::string toString (const InjectSolutionAction & action);
129 virtual std::ostream & dumpOn(std::ostream & str ) const;
131 friend std::ostream& operator<<(std::ostream&, const InjectSolutionAction & action);
133 std::string asString (void) const;
135 // ---------------------------------- accessors
136 const Capability & capability() const { return _capability; };
138 // ---------------------------------- methods
139 virtual bool execute();
143 const Capability & _capability;
147 ///////////////////////////////////////////////////////////////////
148 };// namespace detail
149 /////////////////////////////////////////////////////////////////////
150 /////////////////////////////////////////////////////////////////////
151 };// namespace solver
152 ///////////////////////////////////////////////////////////////////////
153 ///////////////////////////////////////////////////////////////////////
155 /////////////////////////////////////////////////////////////////////////
157 #endif // ZYPP_SOLVER_DETAIL_SOLUTIONACTION_H