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 { /////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////
29 // CLASS NAME : ResPool
31 /** Access to ResObject pool.
33 * \note Filter iterators provided by ResPool are intended to
34 * operate on internal index tables for faster access. If the
35 * the index is not yet implemented, they are realized as
36 * an ordinary filter iterator. Do not provide filter iterators
37 * here, if there is no index table for it.
41 friend std::ostream & operator<<( std::ostream & str, const ResPool & obj );
44 /** \ref zypp::pool::PoolItem */
45 typedef pool::PoolTraits::Item Item;
46 typedef pool::PoolTraits::size_type size_type;
47 typedef pool::PoolTraits::const_iterator const_iterator;
48 typedef pool::PoolTraits::byName_iterator byName_iterator;
49 typedef pool::PoolTraits::byCapabilityIndex_iterator byCapabilityIndex_iterator;
50 typedef pool::PoolTraits::AdditionalCapSet AdditionalCapSet;
51 typedef pool::PoolTraits::repository_iterator repository_iterator;
54 /** Default ctor: empty pool */
60 /** The pools serial number. Changing whenever the
61 * whenever the content changes. (Resolvables or
64 const SerialNumber & serial() const;
66 /** Wheter in sync with sat-pool. */
67 bool satSynced() const;
68 /** Sync with sat-pool. */
75 size_type size() const;
77 /** \name Iterate through all ResObjects (all kinds). */
80 const_iterator begin() const;
82 const_iterator end() const;
86 /** \name Iterate through all ResObjects of a certain kind. */
88 typedef zypp::resfilter::ByKind ByKind;
89 typedef filter_iterator<ByKind,const_iterator> byKind_iterator;
91 byKind_iterator byKindBegin( const ResObject::Kind & kind_r ) const
92 { return make_filter_begin( ByKind(kind_r), *this ); }
95 byKind_iterator byKindBegin() const
96 { return make_filter_begin( resfilter::byKind<_Res>(), *this ); }
99 byKind_iterator byKindEnd( const ResObject::Kind & kind_r ) const
100 { return make_filter_end( ByKind(kind_r), *this ); }
103 byKind_iterator byKindEnd() const
104 { return make_filter_end( resfilter::byKind<_Res>(), *this ); }
108 /** \name Iterate through all ResObjects with a certain name (all kinds). */
110 byName_iterator byNameBegin( const std::string & name_r ) const;
112 byName_iterator byNameEnd( const std::string & name_r ) const;
116 /** \name Iterate through all ResObjects which have at least
117 * one Capability with index \a index_r in dependency \a depType_r.
120 byCapabilityIndex_iterator byCapabilityIndexBegin( const std::string & index_r, Dep depType_r ) const;
122 byCapabilityIndex_iterator byCapabilityIndexEnd( const std::string & index_r, Dep depType_r ) const;
126 /** \name Iterate through all Repositories that contribute ResObjects.
129 size_type knownRepositoriesSize() const;
131 repository_iterator knownRepositoriesBegin() const;
133 repository_iterator knownRepositoriesEnd() const;
137 /** \name Handling addition capabilities in the pool in order for solving it in
138 * a solver run. This is used for tasks like needing a package with the name "foo".
139 * The solver has to evaluate a proper package by his own.
141 * CAUTION: This has another semantic in the solver. The required resolvable has
142 * been set for installation (in the pool) only AFTER a solver run.
146 * Handling additional requirement. E.G. need package "foo" and package
147 * "foo1" which has a greater version than 1.0:
151 * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
152 * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo1 > 1.0"));
154 * // The user is setting this capablility
155 * ResPool::AdditionalCapSet aCapSet;
156 * aCapSet[ResStatus::USER] = capset;
158 * setAdditionalRequire( aCapSet );
161 void setAdditionalRequire( const AdditionalCapSet & capset ) const;
162 AdditionalCapSet & additionalRequire() const;
165 * Handling additional conflicts. E.G. do not install anything which provides "foo":
169 * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
171 * // The user is setting this capablility
172 * ResPool::AdditionalCapSet aCapSet;
173 * aCapSet[ResStatus::USER] = capset;
175 * setAdditionalConflict( aCapSet );
178 void setAdditionalConflict( const AdditionalCapSet & capset ) const;
179 AdditionalCapSet & additionaConflict() const;
182 * Handling additional provides. This is used for ignoring a requirement.
183 * e.G. Do ignore the requirement "foo":
187 * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
189 * // The user is setting this capablility
190 * ResPool::AdditionalCapSet aCapSet;
191 * aCapSet[ResStatus::USER] = capset;
193 * setAdditionalProvide( aCapSet );
196 void setAdditionalProvide( const AdditionalCapSet & capset ) const;
197 AdditionalCapSet & additionaProvide() const;
201 friend class ResPoolManager;
203 ResPool( pool::PoolTraits::Impl_constPtr impl_r );
205 /** Const access to implementation. */
206 pool::PoolTraits::Impl_constPtr _pimpl;
208 ///////////////////////////////////////////////////////////////////
210 /** \todo rename class and eliminate typedef. */
211 typedef ResPool ResPool_Ref;
213 ///////////////////////////////////////////////////////////////////
215 /** \relates ResPool Stream output */
216 std::ostream & operator<<( std::ostream & str, const ResPool & obj );
218 /////////////////////////////////////////////////////////////////
220 ///////////////////////////////////////////////////////////////////
221 #endif // ZYPP_RESPOOL_H