ignore
[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   public:
83     /**
84      * \throws Exception
85      */
86     Target_Ptr target() const;
87
88     /**
89      * \throws Exception
90      * just init the target, dont populate store or pool
91      */
92     void initializeTarget(const Pathname & root);
93
94     /**
95      * \throws Exception
96      * if commit_only == true, just init the target, dont populate store or pool
97      */
98     ZYPP_DEPRECATED void initTarget(const Pathname & root, bool commit_only = false);  
99     
100     /**
101      * \throws Exception
102      */
103     void finishTarget();
104
105
106   public:
107     typedef ZYppCommitResult CommitResult;
108
109     /** Commit changes and transactions.
110      * \param \ref CommitPolicy
111      * \return \ref CommitResult
112      * \throws Exception
113     */
114     ZYppCommitResult commit( const ZYppCommitPolicy & policy_r );
115
116   public:
117     /** */
118     Resolver_Ptr resolver() const;
119     KeyRing_Ptr keyRing() const;
120   public:
121     /** Set the preferd locale for translated labels, descriptions,
122      *  etc. passed to the UI.
123      */
124     void setTextLocale( const Locale & textLocale_r );
125     /** */
126     Locale getTextLocale() const;
127
128   public:
129     typedef std::set<Locale> LocaleSet;
130     /** Set the requested locales.
131      * Languages to be supported by the system, e.g. language specific
132      * packages to be installed. This function operates on the pool,
133      * so only the locales that are available as resolvables
134      * are marked as requested. The rest is ignored.
135     */
136     void setRequestedLocales( const LocaleSet & locales_r );
137     /** */
138     LocaleSet getRequestedLocales() const;
139
140     /**
141      * Get the set of available locales.
142      * This is computed from the package data so it actually
143      * represents all locales packages claim to support.
144      */
145     LocaleSet getAvailableLocales() const;
146
147     /**
148      * internal use only
149      **/
150     void availableLocale( const Locale & locale_r );
151
152   public:
153     /** Get the path where zypp related plugins store persistent data and caches   */
154     Pathname homePath() const;
155     
156     /** Get the path where zypp related plugins store temp data   */
157     Pathname tmpPath() const;
158     
159     /** set the home, if you need to change it */
160     void setHomePath( const Pathname & path );
161
162     /** Get the system architecture.   */
163     Arch architecture() const;
164     /** Set the system architecture.
165         This should be used for testing/debugging only since the Target backend
166         won't be able to install incompatible packages ;-)   */
167     void setArchitecture( const Arch & arch );
168
169   protected:
170     /** Dtor */
171     virtual ~ZYpp();
172     /** Stream output */
173     virtual std::ostream & dumpOn( std::ostream & str ) const;
174   private:
175     /** Factory */
176     friend class ZYppFactory;
177
178     /** */
179     typedef zypp_detail::ZYppImpl Impl;
180     typedef shared_ptr<Impl>      Impl_Ptr;
181     /** Factory ctor */
182     explicit
183     ZYpp( const Impl_Ptr & impl_r );
184   private:
185     /** Pointer to implementation */
186     RW_pointer<Impl> _pimpl;
187   };
188   ///////////////////////////////////////////////////////////////////
189
190   /////////////////////////////////////////////////////////////////
191 } // namespace zypp
192 ///////////////////////////////////////////////////////////////////
193 #endif // ZYPP_ZYPP_H