b52227a523debae7475804e5837b0f013aa27f7c
[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/Pathname.h"
23 #include "zypp/ResPool.h"
24
25 ///////////////////////////////////////////////////////////////////
26 namespace zypp
27 { /////////////////////////////////////////////////////////////////
28   namespace target
29   {
30     class TargetImpl;
31     namespace rpm {
32       class RpmDb;
33     }
34   }
35   namespace zypp_detail
36   {
37     class ZYppImpl;
38   }
39
40   DEFINE_PTR_TYPE(Target);
41
42   ///////////////////////////////////////////////////////////////////
43   //
44   //    CLASS NAME : Target
45   //
46   /**
47   */
48   class Target : public base::ReferenceCounted, public base::NonCopyable
49   {
50   public:
51     typedef target::TargetImpl  Impl;
52     typedef intrusive_ptr<Impl> Impl_Ptr;
53     typedef std::list<PoolItem> PoolItemList;
54
55   public:
56
57     /**
58      * load resolvables into the pool
59      */
60     void load();
61
62     /**
63      * reload the target in future calls if
64      * needed.
65      * note the loading can actually be delayed, but
66      * the next call to resolvables must reflect the
67      * status of the system.
68     */
69     void reset();
70
71     /** Null implementation */
72     static Target_Ptr nullimpl();
73
74     /** Refference to the RPM database */
75     target::rpm::RpmDb & rpmDb();
76
77     /** If the package is installed and provides the file
78      Needed to evaluate split provides during Resolver::Upgrade() */
79     bool providesFile (const std::string & name_str, const std::string & path_str) const;
80
81     /** Return name of package owning \a path_str
82      * or empty string if no installed package owns \a path_str.
83      **/
84     std::string whoOwnsFile (const std::string & path_str) const;
85
86     /** Set the log file for target */
87     bool setInstallationLogfile(const Pathname & path_r);
88
89     /** Return the root set for this target */
90     Pathname root() const;
91
92     /** return the last modification date of the target */
93     Date timestamp() const;
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