- fixed some typos
[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    * ZYpp API main interface
53    */
54   class ZYpp : public base::ReferenceCounted, private base::NonCopyable
55   {
56   public:
57
58     typedef intrusive_ptr<ZYpp>       Ptr;
59     typedef intrusive_ptr<const ZYpp> constPtr;
60
61   public:
62
63     /** 
64      * Access to the main resolvable pool
65      * \ref zypp::ResPool
66      */
67     ResPool pool() const;
68
69     /** Pool of ui::Selectable.
70      * Based on the ResPool, ui::Selectable groups ResObjetcs of
71      * same kind and name.
72     */
73     ResPoolProxy poolProxy() const;
74
75     /**  */
76     //SourceFeed_Ref sourceFeed() const;
77
78     void addResolvables (const ResStore& store, bool installed = false);
79
80     void removeResolvables (const ResStore& store);
81
82     DiskUsageCounter::MountPointSet diskUsage();
83
84     void setPartitions(const DiskUsageCounter::MountPointSet &mp);
85     
86     DiskUsageCounter::MountPointSet getPartitions() const;
87
88   public:
89     /**
90      * \throws Exception
91      */
92     Target_Ptr target() const;
93
94     /**
95      * \throws Exception
96      * just init the target, dont populate store or pool
97      */
98     void initializeTarget(const Pathname & root);
99
100     /**
101      * \throws Exception
102      * if commit_only == true, just init the target, dont populate store or pool
103      */
104     ZYPP_DEPRECATED void initTarget(const Pathname & root, bool commit_only = false);  
105     
106     /**
107      * \throws Exception
108      */
109     void finishTarget();
110
111
112   public:
113     typedef ZYppCommitResult CommitResult;
114
115     /** Commit changes and transactions.
116      * \param \ref CommitPolicy
117      * \return \ref CommitResult
118      * \throws Exception
119     */
120     ZYppCommitResult commit( const ZYppCommitPolicy & policy_r );
121
122   public:
123     /** */
124     Resolver_Ptr resolver() const;
125     KeyRing_Ptr keyRing() const;
126   public:
127     /** Set the preferred locale for translated labels, descriptions,
128      *  etc. passed to the UI.
129      */
130     void setTextLocale( const Locale & textLocale_r );
131     /** */
132     Locale getTextLocale() const;
133
134   public:
135     typedef std::set<Locale> LocaleSet;
136     /** Set the requested locales.
137      * Languages to be supported by the system, e.g. language specific
138      * packages to be installed. This function operates on the pool,
139      * so only the locales that are available as resolvables
140      * are marked as requested. The rest is ignored.
141     */
142     void setRequestedLocales( const LocaleSet & locales_r );
143     /** */
144     LocaleSet getRequestedLocales() const;
145
146     /**
147      * Get the set of available locales.
148      * This is computed from the package data so it actually
149      * represents all locales packages claim to support.
150      */
151     LocaleSet getAvailableLocales() const;
152
153     /**
154      * internal use only
155      **/
156     void availableLocale( const Locale & locale_r );
157
158   public:
159     /** Get the path where zypp related plugins store persistent data and caches   */
160     Pathname homePath() const;
161     
162     /** Get the path where zypp related plugins store temp data   */
163     Pathname tmpPath() const;
164     
165     /** set the home, if you need to change it */
166     void setHomePath( const Pathname & path );
167
168     /** Get the system architecture.   */
169     Arch architecture() const;
170     /** Set the system architecture.
171         This should be used for testing/debugging only since the Target backend
172         won't be able to install incompatible packages ;-)   */
173     void setArchitecture( const Arch & arch );
174
175   protected:
176     /** Dtor */
177     virtual ~ZYpp();
178     /** Stream output */
179     virtual std::ostream & dumpOn( std::ostream & str ) const;
180   private:
181     /** Factory */
182     friend class ZYppFactory;
183
184     /** */
185     typedef zypp_detail::ZYppImpl Impl;
186     typedef shared_ptr<Impl>      Impl_Ptr;
187     /** Factory ctor */
188     explicit
189     ZYpp( const Impl_Ptr & impl_r );
190   private:
191     /** Pointer to implementation */
192     RW_pointer<Impl> _pimpl;
193   };
194   ///////////////////////////////////////////////////////////////////
195
196   /////////////////////////////////////////////////////////////////
197 } // namespace zypp
198 ///////////////////////////////////////////////////////////////////
199 #endif // ZYPP_ZYPP_H