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