14 #define INCLUDE_TESTSETUP_WITHOUT_BOOST
15 #include "zypp/../tests/lib/TestSetup.h"
16 #undef INCLUDE_TESTSETUP_WITHOUT_BOOST
18 #include <zypp/base/Easy.h>
19 #include <zypp/base/Counter.h>
20 #include <zypp/base/Measure.h>
22 #include <zypp/PathInfo.h>
23 #include <zypp/Date.h>
24 #include <zypp/ResObject.h>
25 #include <zypp/pool/PoolStats.h>
27 #include "zypp/ZYppFactory.h"
28 #include "zypp/ResPool.h"
29 #include "zypp/ResPoolProxy.h"
30 #include "zypp/ui/Selectable.h"
31 #include <zypp/Repository.h>
32 #include <zypp/RepoManager.h>
36 using zypp::debug::Measure;
39 ///////////////////////////////////////////////////////////////////
41 #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 )
43 ///////////////////////////////////////////////////////////////////
47 { INT << __PRETTY_FUNCTION__ << endl; }
50 { INT << __PRETTY_FUNCTION__ << endl; }
55 USR << "WAITING FOR INPUT!" << endl;
59 ///////////////////////////////////////////////////////////////////
61 void mksrc( const std::string & url, const std::string & alias, RepoManager & repoManager )
64 nrepo.setAlias( alias );
65 nrepo.setName( alias );
66 nrepo.setEnabled( true );
67 nrepo.setAutorefresh( false );
68 nrepo.addBaseUrl( Url(url) );
70 if ( ! repoManager.isCached( nrepo ) )
72 repoManager.buildCache( nrepo );
75 repoManager.loadFromCache( nrepo );
78 ///////////////////////////////////////////////////////////////////
80 template<class _Condition>
83 SetTrue( _Condition cond_r )
88 bool operator()( _Tp t ) const
97 template<class _Condition>
98 inline SetTrue<_Condition> setTrue_c( _Condition cond_r )
100 return SetTrue<_Condition>( cond_r );
105 void operator()( const PoolItem & pi ) const
106 { USR << pi << endl; }
109 template <class _Iterator>
110 std::ostream & vdumpPoolStats( std::ostream & str,
111 _Iterator begin_r, _Iterator end_r )
113 pool::PoolStats stats;
114 std::for_each( begin_r, end_r,
116 functor::chain( setTrue_c(PrintPoolItem()),
117 setTrue_c(functor::functorRef<void,ResObject::constPtr>(stats)) )
123 ///////////////////////////////////////////////////////////////////
126 typedef zypp::pool::PoolStats Rstats;
128 template<class _Iterator>
129 void rstats( _Iterator begin, _Iterator end )
131 DBG << __PRETTY_FUNCTION__ << endl;
133 for_each( begin, end, functor::functorRef<void,ResObject::constPtr>(stats) );
134 MIL << stats << endl;
137 template<class _Container>
138 void rstats( const _Container & c )
140 rstats( c.begin(), c.end() );
143 ///////////////////////////////////////////////////////////////////
145 inline RepoManager makeRepoManager( const Pathname & mgrdir_r )
148 return RepoManager();
151 ///////////////////////////////////////////////////////////////////
154 ui::Selectable::Ptr getSel( const std::string & name_r )
156 ResPoolProxy uipool( getZYpp()->poolProxy() );
157 for_(it, uipool.byKindBegin<_Res>(), uipool.byKindEnd<_Res>() )
159 if ( (*it)->name() == name_r )
168 PoolItem getPi( const std::string & alias_r, const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
171 ResPool pool( getZYpp()->pool() );
172 for_(it, pool.byIdentBegin<_Res>(name_r), pool.byIdentEnd<_Res>(name_r) )
174 if ( ( ed_r.empty() || ed_r.match((*it)->edition()) == 0 )
175 && ( arch_r.empty() || arch_r == (*it)->arch() )
176 && ( alias_r.empty() || alias_r == (*it)->repository().alias() ) )
178 if ( !ret || ret->repository().alias() == sat::Pool::systemRepoAlias() )
181 MIL << " ->" << *it << endl;
185 DBG << " - " << *it << endl;
190 DBG << " ?" << *it << endl;
196 PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
198 return getPi<_Res>( "", name_r, ed_r, arch_r );
201 PoolItem getPi( const std::string & name_r )
203 return getPi<_Res>( name_r, Edition(), Arch_empty );
206 PoolItem getPi( const std::string & name_r, const Edition & ed_r )
208 return getPi<_Res>( name_r, ed_r, Arch_empty );
211 PoolItem getPi( const std::string & name_r, const Arch & arch_r )
213 return getPi<_Res>( name_r, Edition(), arch_r );
216 ///////////////////////////////////////////////////////////////////