46 #include <zypp/ui/Status.h>
47 #include <zypp/ui/Selectable.h>
48 #include <zypp/ResObject.h>
49 #include <zypp/Package.h>
50 #include <zypp/Pattern.h>
51 #include <zypp/Product.h>
53 #include <zypp/Patch.h>
54 #include <zypp/ZYppFactory.h>
55 #include <zypp/ResPoolProxy.h>
56 #include <zypp/PoolQuery.h>
59 using zypp::ui::S_Protected;
60 using zypp::ui::S_Taboo;
61 using zypp::ui::S_Del;
62 using zypp::ui::S_Update;
63 using zypp::ui::S_Install;
64 using zypp::ui::S_AutoDel;
65 using zypp::ui::S_AutoUpdate;
66 using zypp::ui::S_AutoInstall;
67 using zypp::ui::S_KeepInstalled;
68 using zypp::ui::S_NoInst;
75 typedef zypp::ui::Status ZyppStatus;
76 typedef zypp::ui::Selectable::Ptr ZyppSel;
77 typedef zypp::ResObject::constPtr ZyppObj;
78 typedef zypp::Package::constPtr ZyppPkg;
79 typedef zypp::Pattern::constPtr ZyppPattern;
81 typedef zypp::Patch::constPtr ZyppPatch;
82 typedef zypp::Product::constPtr ZyppProduct;
83 typedef zypp::Repository ZyppRepo;
85 typedef zypp::ResPoolProxy ZyppPool;
86 typedef zypp::ResPoolProxy::const_iterator ZyppPoolIterator;
87 typedef zypp::ResPoolProxy::repository_iterator ZyppRepositoryIterator;
90 inline ZyppPool zyppPool() {
return zypp::getZYpp()->poolProxy(); }
92 template<
class T> ZyppPoolIterator zyppBegin() {
return zyppPool().byKindBegin<T>(); }
93 template<
class T> ZyppPoolIterator zyppEnd() {
return zyppPool().byKindEnd<T>(); }
95 inline ZyppPoolIterator zyppPkgBegin() {
return zyppBegin<zypp::Package>(); }
96 inline ZyppPoolIterator zyppPkgEnd() {
return zyppEnd<zypp::Package>(); }
98 inline ZyppPoolIterator zyppPatternsBegin() {
return zyppBegin<zypp::Pattern>(); }
99 inline ZyppPoolIterator zyppPatternsEnd() {
return zyppEnd<zypp::Pattern>(); }
104 inline ZyppPoolIterator zyppPatchesBegin() {
return zyppBegin<zypp::Patch>(); }
105 inline ZyppPoolIterator zyppPatchesEnd() {
return zyppEnd<zypp::Patch>(); }
107 inline ZyppPoolIterator zyppProductsBegin() {
return zyppBegin<zypp::Product>(); }
108 inline ZyppPoolIterator zyppProductsEnd() {
return zyppEnd<zypp::Product>(); }
110 inline ZyppRepositoryIterator ZyppRepositoriesBegin() {
return zyppPool().knownRepositoriesBegin(); }
111 inline ZyppRepositoryIterator ZyppRepositoriesEnd() {
return zyppPool().knownRepositoriesEnd(); }
114 inline ZyppPkg tryCastToZyppPkg( ZyppObj zyppObj )
116 return zypp::dynamic_pointer_cast<
const zypp::Package>( zyppObj );
119 inline ZyppPattern tryCastToZyppPattern( ZyppObj zyppObj )
121 return zypp::dynamic_pointer_cast<
const zypp::Pattern>( zyppObj );
125 inline ZyppLang tryCastToZyppLang( ZyppObj zyppObj )
127 return zypp::dynamic_pointer_cast<
const zypp::Language>( zyppObj );
130 inline ZyppPatch tryCastToZyppPatch( ZyppObj zyppObj )
132 return zypp::dynamic_pointer_cast<
const zypp::Patch>( zyppObj );
135 inline ZyppProduct tryCastToZyppProduct( ZyppObj zyppObj )
137 return zypp::dynamic_pointer_cast<
const zypp::Product>( zyppObj );
140 template<
typename T>
bool inContainer(
const std::set<T> & container, T search )
142 return container.find( search ) != container.end();
146 template<
typename T>
bool bsearch(
const std::vector<T> & sorted_vector, T search )
148 return binary_search( sorted_vector.begin(), sorted_vector.end(), search);
151 inline bool sortByName( ZyppSel ptr1, ZyppSel ptr2 )
153 return( ptr1->name() < ptr2->name() );