- Added ZYppCommitPolicy for passing policy options to commit. Old style
[platform/upstream/libzypp.git] / zypp / Target.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Target.h
10  *
11 */
12 #ifndef ZYPP_TARGET_H
13 #define ZYPP_TARGET_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/base/Deprecated.h"
21
22 #include "zypp/ResStore.h"
23 #include "zypp/Pathname.h"
24 #include "zypp/ResPool.h"
25
26 ///////////////////////////////////////////////////////////////////
27 namespace zypp
28 { /////////////////////////////////////////////////////////////////
29   namespace target
30   {
31     class TargetImpl;
32     namespace rpm {
33       class RpmDb;
34     }
35   }
36   namespace zypp_detail
37   {
38     class ZYppImpl;
39   }
40
41   DEFINE_PTR_TYPE(Target);
42
43   ///////////////////////////////////////////////////////////////////
44   //
45   //    CLASS NAME : Target
46   //
47   /**
48   */
49   class Target : public base::ReferenceCounted, public base::NonCopyable
50   {
51   public:
52     typedef target::TargetImpl  Impl;
53     typedef intrusive_ptr<Impl> Impl_Ptr;
54     typedef std::list<PoolItem_Ref> PoolItemList;
55
56   public:
57
58     /** All resolvables provided by the target. */
59     const ResStore & resolvables();
60
61     /** Null implementation */
62     static Target_Ptr nullimpl();
63
64     /** Refference to the RPM database */
65     target::rpm::RpmDb & rpmDb();
66
67     /** Commit changes in the pool
68      *  \param medianr 0 = all/any media
69      *                 > 0 means only the given media number
70      * return number of successfully committed resolvables
71      *
72      * \todo Interface to commit should be ZYpp::commit( medianr ). This call
73      * should be removed from the targets public interface, as soon as ZYpp::Impl
74      * is able to call Target::Impl.
75     */
76     int commit( ResPool pool_r, int medianr,
77                 PoolItemList & errors_r,
78                 PoolItemList & remaining_r,
79                 PoolItemList & srcremaining_r,
80                 bool dry_run = false ) ZYPP_DEPRECATED;
81
82     /** If the package is installed and provides the file
83      Needed to evaluate split provides during Resolver::Upgrade() */
84     bool providesFile (const std::string & name_str, const std::string & path_str) const;
85
86     ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
87
88     /** JUST FOR TESTSUITE */
89     /** Sort according to prereqs and media numbers
90      * \todo provide it as standalone algorithm
91     */
92     void getResolvablesToInsDel ( const ResPool pool_r,
93                                   PoolItemList & dellist_r,
94                                   PoolItemList & instlist_r,
95                                   PoolItemList & srclist_r ) const;
96
97 #ifndef STORAGE_DISABLED
98     /** enables the storage target */
99     bool isStorageEnabled() const;
100     void enableStorage(const Pathname &root_r);
101 #endif
102
103     /** Set the log file for target */
104     bool setInstallationLogfile(const Pathname & path_r);
105
106     /** Return the root set for this target */
107     Pathname root() const;
108
109   public:
110     /** Ctor */
111     explicit
112     Target( const Pathname & root = "/" );
113     /** Ctor */
114     explicit
115     Target( const Impl_Ptr & impl_r );
116
117   private:
118     friend std::ostream & operator<<( std::ostream & str, const Target & obj );
119     /** Stream output. */
120     std::ostream & dumpOn( std::ostream & str ) const;
121
122   private:
123     /** Direct access to Impl. */
124     friend class zypp_detail::ZYppImpl;
125
126     /** Pointer to implementation */
127     RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
128
129     static Target_Ptr _nullimpl;
130   };
131   ///////////////////////////////////////////////////////////////////
132
133   /** \relates Target Stream output. */
134   inline std::ostream & operator<<( std::ostream & str, const Target & obj )
135   { return obj.dumpOn( str ); }
136
137
138   /////////////////////////////////////////////////////////////////
139 } // namespace zypp
140 ///////////////////////////////////////////////////////////////////
141 #endif // ZYPP_TARGET_H