11 #define INCLUDE_TESTSETUP_WITHOUT_BOOST
12 #include "zypp/../tests/lib/TestSetup.h"
13 #undef INCLUDE_TESTSETUP_WITHOUT_BOOST
15 #include <zypp/base/Easy.h>
16 #include <zypp/base/Counter.h>
17 #include <zypp/base/Measure.h>
19 #include <zypp/PathInfo.h>
20 #include <zypp/Date.h>
21 #include <zypp/ResObject.h>
22 #include <zypp/pool/PoolStats.h>
24 #include "zypp/ZYppFactory.h"
25 #include "zypp/ResPool.h"
26 #include "zypp/ResPoolProxy.h"
27 #include "zypp/ui/Selectable.h"
28 #include <zypp/Repository.h>
29 #include <zypp/RepoManager.h>
33 using zypp::debug::Measure;
36 ///////////////////////////////////////////////////////////////////
38 #define for_providers_(IT,CAP) for ( sat::WhatProvides::const_iterator IT = sat::WhatProvides( Capability CAP ).begin(), _for_end = sat::WhatProvides().end(); IT != _for_end; ++IT )
40 ///////////////////////////////////////////////////////////////////
44 { INT << __PRETTY_FUNCTION__ << endl; }
47 { INT << __PRETTY_FUNCTION__ << endl; }
52 USR << "WAITING FOR INPUT!" << endl;
56 ///////////////////////////////////////////////////////////////////
58 void mksrc( const std::string & url, const std::string & alias, RepoManager & repoManager )
61 nrepo.setAlias( alias );
62 nrepo.setName( alias );
63 nrepo.setEnabled( true );
64 nrepo.setAutorefresh( false );
65 nrepo.addBaseUrl( Url(url) );
67 if ( ! repoManager.isCached( nrepo ) )
69 repoManager.buildCache( nrepo );
72 repoManager.loadFromCache( nrepo );
75 ///////////////////////////////////////////////////////////////////
77 template<class TCondition>
80 SetTrue( TCondition cond_r )
85 bool operator()( Tp t ) const
94 template<class TCondition>
95 inline SetTrue<TCondition> setTrue_c( TCondition cond_r )
97 return SetTrue<TCondition>( cond_r );
102 void operator()( const PoolItem & pi ) const
103 { USR << pi << endl; }
106 template <class TIterator>
107 std::ostream & vdumpPoolStats( std::ostream & str,
108 TIterator begin_r, TIterator end_r )
110 pool::PoolStats stats;
111 std::for_each( begin_r, end_r,
113 functor::chain( setTrue_c(PrintPoolItem()),
114 setTrue_c(functor::functorRef<void,ResObject::constPtr>(stats)) )
120 ///////////////////////////////////////////////////////////////////
123 typedef zypp::pool::PoolStats Rstats;
125 template<class TIterator>
126 void rstats( TIterator begin, TIterator end )
128 DBG << __PRETTY_FUNCTION__ << endl;
130 for_each( begin, end, functor::functorRef<void,ResObject::constPtr>(stats) );
131 MIL << stats << endl;
134 template<class TContainer>
135 void rstats( const TContainer & c )
137 rstats( c.begin(), c.end() );
140 ///////////////////////////////////////////////////////////////////
142 inline RepoManager makeRepoManager( const Pathname & mgrdir_r )
145 return RepoManager();
148 ///////////////////////////////////////////////////////////////////
151 ui::Selectable::Ptr getSel( const std::string & name_r )
153 ResPoolProxy uipool( getZYpp()->poolProxy() );
154 for_(it, uipool.byKindBegin<TRes>(), uipool.byKindEnd<TRes>() )
156 if ( (*it)->name() == name_r )
165 PoolItem getPi( const std::string & alias_r, const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
168 ResPool pool( getZYpp()->pool() );
169 for_(it, pool.byIdentBegin<TRes>(name_r), pool.byIdentEnd<TRes>(name_r) )
171 if ( ( ed_r.empty() || ed_r.match((*it)->edition()) == 0 )
172 && ( arch_r.empty() || arch_r == (*it)->arch() )
173 && ( alias_r.empty() || alias_r == (*it)->repository().alias() ) )
175 if ( !ret || ret->repository().alias() == sat::Pool::systemRepoAlias() )
178 MIL << " ->" << *it << endl;
182 DBG << " - " << *it << endl;
187 DBG << " ?" << *it << endl;
193 PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
195 return getPi<TRes>( "", name_r, ed_r, arch_r );
198 PoolItem getPi( const std::string & name_r )
200 return getPi<TRes>( name_r, Edition(), Arch_empty );
203 PoolItem getPi( const std::string & name_r, const Edition & ed_r )
205 return getPi<TRes>( name_r, ed_r, Arch_empty );
208 PoolItem getPi( const std::string & name_r, const Arch & arch_r )
210 return getPi<TRes>( name_r, Edition(), arch_r );
213 ///////////////////////////////////////////////////////////////////