00001
00002
00003
00004
00005
00006
00007
00008
00013 #include <iostream>
00014 #include "zypp/base/LogTools.h"
00015
00016 #include "zypp/ui/PatternContentsImpl.h"
00017 #include "zypp/ui/PatternExpander.h"
00018
00019 #include "zypp/ZYppFactory.h"
00020 #include "zypp/ResPool.h"
00021
00022 using std::endl;
00023
00025 namespace zypp
00026 {
00027
00028 namespace ui
00029 {
00030
00032 namespace
00033 {
00034
00035 struct CollectInstallPackages
00036 {
00037 CollectInstallPackages( std::set<std::string> & result )
00038 : _result( &result )
00039 {}
00040
00041 void operator()( const Pattern::constPtr & pattern )
00042 {
00043 std::set<std::string> s( pattern->install_packages() );
00044 _result->insert( s.begin(), s.end() );
00045 }
00046
00047 std::set<std::string> * _result;
00048 };
00049
00051 }
00053
00054 PatternContents::Impl::Impl( const Pattern::constPtr & pattern )
00055 : _pattern( pattern )
00056 {}
00057
00058 std::set<std::string> PatternContents::Impl::install_packages() const
00059 {
00060 PatternExpander expander( getZYpp()->pool() );
00061
00062 if ( ! expander.expand( _pattern ) )
00063 return std::set<std::string>();
00064
00065 std::set<std::string> result;
00066 for_each( expander.begin(),
00067 expander.end(),
00068 CollectInstallPackages( result ) );
00069 return result;
00070 }
00071
00073 }
00076 }