libzypp  17.31.31
SolutionAction.h
Go to the documentation of this file.
1 /*
2  *
3  * Easy-to use interface to the ZYPP dependency resolver
4  *
5  * Author: Stefan Hundhammer <sh@suse.de>
6  *
7  **/
8 
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!
13 #else
14 
15 #include <list>
16 #include <string>
17 
18 #include <zypp/base/ReferenceCounted.h>
19 #include <zypp/base/PtrTypes.h>
20 
21 #include <zypp/PoolItem.h>
22 
24 namespace zypp
25 {
26  namespace solver
28  {
29  namespace detail
31  {
32 
33  class Resolver;
34 
36 
37  DEFINE_PTR_TYPE(SolutionAction);
38  typedef std::list<SolutionAction_Ptr> SolutionActionList;
39 
43  class SolutionAction : public base::ReferenceCounted
44  {
45  protected:
46  typedef Resolver ResolverInternal;
47  SolutionAction ();
48  public:
49  virtual ~SolutionAction();
50 
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);
56 
57  // ---------------------------------- methods
62  virtual bool execute (ResolverInternal & resolver) const = 0;
63 
64  public:
66  virtual bool skipsPatchesOnly() const;
67  };
68 
69 
75  typedef enum
76  {
77  KEEP,
78  INSTALL,
79  REMOVE,
80  UNLOCK,
81  LOCK,
82  REMOVE_EXTRA_REQUIRE,
83  REMOVE_EXTRA_CONFLICT,
84  ADD_SOLVE_QUEUE_ITEM,
85  REMOVE_SOLVE_QUEUE_ITEM,
86  } TransactionKind;
87 
88 
89  class TransactionSolutionAction: public SolutionAction
90  {
91  public:
92  TransactionSolutionAction( PoolItem item,
93  TransactionKind action )
94  : SolutionAction(),
95  _item( item ), _action( action ) {}
96 
97  TransactionSolutionAction( Capability capability,
98  TransactionKind action )
99  : SolutionAction(),
100  _capability( capability ), _action( action ) {}
101 
102 
103  TransactionSolutionAction( SolverQueueItem_Ptr item,
104  TransactionKind action )
105  : SolutionAction(),
106  _solverQueueItem( item ), _action( action ) {}
107 
108  TransactionSolutionAction( TransactionKind action )
109  : SolutionAction(),
110  _item(), _action( action ) {}
111 
112  // ---------------------------------- I/O
113  virtual std::ostream & dumpOn( std::ostream & str ) const;
114  friend std::ostream& operator<<(std::ostream& str, const TransactionSolutionAction & action)
115  { return action.dumpOn (str); }
116 
117  // ---------------------------------- accessors
118 
119  const PoolItem item() const { return _item; }
120  const Capability capability() const { return _capability; }
121  TransactionKind action() const { return _action; }
122 
123  // ---------------------------------- methods
124  virtual bool execute(ResolverInternal & resolver) const;
125 
126  public:
128  bool skipsPatchesOnly() const override;
129 
130  protected:
131 
132  PoolItem _item;
133  Capability _capability;
134  SolverQueueItem_Ptr _solverQueueItem;
135 
136  const TransactionKind _action;
137  };
138 
139 
144  typedef enum
145  {
146  WEAK
147  } InjectSolutionKind;
148 
149 
157  class InjectSolutionAction: public SolutionAction
158  {
159  public:
160 
161  InjectSolutionAction( PoolItem item,
162  const InjectSolutionKind & kind)
163  : SolutionAction(),
164  _item( item ),
165  _kind( kind ) {}
166 
167  // ---------------------------------- I/O
168  virtual std::ostream & dumpOn( std::ostream & str ) const;
169  friend std::ostream& operator<<(std::ostream& str, const InjectSolutionAction & action)
170  { return action.dumpOn (str); }
171 
172  // ---------------------------------- accessors
173  const PoolItem item() const { return _item; }
174 
175  // ---------------------------------- methods
176  virtual bool execute(ResolverInternal & resolver) const;
177 
178  protected:
179  PoolItem _item;
180  const InjectSolutionKind _kind;
181  };
182 
183 
185  };// namespace detail
188  };// namespace solver
191 };// namespace zypp
193 #endif // ZYPP_USE_RESOLVER_INTERNALS
194 #endif // ZYPP_SOLVER_DETAIL_SOLUTIONACTION_H
195 
String related utilities and Regular expression matching.
DEFINE_PTR_TYPE(HelixResolvable)
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:580
Resolver ResolverInternal
Preferred name in API.
Definition: Types.h:38
std::ostream & operator<<(std::ostream &os, const SolutionActionList &actionlist)
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
std::list< SolutionAction_Ptr > SolutionActionList
Definition: Types.h:48