8 #include <zypp/base/Counter.h>
9 #include <zypp/base/Measure.h>
11 #include <zypp/Date.h>
12 #include <zypp/ResObject.h>
13 #include <zypp/pool/PoolStats.h>
15 #include <zypp/SourceFactory.h>
16 #include <zypp/source/susetags/SuseTagsImpl.h>
19 using zypp::debug::Measure;
22 ///////////////////////////////////////////////////////////////////
25 template<class _Condition>
28 SetTrue( _Condition cond_r )
33 bool operator()( _Tp t ) const
42 template<class _Condition>
43 inline SetTrue<_Condition> setTrue_c( _Condition cond_r )
45 return SetTrue<_Condition>( cond_r );
50 void operator()( const PoolItem & pi ) const
51 { USR << pi << " (" << pi.resolvable().get() << ")" <<endl; }
54 template <class _Iterator>
55 std::ostream & vdumpPoolStats( std::ostream & str,
56 _Iterator begin_r, _Iterator end_r )
58 pool::PoolStats stats;
59 std::for_each( begin_r, end_r,
61 functor::chain( setTrue_c(PrintPoolItem()),
62 setTrue_c(functor::functorRef<void,ResObject::constPtr>(stats)) )
68 ///////////////////////////////////////////////////////////////////
71 typedef zypp::pool::PoolStats Rstats;
73 template<class _Iterator>
74 void rstats( _Iterator begin, _Iterator end )
76 DBG << __PRETTY_FUNCTION__ << endl;
78 for_each( begin, end, functor::functorRef<void,ResObject::constPtr>(stats) );
82 template<class _Container>
83 void rstats( const _Container & c )
85 rstats( c.begin(), c.end() );
88 ///////////////////////////////////////////////////////////////////
89 inline Source_Ref createSource( const Url & url_r, const std::string & alias_r = std::string() )
92 Measure x( "createSource: " + url_r.asString() );
95 std::string alias( alias_r.empty() ? Date::now().asSeconds() : alias_r );
98 ret = SourceFactory().createFrom( url_r, "/", alias );
100 catch ( const source::SourceUnknownTypeException & )
102 ret = SourceFactory().createFrom( "Plaindir", url_r, "/", alias, "", false, true );
105 catch ( const Exception & )
107 return Source_Ref::noSource;
109 x.start( "parseSource: " + url_r.asString() );
111 //zypp::base::LogControl::TmpLineWriter shutUp;
115 MIL << "Content " << ret << "{" << endl;
116 rstats( ret.resolvables() );
121 inline Source_Ref createSource( const std::string & url_r, const std::string & alias_r = std::string() )
125 return createSource( Url(url_r), alias_r );
127 catch ( const Exception & )
129 return Source_Ref::noSource;