libzypp: zypp/sat/Transaction.h Source File

libzypp 17.36.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
21#include <zypp/sat/SolvIterMixin.h>
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 ZYPP_API 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
62 enum StepType
63 {
64 TRANSACTION_IGNORE = 0x00,
65 TRANSACTION_ERASE = 0x10,
66 TRANSACTION_INSTALL = 0x20,
67 TRANSACTION_MULTIINSTALL = 0x30
68 };
69
71 enum StepStage
72 {
73 STEP_TODO = (1 << 0),
74 STEP_DONE = (1 << 1),
75 STEP_ERROR = (1 << 2),
76 };
77
78 ZYPP_DECLARE_FLAGS(StepStages,StepStage);
79
80 public:
81 struct LoadFromPoolType {};
82 static constexpr LoadFromPoolType loadFromPool = LoadFromPoolType();
83
84 public:
86 Transaction();
87
89 Transaction( LoadFromPoolType );
90
92 ~Transaction();
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
115 using iterator = detail::Transaction_iterator;
116 using const_iterator = detail::Transaction_const_iterator;
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 using action_iterator = filter_iterator<FilterAction, const_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
166 action_iterator actionEnd() const;
167
169 Iterable<action_iterator> action( StepStages filter_r = StepStages() ) const;
171
172 public:
176 int installedResult( Queue & result_r ) const;
177
179 StringQueue autoInstalled() const;
180
182 void autoInstalled( const StringQueue & queue_r );
183
184 public:
186 struct Impl;
187 private:
189 RW_pointer<Impl> _pimpl;
190 };
191
192 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Transaction::StepStages);
193
195 std::ostream & operator<<( std::ostream & str, const Transaction & obj ) ZYPP_API;
196
198 std::ostream & dumpOn( std::ostream & str, const Transaction & obj ) ZYPP_API;
199
201 bool operator==( const Transaction & lhs, const Transaction & rhs ) ZYPP_API;
202
204 inline bool operator!=( const Transaction & lhs, const Transaction & rhs )
205 { return !( lhs == rhs ); }
206
207
218 class Transaction::Step
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
243 Solvable satSolvable() const
244 { return _solv; }
245
256
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:
272 Solvable _solv;
274 RW_pointer<Impl> _pimpl;
275 };
276
278 std::ostream & operator<<( std::ostream & str, const Transaction::Step & obj ) ZYPP_API;
279
281 std::ostream & operator<<( std::ostream & str, Transaction::StepType obj ) ZYPP_API;
282
284 std::ostream & operator<<( std::ostream & str, Transaction::StepStage obj ) ZYPP_API;
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:
301 Transaction_iterator();
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:
308 friend class boost::iterator_core_access;
309
310 reference dereference() const
311 { return Transaction::Step( _pimpl, *base() ); }
312
313 private:
314 friend class Transaction_const_iterator;
316 RW_pointer<Transaction::Impl> _pimpl;
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:
330 Transaction_const_iterator();
331 Transaction_const_iterator( const Transaction_iterator & iter_r );
332 Transaction_const_iterator( const RW_pointer<Transaction::Impl> & pimpl_r, base_type id_r )
333 : Transaction_const_iterator::iterator_adaptor_( id_r )
334 , _pimpl( pimpl_r )
335 {}
336
337 private:
338 friend class boost::iterator_core_access;
339
340 reference dereference() const
341 { return Transaction::Step( _pimpl, *base() ); }
342
343 private:
345 RW_pointer<Transaction::Impl> _pimpl;
346 };
347
349 } // namespace detail
351
352 inline Transaction::const_iterator Transaction::find( const ResObject::constPtr & resolvable_r ) const
353 { return( resolvable_r ? find( resolvable_r->satSolvable() ) : end() ); }
354
355 inline Transaction::iterator Transaction::find( const ResObject::constPtr & resolvable_r )
356 { return( resolvable_r ? find( resolvable_r->satSolvable() ) : end() ); }
357
358 inline Transaction::const_iterator Transaction::find( const PoolItem & pi_r ) const
359 { return find( pi_r.satSolvable() ); }
360
361 inline Transaction::iterator Transaction::find( const PoolItem & pi_r )
362 { return find( pi_r.satSolvable() ); }
363
364
365 struct Transaction::FilterAction
366 {
367 FilterAction() {}
368 FilterAction( StepStages filter_r ) : _filter( filter_r ) {}
369
370 bool operator()( const Transaction::Step & step_r ) const
371 {
372 if ( step_r.stepType() == Transaction::TRANSACTION_IGNORE )
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
383 inline Transaction::action_iterator Transaction::actionEnd() const
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
397 inline Iterable<Transaction::action_iterator> Transaction::action( StepStages filter_r ) const
398 { return makeIterable( actionBegin( filter_r ), actionEnd() ); }
399
401 } // namespace sat
404} // namespace zypp
406#endif // ZYPP_SAT_TRANSACTION_H
operator<<
std::ostream & operator<<(std::ostream &str, const zypp::sat::detail::CDataiterator *obj)
Definition LookupAttr.cc:808
PoolItem.h
Queue.h
SolvIterMixin.h
Solvable.h
bool
filter_iterator
An iterator over the subset of elements of some sequence which satisfy a given predicate.
zypp::Arch
Architecture.
Definition Arch.h:37
zypp::Edition
Edition represents [epoch:]version[-release]
Definition Edition.h:61
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:44
zypp::Iterable
Definition Iterable.h:37
zypp::Iterable::makeIterable
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
convenient construction.
Definition Iterable.h:88
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
zypp::ResObject::constPtr
TraitsType::constPtrType constPtr
Definition ResObject.h:43
zypp::sat::Queue
Libsolv Id queue wrapper.
Definition Queue.h:36
zypp::sat::SolvIterMixin< Transaction, detail::Transaction_const_iterator >::SolvIterMixin
SolvIterMixin()
Definition SolvIterMixin.h:198
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
zypp::sat::Transaction::Step
A single step within a Transaction.
Definition Transaction.h:219
zypp::sat::Transaction::Step::arch
Arch arch() const
Definition Transaction.cc:405
zypp::sat::Transaction::Step::Step
Step(const RW_pointer< Impl > &pimpl_r, detail::IdType id_r)
Definition Transaction.h:224
zypp::sat::Transaction::Step::ident
IdString ident() const
Definition Transaction.cc:399
zypp::sat::Transaction::Step::stepType
StepType stepType() const
Type of action to perform in this step.
Definition Transaction.cc:390
zypp::sat::Transaction::Step::stepStage
StepStage stepStage() const
Step action result.
Definition Transaction.cc:393
zypp::sat::Transaction::Step::operator<<
friend std::ostream & operator<<(std::ostream &str, const Step &obj)
Definition Transaction.cc:408
zypp::sat::Transaction::Step::Step
Step()
Definition Transaction.cc:387
zypp::sat::Transaction::Step::_pimpl
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition Transaction.h:274
zypp::sat::Transaction::Step::_solv
Solvable _solv
Definition Transaction.h:272
zypp::sat::Transaction::Step::satSolvable
Solvable satSolvable() const
Return the corresponding Solvable.
Definition Transaction.h:243
zypp::sat::Transaction::Step::edition
Edition edition() const
Definition Transaction.cc:402
zypp::sat::Transaction
Libsolv transaction wrapper.
Definition Transaction.h:52
zypp::sat::Transaction::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(StepStages, StepStage)
zypp::sat::Transaction::actionSize
size_t actionSize(StepStages filter_r=StepStages()) const
Number of steps in [filtered] transaction steps.
Definition Transaction.h:389
zypp::sat::Transaction::iterator
detail::Transaction_iterator iterator
Definition Transaction.h:115
zypp::sat::Transaction::end
const_iterator end() const
Iterator behind the last TransactionStep.
Definition Transaction.cc:345
zypp::sat::Transaction::actionEmpty
bool actionEmpty(StepStages filter_r=StepStages()) const
Whether the [filtered] transaction contains any steps .
Definition Transaction.h:386
zypp::sat::Transaction::_pimpl
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition Transaction.h:189
zypp::sat::Transaction::operator!=
bool operator!=(const Transaction &lhs, const Transaction &rhs)
Definition Transaction.h:204
zypp::sat::Transaction::installedResult
int installedResult(Queue &result_r) const
Return all packages that would be installed after the transaction is run.
Definition Transaction.cc:357
zypp::sat::Transaction::autoInstalled
StringQueue autoInstalled() const
Return the ident strings of all packages that would be auto-installed after the transaction is run.
Definition Transaction.cc:360
zypp::sat::Transaction::dumpOn
friend std::ostream & dumpOn(std::ostream &str, const Transaction &obj)
Definition Transaction.cc:369
zypp::sat::Transaction::begin
const_iterator begin() const
Iterator to the first TransactionStep.
Definition Transaction.cc:339
zypp::sat::Transaction::const_iterator
detail::Transaction_const_iterator const_iterator
Definition Transaction.h:116
zypp::sat::Transaction::valid
bool valid() const
Whether transaction actually contains data and also fits the current pools content.
Definition Transaction.cc:327
zypp::sat::Transaction::Transaction
Transaction()
Default ctor: empty transaction.
Definition Transaction.cc:316
zypp::sat::Transaction::action
Iterable< action_iterator > action(StepStages filter_r=StepStages()) const
Iterate the [filtered] transaction steps.
Definition Transaction.h:397
zypp::sat::Transaction::operator==
friend bool operator==(const Transaction &lhs, const Transaction &rhs)
Definition Transaction.cc:378
zypp::sat::Transaction::loadFromPool
static constexpr LoadFromPoolType loadFromPool
Definition Transaction.h:82
zypp::sat::Transaction::find
const_iterator find(const sat::Solvable &solv_r) const
Return iterator pointing to solv_r or end.
Definition Transaction.cc:351
zypp::sat::Transaction::StepType
StepType
Type of (rpm) action to perform in a Step.
Definition Transaction.h:63
zypp::sat::Transaction::TRANSACTION_MULTIINSTALL
@ TRANSACTION_MULTIINSTALL
[M] Install(multiversion) item (
Definition Transaction.h:67
zypp::sat::Transaction::TRANSACTION_INSTALL
@ TRANSACTION_INSTALL
[+] Install(update) item
Definition Transaction.h:66
zypp::sat::Transaction::TRANSACTION_IGNORE
@ TRANSACTION_IGNORE
[ ] Nothing (includes implicit deletes due to obsoletes and non-package actions)
Definition Transaction.h:64
zypp::sat::Transaction::TRANSACTION_ERASE
@ TRANSACTION_ERASE
[-] Delete item
Definition Transaction.h:65
zypp::sat::Transaction::actionBegin
action_iterator actionBegin(StepStages filter_r=StepStages()) const
Pointer to the 1st action step in [filtered] transaction.
Definition Transaction.h:380
zypp::sat::Transaction::action_iterator
filter_iterator< FilterAction, const_iterator > action_iterator
Definition Transaction.h:154
zypp::sat::Transaction::actionEnd
action_iterator actionEnd() const
Pointer behind the last action step in transaction.
Definition Transaction.h:383
zypp::sat::Transaction::StepStage
StepStage
Step action result.
Definition Transaction.h:72
zypp::sat::Transaction::STEP_DONE
@ STEP_DONE
[OK] success
Definition Transaction.h:74
zypp::sat::Transaction::STEP_TODO
@ STEP_TODO
[__] unprocessed
Definition Transaction.h:73
zypp::sat::Transaction::STEP_ERROR
@ STEP_ERROR
[**] error
Definition Transaction.h:75
zypp::sat::detail::Transaction_const_iterator
Transaction const_iterator.
Definition Transaction.h:328
zypp::sat::detail::Transaction_const_iterator::Transaction_const_iterator
Transaction_const_iterator(const RW_pointer< Transaction::Impl > &pimpl_r, base_type id_r)
Definition Transaction.h:332
zypp::sat::detail::Transaction_const_iterator::dereference
reference dereference() const
Definition Transaction.h:340
zypp::sat::detail::Transaction_const_iterator::Transaction_const_iterator
Transaction_const_iterator()
Definition Transaction.cc:453
zypp::sat::detail::Transaction_const_iterator::_pimpl
RW_pointer< Transaction::Impl > _pimpl
Pointer to implementation.
Definition Transaction.h:345
zypp::sat::detail::Transaction_const_iterator::iterator_core_access
friend class boost::iterator_core_access
Definition Transaction.h:338
zypp::sat::detail::Transaction_iterator
Transaction iterator.
Definition Transaction.h:299
zypp::sat::detail::Transaction_iterator::dereference
reference dereference() const
Definition Transaction.h:310
zypp::sat::detail::Transaction_iterator::Transaction_iterator
Transaction_iterator()
Definition Transaction.cc:462
zypp::sat::detail::Transaction_iterator::_pimpl
RW_pointer< Transaction::Impl > _pimpl
Pointer to implementation.
Definition Transaction.h:316
zypp::sat::detail::Transaction_iterator::Transaction_iterator
Transaction_iterator(const RW_pointer< Transaction::Impl > &pimpl_r, base_type id_r)
Definition Transaction.h:302
zypp::sat::detail::Transaction_iterator::iterator_core_access
friend class boost::iterator_core_access
Definition Transaction.h:308
zypp::sat::detail::Transaction_iterator::Transaction_const_iterator
friend class Transaction_const_iterator
Definition Transaction.h:314
str
String related utilities and Regular expression matching.
zypp::base
Definition Random.cc:7
zypp::sat::detail
Definition PoolImpl.cc:71
zypp::sat::detail::IdType
int IdType
Generic Id type.
Definition PoolMember.h:104
zypp::sat
Definition Resolver.h:28
zypp::sat::empty
bool empty() const
Whether neither idents nor provides are set.
zypp::sat::operator<<
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
Definition FileConflicts.cc:109
zypp::sat::StringQueue
Queue StringQueue
Queue with String ids.
Definition Queue.h:28
zypp::sat::dumpOn
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
Definition LocaleSupport.cc:41
zypp::sat::operator==
bool operator==(const Map &lhs, const Map &rhs)
Definition Map.cc:125
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::make_filter_begin
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
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::make_filter_end
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
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
zypp::sat::SolvableType::satSolvable
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition SolvableType.h:57
zypp::sat::Transaction::FilterAction
Definition Transaction.h:366
zypp::sat::Transaction::FilterAction::FilterAction
FilterAction()
Definition Transaction.h:367
zypp::sat::Transaction::FilterAction::operator()
bool operator()(const Transaction::Step &step_r) const
Definition Transaction.h:370
zypp::sat::Transaction::FilterAction::_filter
StepStages _filter
Definition Transaction.h:377
zypp::sat::Transaction::FilterAction::FilterAction
FilterAction(StepStages filter_r)
Definition Transaction.h:368
zypp::sat::Transaction::Impl
Transaction implementation.
Definition Transaction.cc:51
zypp::sat::Transaction::LoadFromPoolType
Ctor arg type.
Definition Transaction.h:81
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
ZYPP_DECLARE_OPERATORS_FOR_FLAGS
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition Flags.h:177
Flags.h
Iterator.h
PtrTypes.h