- forgotten to remove Target::setInstallationLogfile()
[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      * builds or refreshes the target cache
59      */
60     void buildCache();
61
62     /**
63      * cleans the target cache (.solv files)
64      */
65     void cleanCache();
66
67    /**
68      * load resolvables into the pool
69      */
70     void load();
71
72     /**
73      * unload target resolvables from the
74      * pool
75      */
76     void unload();
77
78     /** \deprecated NOOP
79     */
80     ZYPP_DEPRECATED void reset() {}
81
82     /** Null implementation */
83     static Target_Ptr nullimpl();
84
85     /** Refference to the RPM database */
86     target::rpm::RpmDb & rpmDb();
87
88     /** If the package is installed and provides the file
89      Needed to evaluate split provides during Resolver::Upgrade() */
90     bool providesFile (const std::string & name_str, const std::string & path_str) const;
91
92     /** Return name of package owning \a path_str
93      * or empty string if no installed package owns \a path_str.
94      **/
95     std::string whoOwnsFile (const std::string & path_str) const;
96
97     /** Return the root set for this target */
98     Pathname root() const;
99
100     /** Return the path prefixed by the target root, unless it already is prefixed. */
101     Pathname assertRootPrefix( const Pathname & path_r ) const
102     { return Pathname::assertprefix( root(), path_r ); }
103
104     /** return the last modification date of the target */
105     Date timestamp() const;
106
107     /** \name Base product and registration. */
108     //@{
109     /** The targets distribution release string (/etc/SuSE-release)
110      * \code
111      *   openSUSE 10.3 (i586)
112      * \endcode
113      * \deprecated \ref targetDistribution might be a better choice as it does not depend on /etc/SuSE-release.
114     */
115     std::string release() const ZYPP_DEPRECATED;
116
117     /** This is \c register.target attribute of the installed base product.
118      * Used for registration and \ref Service refresh.
119      */
120     std::string targetDistribution() const;
121
122     /** This is \c register.release attribute of the installed base product.
123      * Used for registration.
124      */
125     std::string targetDistributionRelease() const;
126     //@}
127
128     /**
129      * anonymous unique id
130      *
131      * This id is generated once and stays in the
132      * saved in the target.
133      * It is unique and is used only for statistics.
134      *
135      */
136     std::string anonymousUniqueId() const;
137
138   public:
139     /** Ctor. If \c doRebuild_r is \c true, an already existing
140      * database is rebuilt (rpm --rebuilddb ).
141     */
142     explicit
143     Target( const Pathname & root = "/", bool doRebuild_r = false );
144     /** Ctor */
145     explicit
146     Target( const Impl_Ptr & impl_r );
147
148   private:
149     friend std::ostream & operator<<( std::ostream & str, const Target & obj );
150     /** Stream output. */
151     std::ostream & dumpOn( std::ostream & str ) const;
152
153   private:
154     /** Direct access to Impl. */
155     friend class zypp_detail::ZYppImpl;
156
157     /** Pointer to implementation */
158     RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
159
160     static Target_Ptr _nullimpl;
161   };
162   ///////////////////////////////////////////////////////////////////
163
164   /** \relates Target Stream output. */
165   inline std::ostream & operator<<( std::ostream & str, const Target & obj )
166   { return obj.dumpOn( str ); }
167
168
169   /////////////////////////////////////////////////////////////////
170 } // namespace zypp
171 ///////////////////////////////////////////////////////////////////
172 #endif // ZYPP_TARGET_H