remove some interfaces, cleanup
[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> PoolItemList;
55
56   public:
57
58     /**
59      * load resolvables into the pool
60      */
61     void load();
62
63     /** 
64      * reload the target in future calls if
65      * needed.
66      * note the loading can actually be delayed, but
67      * the next call to resolvables must reflect the 
68      * status of the system.
69     */
70     void reset();
71     
72     /**
73      * load resolvables of certain kind in the internal store
74      * and return a iterator
75      * successive calls will be faster as resolvables are cached-
76      */
77     ResStore::resfilter_const_iterator byKindBegin( const ResObject::Kind & kind_r  ) const;
78     ResStore::resfilter_const_iterator byKindEnd( const ResObject::Kind & kind_r ) const;
79
80     /** Null implementation */
81     static Target_Ptr nullimpl();
82
83     /** Refference to the RPM database */
84     target::rpm::RpmDb & rpmDb();
85
86     /** If the package is installed and provides the file
87      Needed to evaluate split provides during Resolver::Upgrade() */
88     bool providesFile (const std::string & name_str, const std::string & path_str) const;
89
90     ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
91
92     /** Set the log file for target */
93     bool setInstallationLogfile(const Pathname & path_r);
94
95     /** Return the root set for this target */
96     Pathname root() const;
97
98     /** return the last modification date of the target */
99     Date timestamp() const;
100   public:
101     /** Ctor */
102     explicit
103     Target( const Pathname & root = "/" );
104     /** Ctor */
105     explicit
106     Target( const Impl_Ptr & impl_r );
107
108   private:
109     friend std::ostream & operator<<( std::ostream & str, const Target & obj );
110     /** Stream output. */
111     std::ostream & dumpOn( std::ostream & str ) const;
112
113   private:
114     /** Direct access to Impl. */
115     friend class zypp_detail::ZYppImpl;
116
117     /** Pointer to implementation */
118     RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
119
120     static Target_Ptr _nullimpl;
121   };
122   ///////////////////////////////////////////////////////////////////
123
124   /** \relates Target Stream output. */
125   inline std::ostream & operator<<( std::ostream & str, const Target & obj )
126   { return obj.dumpOn( str ); }
127
128
129   /////////////////////////////////////////////////////////////////
130 } // namespace zypp
131 ///////////////////////////////////////////////////////////////////
132 #endif // ZYPP_TARGET_H