3a9dbd6be3fc9dd34642e5e282f48d02b5d911d7
[platform/upstream/libzypp.git] / zypp / ZYpp.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ZYpp.h
10  *
11 */
12 #ifndef ZYPP_ZYPP_H
13 #define ZYPP_ZYPP_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
21 #include "zypp/base/Deprecated.h"
22 #include "zypp/ZYppCommit.h"
23
24 #include "zypp/Target.h"
25 #include "zypp/Resolver.h"
26 #include "zypp/KeyRing.h"
27 #include "zypp/DiskUsageCounter.h"
28
29 ///////////////////////////////////////////////////////////////////
30 namespace zypp
31 { /////////////////////////////////////////////////////////////////
32
33   namespace zypp_detail
34   {
35     class ZYppImpl;
36   }
37
38   class ZYppFactory;
39   class ResPool;
40   class ResPoolProxy;
41   class SourceFeed_Ref;
42   class ResStore;
43   class Locale;
44   class KeyRing;
45
46   ///////////////////////////////////////////////////////////////////
47   //
48   //    CLASS NAME : ZYpp
49   //
50   /**
51    * \todo define Exceptions
52   */
53   class ZYpp : public base::ReferenceCounted, private base::NonCopyable
54   {
55   public:
56
57     typedef intrusive_ptr<ZYpp>       Ptr;
58     typedef intrusive_ptr<const ZYpp> constPtr;
59
60   public:
61
62     /** Pool of ResStatus for individual ResObjetcs. */
63     ResPool pool() const;
64
65     /** Pool of ui::Selectable.
66      * Based on the ResPool, ui::Selectable groups ResObjetcs of
67      * same kind and name.
68     */
69     ResPoolProxy poolProxy() const;
70
71     /**  */
72     //SourceFeed_Ref sourceFeed() const;
73
74     void addResolvables (const ResStore& store, bool installed = false);
75
76     void removeResolvables (const ResStore& store);
77
78     DiskUsageCounter::MountPointSet diskUsage();
79
80     void setPartitions(const DiskUsageCounter::MountPointSet &mp);
81
82     /** NOOP */
83     ZYPP_DEPRECATED void reset() {}
84   public:
85     /**
86      * \throws Exception
87      */
88     Target_Ptr target() const;
89
90     /**
91      * \throws Exception
92      * if commit_only == true, just init, don't populate store or pool
93      */
94     void initTarget(const Pathname & root, bool commit_only = false);
95
96     /**
97      * \throws Exception
98      */
99     void finishTarget();
100
101
102   public:
103     typedef ZYppCommitResult CommitResult;
104
105     /** Commit changes and transactions.
106      * \param \ref CommitPolicy
107      * \return \ref CommitResult
108      * \throws Exception
109     */
110     ZYppCommitResult commit( const ZYppCommitPolicy & policy_r );
111
112     ZYPP_DEPRECATED ZYppCommitResult commit( int medianr_r, bool dry_run = false )
113     {
114       ZYppCommitPolicy policy;
115       policy.restrictToMedia( medianr_r ).dryRun( dry_run );
116       return commit( policy );
117     }
118
119
120   public:
121     /** */
122     Resolver_Ptr resolver() const;
123     KeyRing_Ptr keyRing() const;
124   public:
125     /** Set the preferd locale for translated labels, descriptions,
126      *  etc. passed to the UI.
127      */
128     void setTextLocale( const Locale & textLocale_r );
129     /** */
130     Locale getTextLocale() const;
131
132   public:
133     typedef std::set<Locale> LocaleSet;
134     /** Set the requested locales.
135      * Languages to be supported by the system, e.g. language specific
136      * packages to be installed.
137     */
138     void setRequestedLocales( const LocaleSet & locales_r );
139     /** */
140     LocaleSet getRequestedLocales() const;
141
142     /**
143      * Get the set of available locales.
144      * This is computed from the package data so it actually
145      * represents all locales packages claim to support.
146      */
147     LocaleSet getAvailableLocales() const;
148
149     /**
150      * internal use only
151      **/
152     void availableLocale( const Locale & locale_r );
153
154   public:
155     /** Get the path where zypp related plugins store persistent data and caches   */
156     Pathname homePath() const;
157     /** set the home, if you need to change it */
158     void setHomePath( const Pathname & path );
159
160     /** Get the system architecture.   */
161     Arch architecture() const;
162     /** Set the system architecture.
163         This should be used for testing/debugging only since the Target backend
164         won't be able to install incompatible packages ;-)   */
165     void setArchitecture( const Arch & arch );
166
167   protected:
168     /** Dtor */
169     virtual ~ZYpp();
170     /** Stream output */
171     virtual std::ostream & dumpOn( std::ostream & str ) const;
172   private:
173     /** Factory */
174     friend class ZYppFactory;
175
176     /** */
177     typedef zypp_detail::ZYppImpl Impl;
178     typedef shared_ptr<Impl>      Impl_Ptr;
179     /** Factory ctor */
180     explicit
181     ZYpp( const Impl_Ptr & impl_r );
182   private:
183     /** Pointer to implementation */
184     RW_pointer<Impl> _pimpl;
185   };
186   ///////////////////////////////////////////////////////////////////
187
188   /////////////////////////////////////////////////////////////////
189 } // namespace zypp
190 ///////////////////////////////////////////////////////////////////
191 #endif // ZYPP_ZYPP_H