9 #include <zypp/ResObject.h>
11 #include <zypp/SourceFactory.h>
12 #include <zypp/source/susetags/SuseTagsImpl.h>
17 ///////////////////////////////////////////////////////////////////
22 Counter() : _value( _IntT(0) ) {}
23 Counter( _IntT value_r ) : _value( _IntT( value_r ) ) {}
24 operator _IntT &() { return _value; }
25 operator const _IntT &() const { return _value; }
30 struct Rstats : public std::unary_function<ResObject::constPtr, void>
32 void operator()( ResObject::constPtr ptr )
35 ++_perKind[ptr->kind()];
38 typedef std::map<ResolvableTraits::KindType,Counter<unsigned> > KindMap;
39 Counter<unsigned> _total;
43 std::ostream & operator<<( std::ostream & str, const Rstats & obj )
45 str << "Total: " << obj._total;
46 for( Rstats::KindMap::const_iterator it = obj._perKind.begin(); it != obj._perKind.end(); ++it )
48 str << endl << " " << it->first << ":\t" << it->second;
53 template<class _Iterator>
54 void rstats( _Iterator begin, _Iterator end )
56 DBG << __PRETTY_FUNCTION__ << endl;
58 for_each( begin, end, functor::functorRef<void,ResObject::constPtr>(stats) );
62 template<class _Container>
63 void rstats( const _Container & c )
65 rstats( c.begin(), c.end() );
68 ///////////////////////////////////////////////////////////////////
69 inline Source_Ref createSource( const Url & url_r )
72 Measure x( "createSource: " + url_r.asString() );
75 ret = SourceFactory().createFrom( url_r );
77 catch ( const Exception & )
79 return Source_Ref::noSource;
81 x.start( "parseSource: " + url_r.asString() );
84 MIL << "Content " << ret << "{" << endl;
85 rstats( ret.resolvables() );
90 inline Source_Ref createSource( const std::string & url_r )
94 return createSource( Url(url_r) );
96 catch ( const Exception & )
98 return Source_Ref::noSource;