- Removed deprecated oldstyle commit methods.
[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     /** If the package is installed and provides the file
68      Needed to evaluate split provides during Resolver::Upgrade() */
69     bool providesFile (const std::string & name_str, const std::string & path_str) const;
70
71     ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
72
73     /** JUST FOR TESTSUITE */
74     /** Sort according to prereqs and media numbers
75      * \todo provide it as standalone algorithm
76     */
77     void getResolvablesToInsDel ( const ResPool pool_r,
78                                   PoolItemList & dellist_r,
79                                   PoolItemList & instlist_r,
80                                   PoolItemList & srclist_r ) const;
81
82 #ifndef STORAGE_DISABLED
83     /** enables the storage target */
84     bool isStorageEnabled() const;
85     void enableStorage(const Pathname &root_r);
86 #endif
87
88     /** Set the log file for target */
89     bool setInstallationLogfile(const Pathname & path_r);
90
91     /** Return the root set for this target */
92     Pathname root() const;
93
94   public:
95     /** Ctor */
96     explicit
97     Target( const Pathname & root = "/" );
98     /** Ctor */
99     explicit
100     Target( const Impl_Ptr & impl_r );
101
102   private:
103     friend std::ostream & operator<<( std::ostream & str, const Target & obj );
104     /** Stream output. */
105     std::ostream & dumpOn( std::ostream & str ) const;
106
107   private:
108     /** Direct access to Impl. */
109     friend class zypp_detail::ZYppImpl;
110
111     /** Pointer to implementation */
112     RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
113
114     static Target_Ptr _nullimpl;
115   };
116   ///////////////////////////////////////////////////////////////////
117
118   /** \relates Target Stream output. */
119   inline std::ostream & operator<<( std::ostream & str, const Target & obj )
120   { return obj.dumpOn( str ); }
121
122
123   /////////////////////////////////////////////////////////////////
124 } // namespace zypp
125 ///////////////////////////////////////////////////////////////////
126 #endif // ZYPP_TARGET_H