#define ZYPP_ZYPPCOMMITRESULT_H
#include <iosfwd>
+#include <vector>
#include <list>
#include "zypp/PoolItem.h"
+#include "zypp/sat/Transaction.h"
+#include "zypp/base/DefaultIntegral.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
+ namespace sat
+ {
+ class Transaction;
+ }
+
/** Pair of \ref sat::Solvable and \ref Pathname. */
class UpdateNotificationFile
{
//
/** Result returned from ZYpp::commit.
*
+ * \note Transaction data are provided and maintained during commit.
+ * Though the interface does not inhibit manipulation of transaction
+ * data outside commit (those methods could have been made \c private:),
+ * this is not recommended as you may easily mess up things.
+ *
* \see \ref ZYpp::commit
- * \todo document fields.
*/
class ZYppCommitResult
{
public:
+ typedef std::vector<sat::Transaction::Step> TransactionStepList;
+
+ public:
ZYppCommitResult();
+ ZYppCommitResult( const ZYppCommitResult & lhs_r );
ZYppCommitResult( const Pathname & root_r );
+ ~ZYppCommitResult();
public:
/** Remembered root directory of the target.
*/
const Pathname & root() const;
+ /** \c True if at least one attempt to actually install/remove packages was made.
+ * While this is false there should have been no serious modifications to the system.
+ * Mainly used to detect whether commit failed while preloading the caches or within
+ * the real action.
+ */
+ bool attemptToModify() const;
+
+ /** Set \ref attemptToModify */
+ void attemptToModify( bool yesno_r );
+
+ /** The full transaction list.
+ * The complete list including transaction steps that do not require
+ * any action (like obsoletes or non-package actions). Depending on
+ * \ref ZYppCommitPolicy::restrictToMedia only a subset of this
+ * transaction might have been executed.
+ * \see \ref transactionStepList.
+ */
+ const sat::Transaction & transaction() const;
+
+ /** Manipulate \ref transaction */
+ sat::Transaction & rTransaction();
+
+ /** List of \ref sat::Transaction::Step to be executed by commit.
+ * The list of transaction step commit actually tried to execute.
+ */
+ const TransactionStepList & transactionStepList() const;
+
+ /** Manipulate \ref transactionStepList. */
+ TransactionStepList & rTransactionStepList();
+
/** List of update messages installed during this commit.
* \Note Pathnames are relative to the targets root directory.
* \code
*/
const UpdateNotifications & updateMessages() const;
- /** Change list of update messages installed during this commit.
+ /** Manipulate \ref updateMessages
* \Note Pathnames are relative to the targets root directory.
*/
- UpdateNotifications & setUpdateMessages();
+ UpdateNotifications & rUpdateMessages();
public:
- /** \name Oldstlye interface to be removed asap.
+
+ /** \name Some statistics based on \ref Transaction
+ *
+ * Class \ref Transaction allows to count and iterate the action steps to
+ * get more detailed information about the transaction result. Here are just
+ * a few convenience methods for easy evaluation.
+ *
+ * \code
+ * ZYppCommitResult result;
+ * const sat::Transaction & trans( result.transaction() );
+ * for_( it, trans.actionBegin(~sat::Transaction::STEP_DONE), trans.actionEnd() )
+ * {
+ * // process all steps not DONE (ERROR and TODO)
+ * if ( it->satSolvable() )
+ * std::cout << it->satSolvable() << endl;
+ * else // deleted @System solvable: print post mortem data available
+ * std::cout << it->ident() << endl;
+ * }
+ * \endcode
+ * \see \ref Transaction, \ref transaction()
*/
//@{
- typedef std::list<PoolItem> PoolItemList;
- /**
- * number of committed resolvables
- **/
- int _result;
- /**
- * list of resolvables with error
- **/
- PoolItemList _errors;
- /**
- * list of resolvables remaining (due to wrong media)
- **/
- PoolItemList _remaining;
- /**
- * list of kind:source resolvables remaining (due to wrong media)
- **/
- PoolItemList _srcremaining;
+ /** Whether all steps were performed successfully (none skipped or error) */
+ bool allDone() const
+ { return transaction().actionEmpty( ~sat::Transaction::STEP_DONE ); }
+
+ /** Whether an error ocurred (skipped streps are ok). */
+ bool noError() const
+ { return transaction().actionEmpty( sat::Transaction::STEP_ERROR ); }
//@}
public: