added preliminary commit function for target
[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
27 ///////////////////////////////////////////////////////////////////
28 namespace zypp
29 { /////////////////////////////////////////////////////////////////
30   ///////////////////////////////////////////////////////////////////
31   namespace target
32   { /////////////////////////////////////////////////////////////////
33
34     DEFINE_PTR_TYPE(TargetImpl);
35
36     ///////////////////////////////////////////////////////////////////
37     //
38     //  CLASS NAME : TargetImpl
39     //
40     /** Base class for concrete Target implementations.
41      *
42      * Constructed by \ref TargetFactory. Public access via \ref Target
43      * interface.
44     */
45     class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
46     {
47       friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
48
49     public:
50       /** Ctor. */
51       TargetImpl(const Pathname & root_r = "/");
52       /** Dtor. */
53       virtual ~TargetImpl();
54
55       /** Null implementation */
56       static TargetImpl_Ptr nullimpl();
57
58     public:
59
60       /** All resolvables in the target. */
61       const ResStore & resolvables();
62
63       /** Comomit changes in the pool */
64 #warning Add support for multiple medias - eg. limit only to CD1
65       void commit(ResPool & pool_r);
66
67       /** Overload to realize stream output. */
68       virtual std::ostream & dumpOn( std::ostream & str ) const
69       { return str << "TargetImpl"; }
70
71       /** The RPM database */
72       rpm::RpmDb & rpm();
73
74     protected:
75       /** All resolvables provided by the target. */
76       ResStore _store;
77       /** Path to the target */
78       Pathname _root;
79       /** RPM database */
80       rpm::RpmDb _rpm;
81     private:
82       /** Null implementation */
83       static TargetImpl_Ptr _nullimpl;
84     };
85     ///////////////////////////////////////////////////////////////////
86
87     /** \relates TargetImpl Stream output */
88     inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
89     { return obj.dumpOn( str ); }
90
91     /////////////////////////////////////////////////////////////////
92   } // namespace target
93   ///////////////////////////////////////////////////////////////////
94   /////////////////////////////////////////////////////////////////
95 } // namespace zypp
96 ///////////////////////////////////////////////////////////////////
97 #endif // ZYPP_TARGET_TARGETIMPL_H