00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: InstSrcDescr.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: Installation source description 00019 Keeps all information to identify and describe an installation 00020 source, but does not have knowledge about its contents (i.e the 00021 packages, selectins, etc ). See InstSrcData for the contents. 00022 00023 /-*/ 00024 #ifndef InstSrcDescr_h 00025 #define InstSrcDescr_h 00026 00027 #include <iosfwd> 00028 00029 #include <list> 00030 #include <string> 00031 00032 #include <y2util/Url.h> 00033 #include <y2util/Vendor.h> 00034 #include <y2util/Pathname.h> 00035 #include <y2util/LangCode.h> 00036 00037 #include <y2pm/InstSrcDescrPtr.h> 00038 #include <y2pm/F_Media.h> 00039 00040 #include <y2pm/InstSrc.h> 00041 #include <y2pm/ProductIdent.h> 00042 #include <y2pm/PkgRelation.h> 00043 #include <y2pm/PkgArch.h> 00044 00046 // 00047 // CLASS NAME : InstSrcDescr 00057 class InstSrcDescr : public CountedRep { 00058 REP_BODY(InstSrcDescr); 00059 00060 public: 00061 00065 typedef InstSrcError Error; 00066 00067 typedef std::map<std::string,std::list<PkgArch> > ArchMap; 00068 typedef std::map<LangCode,std::string> LabelMap; 00069 typedef std::list<LangCode> LinguasList; 00070 00071 static const unsigned NO_RANK = unsigned(-1); 00072 00073 public: 00074 00075 InstSrcDescr(); 00076 00077 virtual ~InstSrcDescr(); 00078 00079 private: 00080 00082 // Basic data NOT TO BE STORED IN CACHE (e.g. InstTaget/UI related) 00084 00088 static const Pathname _cache_file; 00089 00090 private: 00091 00093 // CACHE DATA start here 00095 00097 // InstSrc related/provided data. Can not be retrieved from media. 00099 00103 InstSrc::Type _type; 00104 00108 Url _url; 00109 00113 Pathname _product_dir; 00114 00116 // InstSrcManager related/provided data. Can not be retrieved from media. 00118 00122 bool _default_activate; 00123 00127 unsigned _default_rank; 00128 00130 // media file ( _url / media.N / media ) 00132 00133 Vendor _media_vendor; // media vendor 00134 std::string _media_id; // ID code for media match 00135 unsigned _media_count; // total number if is split up on multiple media 00136 bool _media_doublesided; // true if doublesided media 00137 F_Media::LabelMap _media_labels; // media names to use in UI 00138 00140 // content file ( _url / _product_dir / content ) 00142 00143 ProductIdent _content_product; 00144 PkgNameEd _content_distproduct; 00145 ProductIdent _content_baseproduct; 00146 Vendor _content_vendor; 00147 00148 std::string _content_defaultbase; 00149 ArchMap _content_archmap; 00150 00151 PkgRelation _content_requires; 00152 00153 LangCode _content_language; 00154 LinguasList _content_linguas; 00155 std::string _content_label; 00156 LabelMap _content_labelmap; 00157 00158 std::string _content_timezone; 00159 00163 Pathname _content_descrdir; 00164 00168 Pathname _content_datadir; 00169 00170 std::string _content_flags; 00171 00172 std::string _content_relnotesurl; 00173 00174 std::string _content_youurl; 00175 std::string _content_youtype; 00176 std::string _content_youpath; 00177 00178 public: 00179 00181 // access functions 00183 00184 InstSrc::Type type() const { return _type; } 00185 const Url & url() const { return _url; } 00186 const Pathname & product_dir() const { return _product_dir; } 00187 00188 bool default_activate() const { return _default_activate; } 00189 unsigned default_rank() const { return _default_rank; } 00190 00191 const Vendor & media_vendor() const { return _media_vendor; } 00192 const std::string & media_id() const { return _media_id; } 00193 const unsigned & media_count() const { return _media_count; } 00194 bool media_doublesided() const { return _media_doublesided; } 00195 const PM::LocaleString & media_label( unsigned number_r ) const { 00196 F_Media::LabelMap::const_iterator found( _media_labels.find( number_r ) ); 00197 return( found == _media_labels.end() ? F_Media::_noLabel : found->second ); 00198 } 00199 const ProductIdent & content_product() const { return _content_product; } 00200 const PkgNameEd & content_distproduct() const { return _content_distproduct; } 00201 const ProductIdent & content_baseproduct() const { return _content_baseproduct; } 00202 const Vendor & content_vendor() const { return _content_vendor; } 00203 const std::string & content_defaultbase() const { return _content_defaultbase; } 00204 const ArchMap & content_archmap() const { return _content_archmap; } 00205 const PkgRelation & content_requires() const { return _content_requires; } 00206 const LangCode & content_language() const { return _content_language; } 00207 const LinguasList & content_linguas() const { return _content_linguas; } 00208 const std::string & content_label() const { return _content_label; } 00209 const LabelMap & content_labelmap() const { return _content_labelmap; } 00210 const std::string & content_timezone() const { return _content_timezone; } 00211 const Pathname & content_descrdir() const { return _content_descrdir; } 00212 const Pathname & content_datadir() const { return _content_datadir; } 00213 const std::string & content_flags() const { return _content_flags; } 00214 const std::string & content_relnotesurl() const { return _content_relnotesurl; } 00215 const std::string & content_youurl() const { return _content_youurl; } 00216 const std::string & content_youtype() const { return _content_youtype; } 00217 const std::string & content_youpath() const { return _content_youpath; } 00218 00220 // convenience functions 00222 00226 Pathname descrdir() const { return _product_dir + _content_descrdir; } 00227 00231 Pathname datadir() const { return _product_dir + _content_datadir; } 00232 00236 std::string label() const; 00237 00238 public: 00239 00241 // set value functions 00243 00244 void set_type( InstSrc::Type val_r ) { _type = val_r; } 00245 void set_url( const Url & val_r ) { _url = val_r; } 00246 void set_product_dir( const Pathname & val_r ) { _product_dir = val_r; } 00247 00248 void set_default_activate( bool val_r ) { _default_activate = val_r; } 00249 void set_default_rank( unsigned val_r ) { _default_rank = val_r; } 00250 00251 void set_media_vendor( const Vendor & val_r ) { _media_vendor = val_r; } 00252 void set_media_id( const std::string & val_r ) { _media_id = val_r; } 00253 void set_media_count( unsigned val_r ) { _media_count = val_r; } 00254 void set_media_doublesided( bool val_r ) { _media_doublesided = val_r; } 00255 void set_media_labels( const F_Media::LabelMap & val_r ) { _media_labels = val_r; } 00256 00257 void set_content_product( const ProductIdent & val_r ) { _content_product = val_r; } 00258 void set_content_distproduct( const PkgNameEd & val_r ) { _content_distproduct = val_r; } 00259 void set_content_baseproduct( const ProductIdent & val_r ){ _content_baseproduct = val_r; } 00260 void set_content_vendor( const Vendor & val_r ) { _content_vendor = val_r; } 00261 void set_content_defaultbase( const std::string & val_r ) { _content_defaultbase = val_r; } 00262 void set_content_archmap( const ArchMap & val_r ) { _content_archmap = val_r; } 00263 void set_content_requires( const PkgRelation & val_r ) { _content_requires = val_r; } 00264 void set_content_language(const LangCode & val_r ) { _content_language = val_r; } 00265 void set_content_linguas( const LinguasList & val_r ) { _content_linguas = val_r; } 00266 void set_content_label( const std::string & val_r ) { _content_label = val_r; } 00267 void set_content_labelmap( const LabelMap & val_r ) { _content_labelmap = val_r; } 00268 void set_content_timezone( const std::string & val_r ) { _content_timezone = val_r; } 00269 void set_content_descrdir( const Pathname & val_r ) { _content_descrdir = val_r; } 00270 void set_content_datadir( const Pathname & val_r ) { _content_datadir = val_r; } 00271 void set_content_flags( const std::string & val_r ) { _content_flags = val_r; } 00272 void set_content_relnotesurl( const std::string & val_r ) { _content_relnotesurl = val_r; } 00273 void set_content_youurl( const std::string & val_r ) { _content_youurl = val_r; } 00274 void set_content_youtype( const std::string & val_r ) { _content_youtype = val_r; } 00275 void set_content_youpath( const std::string & val_r ) { _content_youpath = val_r; } 00276 00277 public: 00278 00282 bool isBaseProduct() const { return _content_baseproduct.undefined(); } 00283 00288 bool hasBaseProduct( const constInstSrcDescrPtr & base_r ) const { 00289 if ( base_r ) { 00290 return _content_baseproduct.sameProduct( base_r->content_product() ); 00291 } 00292 return isBaseProduct(); 00293 } 00294 00298 static bool sameContentProduct( const constInstSrcDescrPtr & rhs, const constInstSrcDescrPtr & lhs ); 00299 00300 public: 00301 00302 virtual std::ostream & dumpOn( std::ostream & str ) const; 00303 00304 public: 00305 00309 static PMError readCache( InstSrcDescrPtr & ndescr_r, const Pathname & cache_dir_r ); 00310 00314 PMError writeCache( const Pathname & cache_dir_r ) const; 00315 00316 public: 00317 00321 static PMError readStream( InstSrcDescrPtr & ndescr_r, std::istream & str ); 00322 00326 PMError writeStream( std::ostream & str ) const; 00327 }; 00328 00330 00331 #endif // InstSrcDescr_h 00332