added implementation of target classes, which are container 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       /** Overload to realize stream output. */
64       virtual std::ostream & dumpOn( std::ostream & str ) const
65       { return str << "TargetImpl"; }
66
67       /** The RPM database */
68       rpm::RpmDb & rpm();
69
70     protected:
71       /** All resolvables provided by the target. */
72       ResStore _store;
73       /** Path to the target */
74       Pathname _root;
75       /** RPM database */
76       rpm::RpmDb _rpm;
77     private:
78       /** Null implementation */
79       static TargetImpl_Ptr _nullimpl;
80     };
81     ///////////////////////////////////////////////////////////////////
82
83     /** \relates TargetImpl Stream output */
84     inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
85     { return obj.dumpOn( str ); }
86
87     /////////////////////////////////////////////////////////////////
88   } // namespace target
89   ///////////////////////////////////////////////////////////////////
90   /////////////////////////////////////////////////////////////////
91 } // namespace zypp
92 ///////////////////////////////////////////////////////////////////
93 #endif // ZYPP_TARGET_TARGETIMPL_H