00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: PMSelectionDataProvider.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: Common interface to be realized by all SelectionDataProvider. 00019 00020 /-*/ 00021 #ifndef PMSelectionDataProvider_h 00022 #define PMSelectionDataProvider_h 00023 00024 #include <iosfwd> 00025 #include <string> 00026 #include <list> 00027 #include <set> 00028 00029 #include <y2util/FSize.h> 00030 #include <y2util/Vendor.h> 00031 #include <y2util/LangCode.h> 00032 #include <y2util/Pathname.h> 00033 00034 #include <y2pm/PMSelectablePtr.h> 00035 00036 #include <y2pm/PMError.h> 00037 #include <y2pm/PMSelectionDataProviderPtr.h> 00038 #include <y2pm/PMSelectionPtr.h> 00039 00041 // 00042 // CLASS NAME : PMSelectionDataProvider 00053 class PMSelectionDataProvider : public CountedRep { 00054 REP_BODY(PMSelectionDataProvider); 00055 00056 public: 00057 00059 // default for unprovided values 00061 00062 // PMObject attributes 00063 static std::string summary ( const LangCode& lang = LangCode("") ) { return std::string(); } 00064 static std::list<std::string> description( const LangCode& lang = LangCode("") ) { return std::list<std::string>(); } 00065 static std::list<std::string> insnotify ( const LangCode& lang = LangCode("") ) { return std::list<std::string>(); } 00066 static std::list<std::string> delnotify ( const LangCode& lang = LangCode("") ) { return std::list<std::string>(); } 00067 static FSize size() { return FSize(0); } 00068 static bool providesSources() { return false; } 00069 static std::string instSrcLabel() { return std::string(); } 00070 static Vendor instSrcVendor() { return Vendor(); } 00071 static unsigned instSrcRank() { return unsigned(-1); } 00072 00073 // PMSelection attributes 00074 static std::string category() { return std::string(); } 00075 static bool visible() { return true; } 00076 static std::list<std::string> suggests() { return std::list<std::string>(); } 00077 static std::list<PMSelectionPtr> suggests_ptrs() { return std::list<PMSelectionPtr>(); } 00078 static std::list<std::string> recommends() { return std::list<std::string>(); } 00079 static std::list<PMSelectionPtr> recommends_ptrs() { return std::list<PMSelectionPtr>(); } 00080 static std::list<std::string> inspacks ( const LangCode& lang = LangCode("") ) { return std::list<std::string>(); } 00081 static std::list<std::string> delpacks ( const LangCode& lang = LangCode("") ) { return std::list<std::string>(); } 00082 00083 // the per locale entry ( no default lang argument! ) 00084 static std::set<PMSelectablePtr> inspacks_ptrs( const LangCode& lang ) { return std::set<PMSelectablePtr>(); } 00085 static std::set<PMSelectablePtr> delpacks_ptrs( const LangCode& lang ) { return std::set<PMSelectablePtr>(); } 00086 00087 static FSize archivesize() { return FSize(0); } 00088 static std::string order() { return "000"; } 00089 00090 static bool isBase() { return false; } 00091 00092 // physical access to the sel file. 00093 static PMError provideSelToInstall( Pathname & path_r ) { path_r = Pathname(); return PMError::E_error; } 00094 00095 protected: 00096 00097 PMSelectionDataProvider(); 00098 00099 virtual ~PMSelectionDataProvider(); 00100 00104 PMSelectionPtr mkPtr( const PMSelection & sel_r ) const { return const_cast<PMSelection*>(&sel_r); } 00105 00106 public: 00107 00109 // Overload values you can provide 00111 00112 // PMObject attributes 00113 virtual std::string summary ( const PMSelection & sel_r, const LangCode& lang = LangCode("") ) const { return summary(); } 00114 virtual std::list<std::string> description ( const PMSelection & sel_r, const LangCode& lang = LangCode("") ) const { return description(); } 00115 virtual std::list<std::string> insnotify ( const PMSelection & sel_r, const LangCode& lang = LangCode("") ) const { return insnotify(); } 00116 virtual std::list<std::string> delnotify ( const PMSelection & sel_r, const LangCode& lang = LangCode("") ) const { return delnotify(); } 00117 virtual FSize size ( const PMSelection & sel_r ) const { return size(); } 00118 virtual bool providesSources( const PMSelection & sel_r ) const { return providesSources(); } 00119 virtual std::string instSrcLabel ( const PMSelection & sel_r ) const { return instSrcLabel(); } 00120 virtual Vendor instSrcVendor ( const PMSelection & sel_r ) const { return instSrcVendor(); } 00121 virtual unsigned instSrcRank ( const PMSelection & sel_r ) const { return instSrcRank(); } 00122 00123 // PMSelection attributes 00124 virtual std::string category ( const PMSelection & sel_r ) const { return category(); } 00125 virtual bool visible ( const PMSelection & sel_r ) const { return visible(); } 00126 virtual std::list<std::string> suggests ( const PMSelection & sel_r ) const { return suggests(); } 00127 virtual std::list<PMSelectionPtr> suggests_ptrs ( const PMSelection & sel_r ) const { return suggests_ptrs(); } 00128 virtual std::list<std::string> recommends ( const PMSelection & sel_r ) const { return recommends(); } 00129 virtual std::list<PMSelectionPtr> recommends_ptrs( const PMSelection & sel_r ) const { return recommends_ptrs(); } 00130 virtual std::list<std::string> inspacks ( const PMSelection & sel_r, const LangCode& lang = LangCode("") ) const { return inspacks(); } 00131 virtual std::list<std::string> delpacks ( const PMSelection & sel_r, const LangCode& lang = LangCode("") ) const { return delpacks(); } 00132 00133 // the per locale entry ( no default lang argument! ) 00134 virtual std::set<PMSelectablePtr> inspacks_ptrs ( const PMSelection & sel_r, const LangCode& lang ) const { return inspacks_ptrs(lang); } 00135 virtual std::set<PMSelectablePtr> delpacks_ptrs ( const PMSelection & sel_r, const LangCode& lang ) const { return delpacks_ptrs(lang); } 00136 00137 virtual FSize archivesize ( const PMSelection & sel_r ) const { return archivesize(); } 00138 virtual std::string order ( const PMSelection & sel_r ) const { return order(); } 00139 00140 virtual bool isBase ( const PMSelection & sel_r ) const { return isBase(); } 00141 00142 // physical access to the sel file. 00143 virtual PMError provideSelToInstall( const PMSelection & sel_r, Pathname & path_r ) const { return provideSelToInstall( path_r ); } 00144 }; 00145 00147 00148 #endif // PMSelectionDataProvider_h 00149