split commit into 2 functions
[platform/upstream/libzypp.git] / zypp / target / TargetImpl.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/target/TargetImpl.h
10  *
11 */
12 #ifndef ZYPP_TARGET_TARGETIMPL_H
13 #define ZYPP_TARGET_TARGETIMPL_H
14
15 #include <iosfwd>
16
17 #include "zypp/base/ReferenceCounted.h"
18 #include "zypp/base/NonCopyable.h"
19 #include "zypp/base/PtrTypes.h"
20 #include "zypp/ResStore.h"
21
22 #include "zypp/Pathname.h"
23 #include "zypp/media/MediaAccess.h"
24 #include "zypp/Target.h"
25 #include "zypp/target/rpm/RpmDb.h"
26 #include "zypp/solver/detail/Types.h"
27
28 ///////////////////////////////////////////////////////////////////
29 namespace zypp
30 { /////////////////////////////////////////////////////////////////
31   ///////////////////////////////////////////////////////////////////
32   namespace target
33   { /////////////////////////////////////////////////////////////////
34
35     DEFINE_PTR_TYPE(TargetImpl);
36
37     ///////////////////////////////////////////////////////////////////
38     //
39     //  CLASS NAME : TargetImpl
40     //
41     /** Base class for concrete Target implementations.
42      *
43      * Constructed by \ref TargetFactory. Public access via \ref Target
44      * interface.
45     */
46     class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
47     {
48       friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
49
50     public:
51       /** Ctor. */
52       TargetImpl(const Pathname & root_r = "/");
53       /** Dtor. */
54       virtual ~TargetImpl();
55
56       /** Null implementation */
57       static TargetImpl_Ptr nullimpl();
58
59     public:
60
61       /** All resolvables in the target. */
62       const ResStore & resolvables();
63
64       /** Comomit changes in the pool */
65 #warning Add support for multiple medias - eg. limit only to CD1
66       void commit(ResPool pool_r);
67
68       /** Comomit ordered changes */
69       void commit(const PoolItemList & items_r);
70
71       /** Overload to realize stream output. */
72       virtual std::ostream & dumpOn( std::ostream & str ) const
73       { return str << "TargetImpl"; }
74
75       /** The RPM database */
76       rpm::RpmDb & rpm();
77
78     protected:
79       /** All resolvables provided by the target. */
80       ResStore _store;
81       /** Path to the target */
82       Pathname _root;
83       /** RPM database */
84       rpm::RpmDb _rpm;
85     private:
86       /** Null implementation */
87       static TargetImpl_Ptr _nullimpl;
88     };
89     ///////////////////////////////////////////////////////////////////
90
91     /** \relates TargetImpl Stream output */
92     inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
93     { return obj.dumpOn( str ); }
94
95     /////////////////////////////////////////////////////////////////
96   } // namespace target
97   ///////////////////////////////////////////////////////////////////
98   /////////////////////////////////////////////////////////////////
99 } // namespace zypp
100 ///////////////////////////////////////////////////////////////////
101 #endif // ZYPP_TARGET_TARGETIMPL_H