Deprecate MediaAccess::downloads (accidentally deleted)
[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 #include "zypp/base/Deprecated.h"
21
22 #include "zypp/ZConfig.h"
23
24 #include "zypp/ZYppCommit.h"
25 #include "zypp/ResTraits.h"
26
27 #include "zypp/Target.h"
28 #include "zypp/Resolver.h"
29 #include "zypp/KeyRing.h"
30 #include "zypp/DiskUsageCounter.h"
31
32 ///////////////////////////////////////////////////////////////////
33 namespace zypp
34 { /////////////////////////////////////////////////////////////////
35
36   namespace zypp_detail
37   {
38     class ZYppImpl;
39   }
40
41   class ZYppFactory;
42   class ResPool;
43   class ResPoolProxy;
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 global resolvable pool.
65      * Same as \ref zypp::ResPool::instance
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     DiskUsageCounter::MountPointSet diskUsage();
76
77     void setPartitions(const DiskUsageCounter::MountPointSet &mp);
78
79     DiskUsageCounter::MountPointSet getPartitions() const;
80
81   public:
82     /**
83      * \throws Exception
84      */
85     Target_Ptr target() const;
86
87     /** Same as \ref target but returns NULL if target is not
88      *  initialized, instead of throwing.
89      */
90     Target_Ptr getTarget() const;
91
92     /**
93      * \throws Exception
94      * Just init the target, dont populate store or pool.
95      * If \c doRebuild_r is \c true, an already existing
96      * database is rebuilt (rpm --rebuilddb ).
97      */
98     void initializeTarget(const Pathname & root, bool doRebuild_r = 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     /** Install a source package on the Target.
117      * \throws Exception
118      */
119     void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
120
121   public:
122     /** */
123     Resolver_Ptr resolver() const;
124     KeyRing_Ptr keyRing() const;
125   public:
126     /** Set the preferred locale for translated labels, descriptions,
127      *  etc. passed to the UI.
128      * \deprecated Use ZConfig diretcly.
129      */
130     ZYPP_DEPRECATED void setTextLocale( const Locale & textLocale_r )
131     { ZConfig::instance().setTextLocale( textLocale_r ); }
132     /** \deprecated Use ZConfig diretcly. */
133     ZYPP_DEPRECATED Locale getTextLocale() const
134     { return ZConfig::instance().textLocale(); }
135
136   public:
137     /** \name move to pool
138      * \deprecated Use ResPool diretcly.
139     */
140     //@{
141     /** Set the requested locales.
142      * Languages to be supported by the system, e.g. language specific
143      * packages to be installed. This function operates on the pool,
144      * so only the locales that are available as resolvables
145      * are marked as requested. The rest is ignored.
146      * \deprecated Use ResPool diretcly.
147     */
148     void setRequestedLocales( const LocaleSet & locales_r ) ZYPP_DEPRECATED;
149
150     /** \deprecated Use ResPool diretcly. */
151     const LocaleSet & getRequestedLocales() const ZYPP_DEPRECATED;
152
153     /**
154      * Get the set of available locales.
155      * This is computed from the package data so it actually
156      * represents all locales packages claim to support.
157      * \deprecated Use ResPool diretcly.
158      */
159     const LocaleSet & getAvailableLocales() const ZYPP_DEPRECATED;
160     //@}
161
162   public:
163     /** Get the path where zypp related plugins store persistent data and caches   */
164     Pathname homePath() const;
165
166     /** Get the path where zypp related plugins store temp data   */
167     Pathname tmpPath() const;
168
169     /** set the home, if you need to change it */
170     void setHomePath( const Pathname & path );
171
172     /** Get the system architecture.
173       * \deprecated Use ZConfig diretcly.
174     */
175     ZYPP_DEPRECATED Arch architecture() const
176     { return ZConfig::instance().systemArchitecture(); }
177     /** Set the system architecture.
178      * This should be used for testing/debugging only since the Target backend
179      * won't be able to install incompatible packages ;-)
180      * \deprecated Use ZConfig diretcly.
181     */
182     ZYPP_DEPRECATED void setArchitecture( const Arch & arch )
183     { ZConfig::instance().setSystemArchitecture( arch ); }
184
185   public:
186
187    /**
188     * \deprecated Persistent locks are automatically maintained, kept in the pool, loaded and saved together with the Target.
189     * \ref ZConfig::apply_locks_file tells whether locks are applied or not.
190     */
191     ZYPP_DEPRECATED int applyLocks()
192     { return 0; }
193
194   protected:
195     /** Dtor */
196     virtual ~ZYpp();
197     /** Stream output */
198     virtual std::ostream & dumpOn( std::ostream & str ) const;
199   private:
200     /** Factory */
201     friend class ZYppFactory;
202
203     /** */
204     typedef zypp_detail::ZYppImpl Impl;
205     typedef shared_ptr<Impl>      Impl_Ptr;
206     /** Factory ctor */
207     explicit
208     ZYpp( const Impl_Ptr & impl_r );
209   private:
210     /** Pointer to implementation */
211     RW_pointer<Impl> _pimpl;
212   };
213   ///////////////////////////////////////////////////////////////////
214
215   /////////////////////////////////////////////////////////////////
216 } // namespace zypp
217 ///////////////////////////////////////////////////////////////////
218 #endif // ZYPP_ZYPP_H