Imported Upstream version 17.23.5
[platform/upstream/libzypp.git] / zypp / target / rpm / RpmCallbacks.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/rpm/RpmCallbacks.h
10  *
11 */
12
13 #ifndef ZYPP_TARGET_RPM_RPMCALLBACKS_H
14 #define ZYPP_TARGET_RPM_RPMCALLBACKS_H
15
16 #include <iosfwd>
17
18 #include <zypp/Url.h>
19 #include <zypp/Callback.h>
20 #include <zypp/base/Exception.h>
21 #include <zypp/Pathname.h>
22
23 namespace zypp
24 {
25 namespace target
26 {
27 namespace rpm
28 {
29
30 ///////////////////////////////////////////////////////////////////
31 // Reporting progress of package removing
32 ///////////////////////////////////////////////////////////////////
33 struct RpmRemoveReport : public callback::ReportBase
34 {
35
36   enum Action {
37     ABORT,  // abort and return error
38     RETRY,   // retry
39     IGNORE   // ignore
40   };
41
42   /** Start the operation */
43   virtual void start( const std::string & name )
44   {}
45   /**
46    * Inform about progress
47    * Return true on abort
48    */
49   virtual bool progress( unsigned percent )
50   { return false; }
51
52   virtual Action problem( Exception & excpt_r )
53   { return ABORT; }
54
55   /** Additional rpm output to be reported in \ref finish in case of success. */
56   virtual void finishInfo( const std::string & info_r )
57   {}
58
59   /** Finish operation in case of success */
60   virtual void finish()
61   {}
62   /** Finish operation in case of fail, report fail exception */
63   virtual void finish( Exception & excpt_r )
64   {}
65 };
66
67 ///////////////////////////////////////////////////////////////////
68 // Reporting progress of package installation
69 ///////////////////////////////////////////////////////////////////
70 struct RpmInstallReport : public callback::ReportBase
71 {
72
73   enum Action {
74     ABORT,  // abort and return error
75     RETRY,   // retry
76     IGNORE   // ignore
77   };
78
79   /** Start the operation */
80   virtual void start( const Pathname & name )
81   {}
82   /**
83    * Inform about progress
84    * Return false on abort
85    */
86   virtual bool progress( unsigned percent )
87   { return true; }
88
89   /** Additional rpm output to be reported in \ref finish in case of success. */
90   virtual void finishInfo( const std::string & info_r )
91   {}
92
93   /** Finish operation in case of success */
94   virtual void finish()
95   {}
96
97   virtual Action problem( Exception & excpt_r )
98   { return ABORT; }
99
100   /** Finish operation in case of fail, report fail exception */
101   virtual void finish( Exception & excpt_r )
102   {}
103 };
104
105 } // namespace rpm
106 } // namespace target
107 } // namespace zypp
108
109 #endif // ZYPP_TARGET_RPM_RPMCALLBACKS_H