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