Remove obsolete ResStatus bits.
[platform/upstream/libzypp.git] / zypp / ZYppCommitResult.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ZYppCommitResult.h
10  *
11 */
12 #ifndef ZYPP_ZYPPCOMMITRESULT_H
13 #define ZYPP_ZYPPCOMMITRESULT_H
14
15 #include <iosfwd>
16 #include <list>
17
18 #include "zypp/PoolItem.h"
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23
24   /** Pair of \ref sat::Solvable and \ref Pathname. */
25   class UpdateNotificationFile
26   {
27     public:
28       UpdateNotificationFile( sat::Solvable solvable_r, const Pathname & file_r )
29       : _solvable( solvable_r ), _file( file_r )
30       {}
31     public:
32       sat::Solvable solvable() const { return _solvable; }
33       const Pathname & file() const { return _file; }
34     private:
35       sat::Solvable _solvable;
36       Pathname      _file;
37   };
38
39   typedef std::list<UpdateNotificationFile> UpdateNotifications;
40
41   ///////////////////////////////////////////////////////////////////
42   //
43   //    CLASS NAME : ZYppCommitResult
44   //
45   /** Result returned from ZYpp::commit.
46    *
47    * \see \ref ZYpp::commit
48    * \todo document fields.
49    */
50   class ZYppCommitResult
51   {
52     public:
53       ZYppCommitResult();
54       ZYppCommitResult( const Pathname & root_r );
55
56     public:
57       /** Remembered root directory of the target.
58        *  \Note Pathnames within this class are relative to the
59        * targets root directory.
60       */
61       const Pathname & root() const;
62
63       /** List of update messages installed during this commit.
64        * \Note Pathnames are relative to the targets root directory.
65        * \code
66        *   ZYppCommitResult result;
67        *   ...
68        *   if ( ! result.updateMessages().empty() )
69        *   {
70        *     MIL << "Received " << result.updateMessages().size() << " update notification(s):" << endl;
71        *     for_( it, result.updateMessages().begin(), result.updateMessages().end() )
72        *     {
73        *       MIL << "- From " << it->solvable().asString() << " in file " << Pathname::showRootIf( result.root(), it->file() ) << ":" << endl;
74        *       {
75        *         // store message files content in a string:
76        *         InputStream istr( Pathname::assertprefix( result.root(), it->file() ) );
77        *         std::ostringstream strstr;
78        *         iostr::copy( istr, strstr );
79        *         std::string message( strstr.str() ); // contains the message
80        *       }
81        *       {
82        *         // or write out the message file indented:
83        *         InputStream istr( Pathname::assertprefix( result.root(), it->file() ) );
84        *         iostr::copyIndent( istr, MIL, "> " ) << endl;
85        *       }
86        *     }
87        *   }
88        * \endcode
89        */
90       const UpdateNotifications & updateMessages() const;
91
92       /** Change list of update messages installed during this commit.
93        * \Note Pathnames are relative to the targets root directory.
94        */
95       UpdateNotifications & setUpdateMessages();
96
97     public:
98       /** \name Oldstlye interface to be removed asap.
99        */
100       //@{
101       typedef std::list<PoolItem> PoolItemList;
102       /**
103        * number of committed resolvables
104        **/
105       int          _result;
106       /**
107        * list of resolvables with error
108        **/
109       PoolItemList _errors;
110       /**
111        * list of resolvables remaining (due to wrong media)
112        **/
113       PoolItemList _remaining;
114       /**
115        * list of kind:source resolvables remaining (due to wrong media)
116        **/
117       PoolItemList _srcremaining;
118       //@}
119
120     public:
121       /** Implementation  */
122       class Impl;
123     private:
124       /** Pointer to data. */
125       RWCOW_pointer<Impl> _pimpl;
126   };
127   ///////////////////////////////////////////////////////////////////
128
129   /** \relates ZYppCommitResult Stream output. */
130   std::ostream & operator<<( std::ostream & str, const ZYppCommitResult & obj );
131
132   /////////////////////////////////////////////////////////////////
133 } // namespace zypp
134 ///////////////////////////////////////////////////////////////////
135 #endif // ZYPP_ZYPPCOMMITRESULT_H