merge make-it-cool
[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     /** return the last modification date of the target */
95     Date timestamp() const;
96   public:
97     /** Ctor */
98     explicit
99     Target( const Pathname & root = "/" );
100     /** Ctor */
101     explicit
102     Target( const Impl_Ptr & impl_r );
103
104   private:
105     friend std::ostream & operator<<( std::ostream & str, const Target & obj );
106     /** Stream output. */
107     std::ostream & dumpOn( std::ostream & str ) const;
108
109   private:
110     /** Direct access to Impl. */
111     friend class zypp_detail::ZYppImpl;
112
113     /** Pointer to implementation */
114     RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
115
116     static Target_Ptr _nullimpl;
117   };
118   ///////////////////////////////////////////////////////////////////
119
120   /** \relates Target Stream output. */
121   inline std::ostream & operator<<( std::ostream & str, const Target & obj )
122   { return obj.dumpOn( str ); }
123
124
125   /////////////////////////////////////////////////////////////////
126 } // namespace zypp
127 ///////////////////////////////////////////////////////////////////
128 #endif // ZYPP_TARGET_H