libzypp 17.31.6
Transaction.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
11#ifndef ZYPP_SAT_TRANSACTION_H
12#define ZYPP_SAT_TRANSACTION_H
13
14#include <iosfwd>
15
16#include <zypp/base/PtrTypes.h>
17#include <zypp/base/Flags.h>
18#include <zypp/base/Iterator.h>
19#include <zypp-core/base/DefaultIntegral>
20
22#include <zypp/sat/Solvable.h>
23#include <zypp/sat/Queue.h>
24
25#include <zypp/PoolItem.h>
26
28namespace zypp
29{
31 namespace sat
32 {
33
34 namespace detail
35 {
37 class Transaction_iterator;
39 class Transaction_const_iterator;
40 }
41
51 class Transaction : public SolvIterMixin<Transaction, detail::Transaction_const_iterator>
52 {
53 friend std::ostream & operator<<( std::ostream & str, const Transaction & obj );
54 friend std::ostream & dumpOn( std::ostream & str, const Transaction & obj );
55 friend bool operator==( const Transaction & lhs, const Transaction & rhs );
56
57 public:
59 class Step;
60
63 {
68 };
69
72 {
73 STEP_TODO = (1 << 0),
74 STEP_DONE = (1 << 1),
75 STEP_ERROR = (1 << 2),
76 };
77
79
80 public:
81 struct LoadFromPoolType {};
83
84 public:
87
90
93
94 public:
96 bool valid() const;
97
99 explicit operator bool() const
100 { return valid(); }
101
107 bool order();
108
110 bool empty() const;
111
113 size_t size() const;
114
117
119 const_iterator begin() const;
121 iterator begin();
122
124 const_iterator end() const;
126 iterator end();
127
129 const_iterator find( const sat::Solvable & solv_r ) const;
130 iterator find( const sat::Solvable & solv_r );
132 const_iterator find( const ResObject::constPtr & resolvable_r ) const;
133 iterator find( const ResObject::constPtr & resolvable_r );
135 const_iterator find( const PoolItem & pi_r ) const;
136 iterator find( const PoolItem & pi_r );
137
138 public:
153 struct FilterAction;
154 typedef filter_iterator<FilterAction,const_iterator> action_iterator;
155
157 bool actionEmpty( StepStages filter_r = StepStages() ) const;
158
160 size_t actionSize( StepStages filter_r = StepStages() ) const;
161
163 action_iterator actionBegin( StepStages filter_r = StepStages() ) const;
164
167
169 Iterable<action_iterator> action( StepStages filter_r = StepStages() ) const;
171
172 public:
176 int installedResult( Queue & result_r ) const;
177
180
182 void autoInstalled( const StringQueue & queue_r );
183
184 public:
186 struct Impl;
187 private:
190 };
191
192 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Transaction::StepStages);
193
195 std::ostream & operator<<( std::ostream & str, const Transaction & obj );
196
198 std::ostream & dumpOn( std::ostream & str, const Transaction & obj );
199
201 bool operator==( const Transaction & lhs, const Transaction & rhs );
202
204 inline bool operator!=( const Transaction & lhs, const Transaction & rhs )
205 { return !( lhs == rhs ); }
206
207
219 {
220 friend std::ostream & operator<<( std::ostream & str, const Step & obj );
221
222 public:
223 Step();
224 Step( const RW_pointer<Impl> & pimpl_r, detail::IdType id_r )
225 : _solv( id_r )
226 , _pimpl( pimpl_r )
227 {}
228
229 public:
231 StepType stepType() const;
232
234 StepStage stepStage() const;
235
237 void stepStage( StepStage val_r );
238
244 { return _solv; }
245
257 IdString ident() const;
258
260 Edition edition() const;
261
263 Arch arch() const;
265
267 operator const Solvable &() const { return _solv; }
269 operator Solvable &() { return _solv; }
270
271 private:
275 };
276
278 std::ostream & operator<<( std::ostream & str, const Transaction::Step & obj );
279
281 std::ostream & operator<<( std::ostream & str, Transaction::StepType obj );
282
284 std::ostream & operator<<( std::ostream & str, Transaction::StepStage obj );
285
287 namespace detail
288 {
289
292 class Transaction_iterator : public boost::iterator_adaptor<
293 Transaction_iterator // Derived
294 , const detail::IdType * // Base
295 , Transaction::Step // Value
296 , boost::forward_traversal_tag // CategoryOrTraversal
297 , Transaction::Step // Reference
298 >
299 {
300 public:
302 Transaction_iterator( const RW_pointer<Transaction::Impl> & pimpl_r, base_type id_r )
303 : Transaction_iterator::iterator_adaptor_( id_r )
304 , _pimpl( pimpl_r )
305 {}
306
307 private:
309
310 reference dereference() const
311 { return Transaction::Step( _pimpl, *base() ); }
312
313 private:
317 };
318
321 class Transaction_const_iterator : public boost::iterator_adaptor<
322 Transaction_const_iterator // Derived
323 , const detail::IdType * // Base
324 , const Transaction::Step // Value
325 , boost::forward_traversal_tag // CategoryOrTraversal
326 , const Transaction::Step // Reference
327 >
328 {
329 public:
333 : Transaction_const_iterator::iterator_adaptor_( id_r )
334 , _pimpl( pimpl_r )
335 {}
336
337 private:
339
340 reference dereference() const
341 { return Transaction::Step( _pimpl, *base() ); }
342
343 private:
346 };
347
349 } // namespace detail
351
353 { return( resolvable_r ? find( resolvable_r->satSolvable() ) : end() ); }
354
356 { return( resolvable_r ? find( resolvable_r->satSolvable() ) : end() ); }
357
359 { return find( pi_r.satSolvable() ); }
360
362 { return find( pi_r.satSolvable() ); }
363
364
366 {
368 FilterAction( StepStages filter_r ) : _filter( filter_r ) {}
369
370 bool operator()( const Transaction::Step & step_r ) const
371 {
373 return false; // no action
374 return !_filter || _filter.testFlag( step_r.stepStage() );
375 }
376
377 StepStages _filter;
378 };
379
380 inline Transaction::action_iterator Transaction::actionBegin( StepStages filter_r ) const
381 { return make_filter_begin( FilterAction( filter_r ), *this ); }
382
384 { return make_filter_end( FilterAction(), *this ); }
385
386 inline bool Transaction::actionEmpty( StepStages filter_r ) const
387 { return( actionBegin( filter_r ) == actionEnd() ); }
388
389 inline size_t Transaction::actionSize( StepStages filter_r ) const
390 {
391 size_t cnt = 0;
392 for_( it, actionBegin( filter_r ), actionEnd() )
393 ++cnt;
394 return cnt;
395 }
396
398 { return makeIterable( actionBegin( filter_r ), actionEnd() ); }
399
401 } // namespace sat
404} // namespace zypp
406#endif // ZYPP_SAT_TRANSACTION_H
Architecture.
Definition: Arch.h:37
Edition represents [epoch:]version[-release]
Definition: Edition.h:61
Access to the sat-pools string space.
Definition: IdString.h:43
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:51
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
Libsolv Id queue wrapper.
Definition: Queue.h:35
Base class providing common iterator types based on a Solvable iterator.
A Solvable object within the sat Pool.
Definition: Solvable.h:54
A single step within a Transaction.
Definition: Transaction.h:219
Step(const RW_pointer< Impl > &pimpl_r, detail::IdType id_r)
Definition: Transaction.h:224
StepType stepType() const
Type of action to perform in this step.
Definition: Transaction.cc:388
StepStage stepStage() const
Step action result.
Definition: Transaction.cc:391
friend std::ostream & operator<<(std::ostream &str, const Step &obj)
Definition: Transaction.cc:406
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: Transaction.h:274
Solvable satSolvable() const
Return the corresponding Solvable.
Definition: Transaction.h:243
Libsolv transaction wrapper.
Definition: Transaction.h:52
ZYPP_DECLARE_FLAGS(StepStages, StepStage)
size_t actionSize(StepStages filter_r=StepStages()) const
Number of steps in [filtered] transaction steps.
Definition: Transaction.h:389
const_iterator end() const
Iterator behind the last TransactionStep.
Definition: Transaction.cc:343
bool actionEmpty(StepStages filter_r=StepStages()) const
Whether the [filtered] transaction contains any steps .
Definition: Transaction.h:386
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: Transaction.h:186
bool operator!=(const Transaction &lhs, const Transaction &rhs)
Definition: Transaction.h:204
int installedResult(Queue &result_r) const
Return all packages that would be installed after the transaction is run.
Definition: Transaction.cc:355
StringQueue autoInstalled() const
Return the ident strings of all packages that would be auto-installed after the transaction is run.
Definition: Transaction.cc:358
friend std::ostream & dumpOn(std::ostream &str, const Transaction &obj)
Definition: Transaction.cc:367
const_iterator begin() const
Iterator to the first TransactionStep.
Definition: Transaction.cc:337
bool valid() const
Whether transaction actually contains data and also fits the current pools content.
Definition: Transaction.cc:325
Transaction()
Default ctor: empty transaction.
Definition: Transaction.cc:314
Iterable< action_iterator > action(StepStages filter_r=StepStages()) const
Iterate the [filtered] transaction steps.
Definition: Transaction.h:397
friend bool operator==(const Transaction &lhs, const Transaction &rhs)
Definition: Transaction.cc:376
filter_iterator< FilterAction, const_iterator > action_iterator
Definition: Transaction.h:153
bool order()
Order transaction steps for commit.
Definition: Transaction.cc:328
friend std::ostream & operator<<(std::ostream &str, const Transaction &obj)
Definition: Transaction.cc:364
static constexpr LoadFromPoolType loadFromPool
Definition: Transaction.h:82
detail::Transaction_const_iterator const_iterator
Definition: Transaction.h:116
const_iterator find(const sat::Solvable &solv_r) const
Return iterator pointing to solv_r or end.
Definition: Transaction.cc:349
StepType
Type of (rpm) action to perform in a Step.
Definition: Transaction.h:63
@ TRANSACTION_MULTIINSTALL
[M] Install(multiversion) item (
Definition: Transaction.h:67
@ TRANSACTION_INSTALL
[+] Install(update) item
Definition: Transaction.h:66
@ TRANSACTION_IGNORE
[ ] Nothing (includes implicit deletes due to obsoletes and non-package actions)
Definition: Transaction.h:64
@ TRANSACTION_ERASE
[-] Delete item
Definition: Transaction.h:65
action_iterator actionBegin(StepStages filter_r=StepStages()) const
Pointer to the 1st action step in [filtered] transaction.
Definition: Transaction.h:380
action_iterator actionEnd() const
Pointer behind the last action step in transaction.
Definition: Transaction.h:383
detail::Transaction_iterator iterator
Definition: Transaction.h:115
size_t size() const
Number of steps in transaction steps.
Definition: Transaction.cc:334
StepStage
Step action result.
Definition: Transaction.h:72
@ STEP_DONE
[OK] success
Definition: Transaction.h:74
@ STEP_TODO
[__] unprocessed
Definition: Transaction.h:73
@ STEP_ERROR
[**] error
Definition: Transaction.h:75
bool empty() const
Whether the transaction contains any steps.
Definition: Transaction.cc:331
Transaction_const_iterator(const RW_pointer< Transaction::Impl > &pimpl_r, base_type id_r)
Definition: Transaction.h:332
RW_pointer< Transaction::Impl > _pimpl
Pointer to implementation.
Definition: Transaction.h:345
RW_pointer< Transaction::Impl > _pimpl
Pointer to implementation.
Definition: Transaction.h:316
Transaction_iterator(const RW_pointer< Transaction::Impl > &pimpl_r, base_type id_r)
Definition: Transaction.h:302
friend class boost::iterator_core_access
Definition: Transaction.h:308
String related utilities and Regular expression matching.
int IdType
Generic Id type.
Definition: PoolMember.h:104
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Transaction::StepStages)
bool operator==(const Map &lhs, const Map &rhs)
Definition: Map.cc:125
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
filter_iterator< TFilter, typename TContainer::const_iterator > make_filter_begin(TFilter f, const TContainer &c)
Convenience to create filter_iterator from container::begin().
Definition: Iterator.h:101
filter_iterator< TFilter, typename TContainer::const_iterator > make_filter_end(TFilter f, const TContainer &c)
Convenience to create filter_iterator from container::end().
Definition: Iterator.h:117
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:286
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
bool operator()(const Transaction::Step &step_r) const
Definition: Transaction.h:370
FilterAction(StepStages filter_r)
Definition: Transaction.h:368
Transaction implementation.
Definition: Transaction.cc:51
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28