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