added new fuction zypp::ZYpp::provideSrcPackage
[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/APIConfig.h"
21
22 #include "zypp/ZConfig.h"
23 #include "zypp/ManagedFile.h"
24
25 #include "zypp/ZYppCommit.h"
26 #include "zypp/ResTraits.h"
27
28 #include "zypp/Target.h"
29 #include "zypp/Resolver.h"
30 #include "zypp/KeyRing.h"
31 #include "zypp/DiskUsageCounter.h"
32
33 ///////////////////////////////////////////////////////////////////
34 namespace zypp
35 { /////////////////////////////////////////////////////////////////
36
37   namespace zypp_detail
38   {
39     class ZYppImpl;
40   }
41
42   class ZYppFactory;
43   class ResPool;
44   class ResPoolProxy;
45   class KeyRing;
46
47   ///////////////////////////////////////////////////////////////////
48   //
49   //    CLASS NAME : ZYpp
50   //
51   /**
52    * \todo define Exceptions
53    * ZYpp API main interface
54    */
55   class ZYpp : public base::ReferenceCounted, private base::NonCopyable
56   {
57   public:
58
59     typedef intrusive_ptr<ZYpp>       Ptr;
60     typedef intrusive_ptr<const ZYpp> constPtr;
61
62   public:
63
64     /**
65      * Access to the global resolvable pool.
66      * Same as \ref zypp::ResPool::instance
67      */
68     ResPool pool() const;
69
70     /** Pool of ui::Selectable.
71      * Based on the ResPool, ui::Selectable groups ResObjetcs of
72      * same kind and name.
73     */
74     ResPoolProxy poolProxy() const;
75
76     DiskUsageCounter::MountPointSet diskUsage();
77
78     void setPartitions(const DiskUsageCounter::MountPointSet &mp);
79
80     DiskUsageCounter::MountPointSet getPartitions() const;
81
82   public:
83     /**
84      * \throws Exception
85      */
86     Target_Ptr target() const;
87
88     /** Same as \ref target but returns NULL if target is not
89      *  initialized, instead of throwing.
90      */
91     Target_Ptr getTarget() const;
92
93     /**
94      * \throws Exception
95      * Just init the target, dont populate store or pool.
96      * If \c doRebuild_r is \c true, an already existing
97      * database is rebuilt (rpm --rebuilddb ).
98      */
99     void initializeTarget(const Pathname & root, bool doRebuild_r = false);
100
101     /**
102      * \throws Exception
103      */
104     void finishTarget();
105
106
107   public:
108     typedef ZYppCommitResult CommitResult;
109
110     /** Commit changes and transactions.
111      * \param \ref CommitPolicy
112      * \return \ref CommitResult
113      * \throws Exception
114     */
115     ZYppCommitResult commit( const ZYppCommitPolicy & policy_r );
116
117     /** Install a source package on the Target.
118      * \throws Exception
119      */
120     void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
121
122     /** Provides a source package on the Target.
123      * \throws Exception
124      */
125     ManagedFile provideSrcPackage( const SrcPackage_constPtr & srcPackage_r );
126
127   public:
128     /** */
129     Resolver_Ptr resolver() const;
130     KeyRing_Ptr keyRing() const;
131   public:
132     /** Set the preferred locale for translated labels, descriptions,
133      *  etc. passed to the UI.
134      * \deprecated Use ZConfig diretcly.
135      */
136     ZYPP_DEPRECATED void setTextLocale( const Locale & textLocale_r )
137     { ZConfig::instance().setTextLocale( textLocale_r ); }
138     /** \deprecated Use ZConfig diretcly. */
139     ZYPP_DEPRECATED Locale getTextLocale() const
140     { return ZConfig::instance().textLocale(); }
141
142   public:
143     /** \name move to pool
144      * \deprecated Use ResPool diretcly.
145     */
146     //@{
147     /** Set the requested locales.
148      * Languages to be supported by the system, e.g. language specific
149      * packages to be installed. This function operates on the pool,
150      * so only the locales that are available as resolvables
151      * are marked as requested. The rest is ignored.
152      * \deprecated Use ResPool diretcly.
153     */
154     void setRequestedLocales( const LocaleSet & locales_r ) ZYPP_DEPRECATED;
155
156     /** \deprecated Use ResPool diretcly. */
157     const LocaleSet & getRequestedLocales() const ZYPP_DEPRECATED;
158
159     /**
160      * Get the set of available locales.
161      * This is computed from the package data so it actually
162      * represents all locales packages claim to support.
163      * \deprecated Use ResPool diretcly.
164      */
165     const LocaleSet & getAvailableLocales() const ZYPP_DEPRECATED;
166     //@}
167
168   public:
169     /** Get the path where zypp related plugins store persistent data and caches   */
170     Pathname homePath() const;
171
172     /** Get the path where zypp related plugins store temp data   */
173     Pathname tmpPath() const;
174
175     /** set the home, if you need to change it */
176     void setHomePath( const Pathname & path );
177
178     /** Get the system architecture.
179       * \deprecated Use ZConfig diretcly.
180     */
181     ZYPP_DEPRECATED Arch architecture() const
182     { return ZConfig::instance().systemArchitecture(); }
183     /** Set the system architecture.
184      * This should be used for testing/debugging only since the Target backend
185      * won't be able to install incompatible packages ;-)
186      * \deprecated Use ZConfig diretcly.
187     */
188     ZYPP_DEPRECATED void setArchitecture( const Arch & arch )
189     { ZConfig::instance().setSystemArchitecture( arch ); }
190
191   public:
192
193    /**
194     * \deprecated Persistent locks are automatically maintained, kept in the pool, loaded and saved together with the Target.
195     * \ref ZConfig::apply_locks_file tells whether locks are applied or not.
196     */
197     ZYPP_DEPRECATED int applyLocks()
198     { return 0; }
199
200   protected:
201     /** Dtor */
202     virtual ~ZYpp();
203     /** Stream output */
204     virtual std::ostream & dumpOn( std::ostream & str ) const;
205   private:
206     /** Factory */
207     friend class ZYppFactory;
208
209     /** */
210     typedef zypp_detail::ZYppImpl Impl;
211     typedef shared_ptr<Impl>      Impl_Ptr;
212     /** Factory ctor */
213     explicit
214     ZYpp( const Impl_Ptr & impl_r );
215   private:
216     /** Pointer to implementation */
217     RW_pointer<Impl> _pimpl;
218   };
219   ///////////////////////////////////////////////////////////////////
220
221   /////////////////////////////////////////////////////////////////
222 } // namespace zypp
223 ///////////////////////////////////////////////////////////////////
224 #endif // ZYPP_ZYPP_H