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