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