1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ResPool.h
12 #ifndef ZYPP_RESPOOL_H
13 #define ZYPP_RESPOOL_H
17 #include "zypp/pool/PoolTraits.h"
18 #include "zypp/base/Iterator.h"
19 #include "zypp/ResFilters.h"
21 ///////////////////////////////////////////////////////////////////
23 { /////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////
27 // CLASS NAME : ResPool
29 /** Access to ResObject pool.
31 * \note Filter iterators provided by ResPool are intended to
32 * operate on internal index tables for faster access. If the
33 * the index is not yet implemented, they are realized as
34 * an ordinary filter iterator. Do not provide filter iterators
35 * here, if there is no index table for it.
39 friend std::ostream & operator<<( std::ostream & str, const ResPool & obj );
42 /** \ref zypp::pool::PoolItem */
43 typedef pool::PoolTraits::Item Item;
44 typedef pool::PoolTraits::size_type size_type;
45 typedef pool::PoolTraits::const_iterator const_iterator;
46 typedef pool::PoolTraits::byName_iterator byName_iterator;
47 typedef pool::PoolTraits::byCapabilityIndex_iterator byCapabilityIndex_iterator;
48 typedef pool::PoolTraits::AdditionalCapSet AdditionalCapSet;
51 /** Default ctor: empty pool */
60 size_type size() const;
64 /** \name Iterate through all ResObjects (all kinds). */
67 const_iterator begin() const;
69 const_iterator end() const;
73 /** \name Iterate through all ResObjects of a certain kind. */
75 typedef resfilter::ByKind ByKind;
76 typedef filter_iterator<ByKind,const_iterator> byKind_iterator;
78 byKind_iterator byKindBegin( const ResObject::Kind & kind_r ) const
79 { return make_filter_begin( ByKind(kind_r), *this ); }
82 byKind_iterator byKindBegin() const
83 { return make_filter_begin( resfilter::byKind<_Res>(), *this ); }
86 byKind_iterator byKindEnd( const ResObject::Kind & kind_r ) const
87 { return make_filter_end( ByKind(kind_r), *this ); }
90 byKind_iterator byKindEnd() const
91 { return make_filter_end( resfilter::byKind<_Res>(), *this ); }
95 /** \name Iterate through all ResObjects with a certain name (all kinds). */
97 byName_iterator byNameBegin( const std::string & name_r ) const;
99 byName_iterator byNameEnd( const std::string & name_r ) const;
103 /** \name Iterate through all ResObjects which have at least
104 * one Capability with index \a index_r in dependency \a depType_r.
107 byCapabilityIndex_iterator byCapabilityIndexBegin( const std::string & index_r, Dep depType_r ) const;
109 byCapabilityIndex_iterator byCapabilityIndexEnd( const std::string & index_r, Dep depType_r ) const;
113 /** \name Handling addition capabilities in the pool in order for solving it in
114 * a solver run. This is used for tasks like needing a package with the name "foo".
115 * The solver has to evaluate a proper package by his own.
117 * CAUTION: This has another semantic in the solver. The required resolvable has
118 * been set for installation (in the pool) only AFTER a solver run.
122 * Handling additional requirement. E.G. need package "foo" and package
123 * "foo1" which has a greater version than 1.0:
127 * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
128 * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo1 > 1.0"));
130 * // The user is setting this capablility
131 * ResPool::AdditionalCapSet aCapSet;
132 * aCapSet[ResStatus::USER] = capset;
134 * setAdditionalRequire( aCapSet );
137 void setAdditionalRequire( const AdditionalCapSet & capset ) const;
138 AdditionalCapSet & additionalRequire() const;
141 * Handling additional conflicts. E.G. do not install anything which provides "foo":
145 * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
147 * // The user is setting this capablility
148 * ResPool::AdditionalCapSet aCapSet;
149 * aCapSet[ResStatus::USER] = capset;
151 * setAdditionalConflict( aCapSet );
154 void setAdditionalConflict( const AdditionalCapSet & capset ) const;
155 AdditionalCapSet & additionaConflict() const;
158 * Handling additional provides. This is used for ignoring a requirement.
159 * e.G. Do ignore the requirement "foo":
163 * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
165 * // The user is setting this capablility
166 * ResPool::AdditionalCapSet aCapSet;
167 * aCapSet[ResStatus::USER] = capset;
169 * setAdditionalProvide( aCapSet );
172 void setAdditionalProvide( const AdditionalCapSet & capset ) const;
173 AdditionalCapSet & additionaProvide() const;
177 friend class ResPoolManager;
179 ResPool( pool::PoolTraits::Impl_constPtr impl_r );
181 /** Const access to implementation. */
182 pool::PoolTraits::Impl_constPtr _pimpl;
184 ///////////////////////////////////////////////////////////////////
186 /** \todo rename class and eliminate typedef. */
187 typedef ResPool ResPool_Ref;
189 ///////////////////////////////////////////////////////////////////
191 /** \relates ResPool Stream output */
192 std::ostream & operator<<( std::ostream & str, const ResPool & obj );
194 /////////////////////////////////////////////////////////////////
196 ///////////////////////////////////////////////////////////////////
197 #endif // ZYPP_RESPOOL_H