1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ZYppCommitResult.h
12 #ifndef ZYPP_ZYPPCOMMITRESULT_H
13 #define ZYPP_ZYPPCOMMITRESULT_H
19 #include "zypp/PoolItem.h"
20 #include "zypp/sat/Transaction.h"
21 #include "zypp/base/DefaultIntegral.h"
23 ///////////////////////////////////////////////////////////////////
25 { /////////////////////////////////////////////////////////////////
32 /** Pair of \ref sat::Solvable and \ref Pathname. */
33 class UpdateNotificationFile
36 UpdateNotificationFile( sat::Solvable solvable_r, const Pathname & file_r )
37 : _solvable( solvable_r ), _file( file_r )
40 sat::Solvable solvable() const { return _solvable; }
41 const Pathname & file() const { return _file; }
43 sat::Solvable _solvable;
47 typedef std::list<UpdateNotificationFile> UpdateNotifications;
49 ///////////////////////////////////////////////////////////////////
51 // CLASS NAME : ZYppCommitResult
53 /** Result returned from ZYpp::commit.
55 * \note Transaction data are provided and maintained during commit.
56 * Though the interface does not inhibit manipulation of transaction
57 * data outside commit (those methods could have been made \c private:),
58 * this is not recommended as you may easily mess up things.
60 * \see \ref ZYpp::commit
62 class ZYppCommitResult
65 typedef std::vector<sat::Transaction::Step> TransactionStepList;
69 ZYppCommitResult( const ZYppCommitResult & lhs_r );
70 ZYppCommitResult( const Pathname & root_r );
74 /** Remembered root directory of the target.
75 * \Note Pathnames within this class are relative to the
76 * targets root directory.
78 const Pathname & root() const;
80 /** The full transaction list.
81 * The complete list including transaction steps that do not require
82 * any action (like obsoletes or non-package actions). Depending on
83 * \ref ZYppCommitPolicy::restrictToMedia only a subset of this
84 * transaction might have been executed.
85 * \see \ref transactionStepList.
87 const sat::Transaction & transaction() const;
89 /** Manipulate \ref transaction */
90 sat::Transaction & rTransaction();
92 /** List of \ref sat::Transaction::Step to be executed by commit.
93 * The list of transaction step commit actually tried to execute.
95 const TransactionStepList & transactionStepList() const;
97 /** Manipulate \ref transactionStepList. */
98 TransactionStepList & rTransactionStepList();
100 /** List of update messages installed during this commit.
101 * \Note Pathnames are relative to the targets root directory.
103 * ZYppCommitResult result;
105 * if ( ! result.updateMessages().empty() )
107 * MIL << "Received " << result.updateMessages().size() << " update notification(s):" << endl;
108 * for_( it, result.updateMessages().begin(), result.updateMessages().end() )
110 * MIL << "- From " << it->solvable().asString() << " in file " << Pathname::showRootIf( result.root(), it->file() ) << ":" << endl;
112 * // store message files content in a string:
113 * InputStream istr( Pathname::assertprefix( result.root(), it->file() ) );
114 * std::ostringstream strstr;
115 * iostr::copy( istr, strstr );
116 * std::string message( strstr.str() ); // contains the message
119 * // or write out the message file indented:
120 * InputStream istr( Pathname::assertprefix( result.root(), it->file() ) );
121 * iostr::copyIndent( istr, MIL, "> " ) << endl;
127 const UpdateNotifications & updateMessages() const;
129 /** Manipulate \ref updateMessages
130 * \Note Pathnames are relative to the targets root directory.
132 UpdateNotifications & rUpdateMessages();
136 /** \name Some statistics based on \ref Transaction
138 * Class \ref Transaction allows to count and iterate the action steps to
139 * get more detailed information about the transaction result. Here are just
140 * a few convenience methods for easy evaluation.
143 * ZYppCommitResult result;
144 * const sat::Transaction & trans( result.transaction() );
145 * for_( it, trans.actionBegin(~sat::Transaction::STEP_DONE), trans.actionEnd() )
147 * // process all steps not DONE (ERROR and TODO)
148 * if ( it->satSolvable() )
149 * std::cout << it->satSolvable() << endl;
150 * else // deleted @System solvable: print post mortem data available
151 * std::cout << it->ident() << endl;
154 * \see \ref Transaction, \ref transaction()
157 /** Whether all steps were performed successfully (none skipped or error) */
159 { return transaction().actionEmpty( ~sat::Transaction::STEP_DONE ); }
161 /** Whether an error ocurred (skipped streps are ok). */
163 { return transaction().actionEmpty( sat::Transaction::STEP_ERROR ); }
167 /** \name Oldstlye interface to be removed asap.
168 * \deprecated PoolItem is not suitable for reporting errors about
169 * packages to be deteled, as reloading the rpm database after commit
173 typedef std::list<PoolItem> PoolItemList;
175 * number of committed resolvables
177 int _result ZYPP_DEPRECATED;
179 * list of resolvables with error
181 PoolItemList _errors ZYPP_DEPRECATED;
183 * list of resolvables remaining (due to wrong media)
185 PoolItemList _remaining ZYPP_DEPRECATED;
187 * list of kind:source resolvables remaining (due to wrong media)
189 PoolItemList _srcremaining ZYPP_DEPRECATED;
193 /** Implementation */
196 /** Pointer to data. */
197 RWCOW_pointer<Impl> _pimpl;
199 ///////////////////////////////////////////////////////////////////
201 /** \relates ZYppCommitResult Stream output. */
202 std::ostream & operator<<( std::ostream & str, const ZYppCommitResult & obj );
204 /////////////////////////////////////////////////////////////////
206 ///////////////////////////////////////////////////////////////////
207 #endif // ZYPP_ZYPPCOMMITRESULT_H