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