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 bool _default_refresh; 00128 00132 unsigned _default_rank; 00133 00137 bool _usefordeltas; 00138 00140 // media file ( _url / media.N / media ) 00142 00143 Vendor _media_vendor; // media vendor 00144 std::string _media_id; // ID code for media match 00145 unsigned _media_count; // total number if is split up on multiple media 00146 bool _media_doublesided; // true if doublesided media 00147 F_Media::LabelMap _media_labels; // media names to use in UI 00148 00150 // content file ( _url / _product_dir / content ) 00152 00153 ProductIdent _content_product; 00154 PkgNameEd _content_distproduct; 00155 ProductIdent _content_baseproduct; 00156 Vendor _content_vendor; 00157 00158 std::string _content_defaultbase; 00159 ArchMap _content_archmap; 00160 00161 PkgRelation _content_requires; 00162 00163 LangCode _content_language; 00164 LinguasList _content_linguas; 00165 std::string _content_label; 00166 LabelMap _content_labelmap; 00167 00168 std::string _content_timezone; 00169 00173 Pathname _content_descrdir; 00174 00178 Pathname _content_datadir; 00179 00180 std::string _content_flags; 00181 00182 std::string _content_relnotesurl; 00183 00184 std::string _content_youurl; 00185 std::string _content_youtype; 00186 std::string _content_youpath; 00187 00188 public: 00189 00191 // access functions 00193 00194 InstSrc::Type type() const { return _type; } 00195 const Url & url() const { return _url; } 00196 const Pathname & product_dir() const { return _product_dir; } 00197 00198 bool default_activate() const { return _default_activate; } 00199 bool default_refresh() const { return _default_refresh; } 00200 unsigned default_rank() const { return _default_rank; } 00201 bool usefordeltas() const { return _usefordeltas; } 00202 00203 const Vendor & media_vendor() const { return _media_vendor; } 00204 const std::string & media_id() const { return _media_id; } 00205 const unsigned & media_count() const { return _media_count; } 00206 bool media_doublesided() const { return _media_doublesided; } 00207 const PM::LocaleString & media_label( unsigned number_r ) const { 00208 F_Media::LabelMap::const_iterator found( _media_labels.find( number_r ) ); 00209 return( found == _media_labels.end() ? F_Media::_noLabel : found->second ); 00210 } 00211 const ProductIdent & content_product() const { return _content_product; } 00212 const PkgNameEd & content_distproduct() const { return _content_distproduct; } 00213 const ProductIdent & content_baseproduct() const { return _content_baseproduct; } 00214 const Vendor & content_vendor() const { return _content_vendor; } 00215 const std::string & content_defaultbase() const { return _content_defaultbase; } 00216 const ArchMap & content_archmap() const { return _content_archmap; } 00217 const PkgRelation & content_requires() const { return _content_requires; } 00218 const LangCode & content_language() const { return _content_language; } 00219 const LinguasList & content_linguas() const { return _content_linguas; } 00220 const std::string & content_label() const { return _content_label; } 00221 const LabelMap & content_labelmap() const { return _content_labelmap; } 00222 const std::string & content_timezone() const { return _content_timezone; } 00223 const Pathname & content_descrdir() const { return _content_descrdir; } 00224 const Pathname & content_datadir() const { return _content_datadir; } 00225 const std::string & content_flags() const { return _content_flags; } 00226 const std::string content_relnotesurl() const; 00227 const std::string & content_youurl() const { return _content_youurl; } 00228 const std::string & content_youtype() const { return _content_youtype; } 00229 const std::string & content_youpath() const { return _content_youpath; } 00230 00232 // convenience functions 00234 00238 Pathname descrdir() const { return _product_dir + _content_descrdir; } 00239 00243 Pathname datadir() const { return _product_dir + _content_datadir; } 00244 00248 std::string label() const; 00249 00253 bool hasFlag( const std::string & flag_r ) const; 00254 00255 public: 00256 00258 // set value functions 00260 00261 void set_type( InstSrc::Type val_r ) { _type = val_r; } 00262 void set_url( const Url & val_r ) { _url = val_r; } 00263 void set_product_dir( const Pathname & val_r ) { _product_dir = val_r; } 00264 00265 void set_default_activate( bool val_r ) { _default_activate = val_r; } 00266 void set_default_refresh( bool val_r ) { _default_refresh = val_r; } 00267 void set_default_rank( unsigned val_r ) { _default_rank = val_r; } 00268 void set_usefordeltas( bool val_r ) { _usefordeltas = val_r; } 00269 00270 void set_media_vendor( const Vendor & val_r ) { _media_vendor = val_r; } 00271 void set_media_id( const std::string & val_r ) { _media_id = val_r; } 00272 void set_media_count( unsigned val_r ) { _media_count = val_r; } 00273 void set_media_doublesided( bool val_r ) { _media_doublesided = val_r; } 00274 void set_media_labels( const F_Media::LabelMap & val_r ) { _media_labels = val_r; } 00275 00276 void set_content_product( const ProductIdent & val_r ) { _content_product = val_r; } 00277 void set_content_distproduct( const PkgNameEd & val_r ) { _content_distproduct = val_r; } 00278 void set_content_baseproduct( const ProductIdent & val_r ){ _content_baseproduct = val_r; } 00279 void set_content_vendor( const Vendor & val_r ) { _content_vendor = val_r; } 00280 void set_content_defaultbase( const std::string & val_r ) { _content_defaultbase = val_r; } 00281 void set_content_archmap( const ArchMap & val_r ) { _content_archmap = val_r; } 00282 void set_content_requires( const PkgRelation & val_r ) { _content_requires = val_r; } 00283 void set_content_language(const LangCode & val_r ) { _content_language = val_r; } 00284 void set_content_linguas( const LinguasList & val_r ) { _content_linguas = val_r; } 00285 void set_content_label( const std::string & val_r ) { _content_label = val_r; } 00286 void set_content_labelmap( const LabelMap & val_r ) { _content_labelmap = val_r; } 00287 void set_content_timezone( const std::string & val_r ) { _content_timezone = val_r; } 00288 void set_content_descrdir( const Pathname & val_r ) { _content_descrdir = val_r; } 00289 void set_content_datadir( const Pathname & val_r ) { _content_datadir = val_r; } 00290 void set_content_flags( const std::string & val_r ) { _content_flags = val_r; } 00291 void set_content_relnotesurl( const std::string & val_r ) { _content_relnotesurl = val_r; } 00292 void set_content_youurl( const std::string & val_r ) { _content_youurl = val_r; } 00293 void set_content_youtype( const std::string & val_r ) { _content_youtype = val_r; } 00294 void set_content_youpath( const std::string & val_r ) { _content_youpath = val_r; } 00295 00296 public: 00297 00301 bool isBaseProduct() const { return _content_baseproduct.undefined(); } 00302 00307 bool hasBaseProduct( const constInstSrcDescrPtr & base_r ) const { 00308 if ( base_r ) { 00309 return _content_baseproduct.sameProduct( base_r->content_product() ); 00310 } 00311 return isBaseProduct(); 00312 } 00313 00317 static bool sameContentProduct( const constInstSrcDescrPtr & rhs, const constInstSrcDescrPtr & lhs ); 00318 00319 public: 00320 00321 virtual std::ostream & dumpOn( std::ostream & str ) const; 00322 00323 public: 00324 00328 static PMError readCache( InstSrcDescrPtr & ndescr_r, const Pathname & cache_dir_r ); 00329 00333 PMError writeCache( const Pathname & cache_dir_r ) const; 00334 00335 public: 00336 00340 static PMError readStream( InstSrcDescrPtr & ndescr_r, std::istream & str ); 00341 00345 PMError writeStream( std::ostream & str ) const; 00346 }; 00347 00349 00350 #endif // InstSrcDescr_h 00351
1.4.4