fc70cfadbc26570f2fbbdc9d523b1ad2423b0ea9
[platform/upstream/libzypp.git] / zypp / zypp_detail / ZYppImpl.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/zypp_detail/ZYppImpl.h
10  *
11 */
12 #ifndef ZYPP_ZYPP_DETAIL_ZYPPIMPL_H
13 #define ZYPP_ZYPP_DETAIL_ZYPPIMPL_H
14
15 #include <iosfwd>
16
17 #include "zypp/TmpPath.h"
18 #include "zypp/Target.h"
19 #include "zypp/Resolver.h"
20 #include "zypp/KeyRing.h"
21 #include "zypp/ZYppCommit.h"
22 #include "zypp/ResTraits.h"
23 #include "zypp/DiskUsageCounter.h"
24 #include "zypp/ManagedFile.h"
25
26 using namespace zypp::filesystem;
27
28 ///////////////////////////////////////////////////////////////////
29 namespace zypp
30 { /////////////////////////////////////////////////////////////////
31   ///////////////////////////////////////////////////////////////////
32   namespace zypp_detail
33   { /////////////////////////////////////////////////////////////////
34
35     ///////////////////////////////////////////////////////////////////
36     //
37     //  CLASS NAME : ZYppImpl
38     //
39     /** */
40     class ZYppImpl
41     {
42       friend std::ostream & operator<<( std::ostream & str, const ZYppImpl & obj );
43
44     public:
45       /** Default ctor */
46       ZYppImpl();
47       /** Dtor */
48       ~ZYppImpl();
49
50     public:
51       /** */
52       ResPool pool() const
53       { return ResPool::instance(); }
54
55       ResPoolProxy poolProxy() const
56       { return ResPool::instance().proxy(); }
57
58       /** */
59       KeyRing_Ptr keyRing() const
60       { return _keyring; }
61
62
63       Resolver_Ptr resolver() const
64       { return _resolver; }
65
66     public:
67       /** \todo Signal locale change. */
68       /**
69        * \throws Exception
70        */
71       Target_Ptr target() const;
72
73       /** Same as \ref target but returns NULL if target is not
74        *  initialized, instead of throwing.
75        */
76       Target_Ptr getTarget() const
77       { return _target; }
78
79       /**
80        * \throws Exception
81        * true, just init the target, dont populate store or pool
82        */
83       void initializeTarget( const Pathname & root, bool doRebuild_r );
84
85       /**
86        * \throws Exception
87        */
88       void finishTarget();
89
90       /** Commit changes and transactions. */
91       ZYppCommitResult commit( const ZYppCommitPolicy & policy_r );
92
93       /** Install a source package on the Target. */
94       void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
95
96       /** Install a source package on the Target. */
97       ManagedFile provideSrcPackage( const SrcPackage_constPtr & srcPackage_r );
98
99     public:
100       /** Get the path where zypp related plugins store persistent data and caches   */
101       Pathname homePath() const;
102
103       /** Get the path where zypp related plugins store tmp data   */
104       Pathname tmpPath() const;
105
106       /** set the home, if you need to change it */
107       void setHomePath( const Pathname & path );
108
109     public:
110       DiskUsageCounter::MountPointSet diskUsage();
111       void setPartitions(const DiskUsageCounter::MountPointSet &mp);
112       DiskUsageCounter::MountPointSet getPartitions() const;
113
114     private:
115       /** */
116       Target_Ptr _target;
117       /** */
118       Resolver_Ptr _resolver;
119
120       KeyRing_Ptr _keyring;
121       /** */
122       Pathname _home_path;
123       /** defined mount points, used for disk usage counting */
124       shared_ptr<DiskUsageCounter> _disk_usage;
125     };
126     ///////////////////////////////////////////////////////////////////
127
128     /** \relates ZYppImpl Stream output */
129     std::ostream & operator<<( std::ostream & str, const ZYppImpl & obj );
130
131     /////////////////////////////////////////////////////////////////
132   } // namespace zypp_detail
133   ///////////////////////////////////////////////////////////////////
134   /////////////////////////////////////////////////////////////////
135 } // namespace zypp
136 ///////////////////////////////////////////////////////////////////
137 #endif // ZYPP_ZYPP_DETAIL_ZYPPIMPL_H