1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/NameKindProxy.cc
13 //#include "zypp/base/Logger.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 std::string & name_r, Resolvable::Kind kind_r )
59 for ( ResPool::byName_iterator it = pool_r.byNameBegin( _name );
60 it != pool_r.byNameEnd( _name ); ++it )
62 if ( (*it)->kind() == _kind )
64 if ( it->status().isInstalled() )
65 _installed.insert( *it ) ;
67 _available.insert( *it );
72 /******************************************************************
74 ** FUNCTION NAME : operator<<
75 ** FUNCTION TYPE : std::ostream &
77 std::ostream & operator<<( std::ostream & str, const NameKindProxy & obj )
79 str << "[" << obj.kind() << "] " << obj.name()
80 << " {" << obj.installedSize() << "/" << obj.availableSize() << "}" << endl;
81 std::for_each( obj.installedBegin(), obj.installedEnd(), PrintOn<PoolItem>(str," ") );
82 std::for_each( obj.availableBegin(), obj.availableEnd(), PrintOn<PoolItem>(str," ") );
86 /////////////////////////////////////////////////////////////////
88 ///////////////////////////////////////////////////////////////////