fix target not cachedsometimes
[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      * load resolvables into the pool
64      */
65     void load();
66
67     /**
68      * reload the target in future calls if
69      * needed.
70      * note the loading can actually be delayed, but
71      * the next call to resolvables must reflect the
72      * status of the system.
73     */
74     void reset();
75
76     /** Null implementation */
77     static Target_Ptr nullimpl();
78
79     /** Refference to the RPM database */
80     target::rpm::RpmDb & rpmDb();
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     /** Return name of package owning \a path_str
87      * or empty string if no installed package owns \a path_str.
88      **/
89     std::string whoOwnsFile (const std::string & path_str) const;
90
91     /** Set the log file for target */
92     bool setInstallationLogfile(const Pathname & path_r);
93
94     /** Return the root set for this target */
95     Pathname root() const;
96
97     /** return the last modification date of the target */
98     Date timestamp() const;
99   public:
100     /** Ctor */
101     explicit
102     Target( const Pathname & root = "/" );
103     /** Ctor */
104     explicit
105     Target( const Impl_Ptr & impl_r );
106
107   private:
108     friend std::ostream & operator<<( std::ostream & str, const Target & obj );
109     /** Stream output. */
110     std::ostream & dumpOn( std::ostream & str ) const;
111
112   private:
113     /** Direct access to Impl. */
114     friend class zypp_detail::ZYppImpl;
115
116     /** Pointer to implementation */
117     RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
118
119     static Target_Ptr _nullimpl;
120   };
121   ///////////////////////////////////////////////////////////////////
122
123   /** \relates Target Stream output. */
124   inline std::ostream & operator<<( std::ostream & str, const Target & obj )
125   { return obj.dumpOn( str ); }
126
127
128   /////////////////////////////////////////////////////////////////
129 } // namespace zypp
130 ///////////////////////////////////////////////////////////////////
131 #endif // ZYPP_TARGET_H