00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE Linux AG | 00011 \----------------------------------------------------------------------/ 00012 00013 File: ProductIdent.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: 00019 00020 /-*/ 00021 #ifndef ProductIdent_h 00022 #define ProductIdent_h 00023 00024 #include <iosfwd> 00025 00026 #include <y2pm/PkgName.h> 00027 00029 // 00030 // CLASS NAME : ProductIdent 00051 class ProductIdent { 00052 00053 friend std::ostream & operator<<( std::ostream & str, const ProductIdent & obj ); 00054 00055 private: 00056 00057 PkgNameEd _product; 00058 00059 void _initCheck(); 00060 00061 public: 00062 00063 ProductIdent(); 00064 ProductIdent( const PkgNameEd & rhs ); 00065 ProductIdent( const PkgName & n, const PkgEdition & e ); 00066 00067 ~ProductIdent(); 00068 00069 public: 00070 00074 bool undefined() const { 00075 return( _product.name->empty() ); 00076 } 00077 00081 bool isLine( std::string name_r ) const; 00082 00086 bool sameLine( const ProductIdent & rhs ) const { 00087 return isLine( rhs._product.name.asString() ); 00088 } 00089 00093 bool sameVersion( const ProductIdent & rhs ) const { 00094 return( _product.edition == rhs._product.edition ); 00095 } 00096 00100 bool sameProduct( const ProductIdent & rhs ) const { 00101 return( sameLine( rhs ) && sameVersion( rhs ) ); 00102 } 00103 00107 bool obsoletes( const ProductIdent & rhs ) const; 00108 00112 std::string asString() const { return _product.asString(); } 00113 00117 PkgNameEd asPkgNameEd() const { return _product; } 00118 00119 public: 00120 00125 static std::string toString( const ProductIdent & t ) { 00126 return PkgNameEd::toString( t._product ); 00127 } 00128 00133 static ProductIdent fromString( std::string s ) { 00134 return PkgNameEd::fromString( s ); 00135 } 00136 00137 }; 00138 00140 00141 #endif // ProductIdent_h