Imported Upstream version 17.23.5
[platform/upstream/libzypp.git] / zypp / target / RpmPostTransCollector.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/target/RpmPostTransCollector.h
10  */
11 #ifndef ZYPP_TARGET_RPMPOSTTRANSCOLLECTOR_H
12 #define ZYPP_TARGET_RPMPOSTTRANSCOLLECTOR_H
13
14 #include <iosfwd>
15
16 #include <zypp/base/PtrTypes.h>
17 #include <zypp/ManagedFile.h>
18 #include <zypp/Pathname.h>
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 {
23   ///////////////////////////////////////////////////////////////////
24   namespace target
25   {
26     ///////////////////////////////////////////////////////////////////
27     /// \class RpmPostTransCollector
28     /// \brief Extract and remember %posttrans scripts for later execution
29     /// \todo Maybe embedd this into the TransactionSteps.
30     ///////////////////////////////////////////////////////////////////
31     class RpmPostTransCollector
32     {
33       friend std::ostream & operator<<( std::ostream & str, const RpmPostTransCollector & obj );
34       friend std::ostream & dumpOn( std::ostream & str, const RpmPostTransCollector & obj );
35
36       public:
37         /** Default ctor */
38         RpmPostTransCollector( const Pathname & root_r );
39
40         /** Dtor */
41         ~RpmPostTransCollector();
42
43       public:
44         /** Extract and remember a packages %posttrans script for later execution.
45          * \return whether a script was collected.
46          */
47         bool collectScriptFromPackage( ManagedFile rpmPackage_r );
48
49         /** Execute the remembered scripts.
50          * \return false if execution was aborted by a user callback
51          */
52         bool executeScripts();
53
54         /** Discard all remembered scrips. */
55         void discardScripts();
56
57       public:
58         class Impl;              ///< Implementation class.
59       private:
60         RW_pointer<Impl> _pimpl; ///< Pointer to implementation.
61     };
62
63     /** \relates RpmPostTransCollector Stream output */
64     std::ostream & operator<<( std::ostream & str, const RpmPostTransCollector & obj );
65
66     /** \relates RpmPostTransCollector Verbose stream output */
67     std::ostream & dumOn( std::ostream & str, const RpmPostTransCollector & obj );
68
69   } // namespace target
70   ///////////////////////////////////////////////////////////////////
71 } // namespace zypp
72 ///////////////////////////////////////////////////////////////////
73 #endif // ZYPP_TARGET_RPMPOSTTRANSCOLLECTOR_H