fixup Fix to build with libxml 2.12.x (fixes #505)
[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/NonCopyable.h"
18 #include "zypp/base/PtrTypes.h"
19 #include "zypp/APIConfig.h"
20
21 #include "zypp/ZConfig.h"
22 #include "zypp/ManagedFile.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 : private base::NonCopyable
55   {
56     friend std::ostream & operator<<( std::ostream & str, const ZYpp & obj );
57
58   public:
59     // can't get swig working if shared_ptr is without namespace here
60     typedef ::boost::shared_ptr<ZYpp>       Ptr;
61     typedef ::boost::shared_ptr<const ZYpp> constPtr;
62
63   public:
64
65     /**
66      * Access to the global resolvable pool.
67      * Same as \ref zypp::ResPool::instance
68      */
69     ResPool pool() const;
70
71     /** Pool of ui::Selectable.
72      * Based on the ResPool, ui::Selectable groups ResObjetcs of
73      * same kind and name.
74     */
75     ResPoolProxy poolProxy() const;
76
77     DiskUsageCounter::MountPointSet diskUsage();
78
79     void setPartitions(const DiskUsageCounter::MountPointSet &mp);
80
81     DiskUsageCounter::MountPointSet getPartitions() const;
82
83   public:
84     /**
85      * \throws Exception
86      */
87     Target_Ptr target() const;
88
89     /** Same as \ref target but returns NULL if target is not
90      *  initialized, instead of throwing.
91      */
92     Target_Ptr getTarget() const;
93
94     /**
95      * \throws Exception
96      * Just init the target, dont populate store or pool.
97      * If \c doRebuild_r is \c true, an already existing
98      * database is rebuilt (rpm --rebuilddb ).
99      */
100     void initializeTarget(const Pathname & root, bool doRebuild_r = false);
101
102     /**
103      * \throws Exception
104      */
105     void finishTarget();
106
107
108   public:
109     typedef ZYppCommitResult CommitResult;
110
111     /** Commit changes and transactions.
112      * \param \ref CommitPolicy
113      * \return \ref CommitResult
114      * \throws Exception
115     */
116     ZYppCommitResult commit( const ZYppCommitPolicy & policy_r );
117
118     /** Install a source package on the Target.
119      * \throws Exception
120      */
121     void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
122
123     /** Provides a source package on the Target.
124      * \throws Exception
125      */
126     ManagedFile provideSrcPackage( const SrcPackage_constPtr & srcPackage_r );
127
128   public:
129     /** */
130     Resolver_Ptr resolver() const;
131     KeyRing_Ptr keyRing() const;
132
133   public:
134     /** Get the path where zypp related plugins store persistent data and caches   */
135     Pathname homePath() const;
136
137     /** Get the path where zypp related plugins store temp data   */
138     Pathname tmpPath() const;
139
140     /** set the home, if you need to change it */
141     void setHomePath( const Pathname & path );
142
143   private:
144     /** Factory */
145     friend class ZYppFactory;
146     typedef zypp_detail::ZYppImpl Impl;
147     typedef shared_ptr<Impl>      Impl_Ptr;
148     /** Factory ctor */
149     explicit ZYpp( const Impl_Ptr & impl_r );
150   private:
151     /** Deleted via shared_ptr */
152     friend void ::boost::checked_delete<ZYpp>(ZYpp*);   // template<class T> inline void checked_delete(T * x)
153     /** Dtor */
154     ~ZYpp();
155   private:
156     /** Pointer to implementation */
157     RW_pointer<Impl> _pimpl;
158   };
159   ///////////////////////////////////////////////////////////////////
160
161   /////////////////////////////////////////////////////////////////
162 } // namespace zypp
163 ///////////////////////////////////////////////////////////////////
164 #endif // ZYPP_ZYPP_H