1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/NameKindProxy.cc
14 #include "zypp/base/Easy.h"
15 #include "zypp/NameKindProxy.h"
19 ///////////////////////////////////////////////////////////////////
21 { /////////////////////////////////////////////////////////////////
25 /** \todo Move it to base/IOStream.h */
27 struct PrintOn : public std::unary_function<_Tp, bool>
29 bool operator()( const _Tp & obj )
31 _str << _prfx << obj << std::endl;
35 PrintOn( std::ostream & str, const std::string & prfx = std::string() )
44 ///////////////////////////////////////////////////////////////////
46 // CLASS NAME : NameKindProxy
48 ///////////////////////////////////////////////////////////////////
50 ///////////////////////////////////////////////////////////////////
52 // METHOD NAME : NameKindProxy::NameKindProxy
55 NameKindProxy::NameKindProxy( ResPool pool_r, const C_Str & name_r, Resolvable::Kind kind_r )
59 for_( it, pool_r.byIdentBegin( kind_r, _name ), pool_r.byIdentEnd( kind_r, _name ) )
61 if ( it->status().isInstalled() )
62 _installed.insert( *it ) ;
64 _available.insert( *it );
68 NameKindProxy::NameKindProxy( ResPool pool_r, IdString name_r, Resolvable::Kind kind_r )
72 for_( it, pool_r.byIdentBegin( kind_r, _name ), pool_r.byIdentEnd( kind_r, _name ) )
74 if ( it->status().isInstalled() )
75 _installed.insert( *it ) ;
77 _available.insert( *it );
81 /******************************************************************
83 ** FUNCTION NAME : operator<<
84 ** FUNCTION TYPE : std::ostream &
86 std::ostream & operator<<( std::ostream & str, const NameKindProxy & obj )
88 str << "[" << obj.kind() << "] " << obj.name()
89 << " {" << obj.installedSize() << "/" << obj.availableSize() << "}" << endl;
90 std::for_each( obj.installedBegin(), obj.installedEnd(), PrintOn<PoolItem>(str," ") );
91 std::for_each( obj.availableBegin(), obj.availableEnd(), PrintOn<PoolItem>(str," ") );
95 /////////////////////////////////////////////////////////////////
97 ///////////////////////////////////////////////////////////////////