Mailinglist Archive: zypp-commit (223 mails)

< Previous Next >
[zypp-commit] r10715 - in /trunk/libzypp: package/libzypp.changes zypp/CMakeLists.txt zypp/ProductInfo.cc zypp/ProductInfo.h zypp/ResObject.cc zypp/ResObject.h
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Thu, 31 Jul 2008 20:57:10 -0000
  • Message-id: <20080731205710.BCD792F18A@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Thu Jul 31 22:57:10 2008
New Revision: 10715

URL: http://svn.opensuse.org/viewcvs/zypp?rev=10715&view=rev
Log:
- New class ProductInfo to provide product related metadata that
might be associated with a package. This will replace the Product
resolvable.

Added:
trunk/libzypp/zypp/ProductInfo.cc
trunk/libzypp/zypp/ProductInfo.h
Modified:
trunk/libzypp/package/libzypp.changes
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/ResObject.cc
trunk/libzypp/zypp/ResObject.h

Modified: trunk/libzypp/package/libzypp.changes
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=10715&r1=10714&r2=10715&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Thu Jul 31 22:57:10 2008
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Thu Jul 31 21:52:11 CEST 2008 ma@xxxxxxx
+
+- New class ProductInfo to provide product related metadata that
+ might be associated with a package. This will replace the Product
+ resolvable.
+- revision 10715
+
+-------------------------------------------------------------------
Thu Jul 31 19:01:54 CEST 2008 - dmacvicar@xxxxxxx

- generate a unique anonymous unique string per target

Modified: trunk/libzypp/zypp/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=10715&r1=10714&r2=10715&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Thu Jul 31 22:57:10 2008
@@ -41,6 +41,7 @@
PoolQueryResult.cc
ProblemSolution.cc
Product.cc
+ ProductInfo.cc
ProgressData.cc
ProvideFilePolicy.cc
PublicKey.cc
@@ -128,6 +129,7 @@
ProblemSolution.h
ProblemTypes.h
Product.h
+ ProductInfo.h
ProgressData.h
ProvideFilePolicy.h
PublicKey.h

Added: trunk/libzypp/zypp/ProductInfo.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ProductInfo.cc?rev=10715&view=auto
==============================================================================
--- trunk/libzypp/zypp/ProductInfo.cc (added)
+++ trunk/libzypp/zypp/ProductInfo.cc Thu Jul 31 22:57:10 2008
@@ -0,0 +1,192 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ProductInfo.cc
+ *
+*/
+#include <iostream>
+#include "zypp/base/LogTools.h"
+
+#include "zypp/ProductInfo.h"
+#include "zypp/PoolItem.h"
+#include "zypp/Package.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ namespace
+ {
+ /** Fast check whether a \ref sat::Solvable provides product metadata.
+ * Return the solvable or \ref sat::noSolvable.
+ */
+ sat::Solvable ifProductInfoProvided( sat::Solvable solvable_r )
+ {
+#warning THIS SHOULD BE REPLACED BY A FAST TEST E.G. productName
+ // and use detail::IdType lookupIdAttribute for this test
+
+ if ( solvable_r.lookupStrAttribute( sat::SolvAttr::productShortlabel
).empty() )
+ return sat::Solvable::noSolvable;
+ return solvable_r;
+ }
+
+ /** List attribute helper */
+ void fillList( std::list<Url> & ret_r, sat::Solvable solv_r, sat::SolvAttr
attr_r )
+ {
+ sat::LookupAttr query( attr_r, solv_r );
+ for_( it, query.begin(), query.end() )
+ {
+ try // ignore malformed urls
+ {
+ ret_r.push_back( Url( it.asString() ) );
+ }
+ catch( const url::UrlException & )
+ {}
+ }
+ }
+
+ /** List attribute helper */
+ void fillList( std::list<std::string> & ret_r, sat::Solvable solv_r,
sat::SolvAttr attr_r )
+ {
+ sat::LookupAttr query( attr_r, solv_r );
+ for_( it, query.begin(), query.end() )
+ {
+ ret_r.push_back( it.asString() );
+ }
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////
+
+ const ProductInfo ProductInfo::noProductInfo;
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : ProductInfo::ProductInfo
+ // METHOD TYPE : Ctor
+ //
+ ProductInfo::ProductInfo()
+ {}
+
+ ProductInfo::ProductInfo( sat::Solvable solvable_r )
+ : sat::Solvable( ifProductInfoProvided( solvable_r ) )
+ {}
+
+ ProductInfo::ProductInfo( const PoolItem & poolItem_r )
+ : sat::Solvable( ifProductInfoProvided( poolItem_r.satSolvable() ) )
+ {}
+
+ ProductInfo::ProductInfo( const ResTraits<ResObject>::constPtrType &
package_r )
+ : sat::Solvable( package_r ? ifProductInfoProvided( package_r->satSolvable()
)
+ : sat::Solvable::noSolvable )
+ {}
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const ProductInfo & obj )
+ {
+#warning provide reasonable output
+ return str << obj.satSolvable();
+ }
+
+ ///////////////////////////////////////////////////////////////////
+
+ PoolItem ProductInfo::poolItem() const
+ {
+ return PoolItem( *this );
+ }
+
+ ResTraits<Package>::constPtrType ProductInfo::package() const
+ {
+ return make<Package>( *this );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+
+#warning DUMMIES RETURNING THE PACKAGE ATTRIBUTES
+ std::string ProductInfo::name() const
+ { return sat::Solvable::name(); }
+
+ Edition ProductInfo::edition() const
+ { return sat::Solvable::edition(); }
+
+ Arch ProductInfo::arch() const
+ { return sat::Solvable::arch(); }
+
+ Vendor ProductInfo::vendor() const
+ { return sat::Solvable::vendor().asString(); }
+
+ std::string ProductInfo::summary( const Locale & lang_r ) const
+ { return package() ? package()->summary( lang_r ) : std::string(); }
+
+ std::string ProductInfo::description( const Locale & lang_r ) const
+ { return package() ? package()->description( lang_r ) : std::string(); }
+
+
+#warning REVIEW THESE OLD PRODUCT ARTTRIBUTES
+
+ std::string ProductInfo::type() const
+ { return lookupStrAttribute( sat::SolvAttr::productType ); }
+
+ Url ProductInfo::releaseNotesUrl() const
+ {
+ std::list<Url> ret;
+ fillList( ret, satSolvable(), sat::SolvAttr::productRelnotesurl );
+ if ( ! ret.empty() )
+ return ret.front();
+ return Url();
+ }
+
+ std::list<Url> ProductInfo::updateUrls() const
+ {
+ std::list<Url> ret;
+ fillList( ret, satSolvable(), sat::SolvAttr::productUpdateurls );
+ return ret;
+ }
+
+ std::list<Url> ProductInfo::extraUrls() const
+ {
+ std::list<Url> ret;
+ fillList( ret, satSolvable(), sat::SolvAttr::productExtraurls );
+ return ret;
+ }
+
+ std::list<Url> ProductInfo::optionalUrls() const
+ {
+ std::list<Url> ret;
+ fillList( ret, satSolvable(), sat::SolvAttr::productOptionalurls );
+ return ret;
+ }
+
+ std::list<std::string> ProductInfo::flags() const
+ {
+ std::list<std::string> ret;
+ fillList( ret, satSolvable(), sat::SolvAttr::productFlags );
+ return ret;
+ }
+
+ std::string ProductInfo::shortName() const
+ { return lookupStrAttribute( sat::SolvAttr::productShortlabel ); }
+
+ std::string ProductInfo::longName( const Locale & /*lang_r*/ ) const
+ { return std::string(); }
+
+ std::string ProductInfo::distributionName() const
+ { return lookupStrAttribute( sat::SolvAttr::productDistproduct ); }
+
+ Edition ProductInfo::distributionEdition() const
+ { return Edition( lookupStrAttribute( sat::SolvAttr::productDistversion ) );
}
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////

Added: trunk/libzypp/zypp/ProductInfo.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ProductInfo.h?rev=10715&view=auto
==============================================================================
--- trunk/libzypp/zypp/ProductInfo.h (added)
+++ trunk/libzypp/zypp/ProductInfo.h Thu Jul 31 22:57:10 2008
@@ -0,0 +1,172 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ProductInfo.h
+ *
+*/
+#ifndef ZYPP_PRODUCTINFO_H
+#define ZYPP_PRODUCTINFO_H
+
+#include <iosfwd>
+
+#include "zypp/sat/Solvable.h"
+#include "zypp/Locale.h"
+#include "zypp/Vendor.h"
+#include "zypp/Repository.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ class Url;
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ProductInfo
+ //
+ /** Product metadata.
+ *
+ * \ref ProductInfo allows to retrieve product related metadata, that
+ * might be associated with certain packages. This class basically
+ * provides the information stored in an \c /etc/products.d entry.
+ *
+ * \ref ProductInfo is provided by \ref Package.
+ *
+ * The underlying \c private \ref sat::Solvable either refers to
+ * an associated package providing product related metadata, or
+ * is \ref sat::noSolvable.
+ */
+ class ProductInfo : private sat::Solvable
+ {
+ public:
+ /** Represents no \ref ProductInfo. */
+ static const ProductInfo noProductInfo;
+
+ public:
+ /** Default ctor creates \ref noProductInfo. */
+ ProductInfo();
+
+ /** ProductInfo associated with a \ref sat::Solvable or \ref
noProductInfo. */
+ explicit ProductInfo( sat::Solvable solvable_r );
+
+ /** ProductInfo associated with a \ref PoolItem or \ref noProductInfo. */
+ explicit ProductInfo( const PoolItem & poolItem_r );
+
+ /** ProductInfo associated with a \ref ResObject or \ref noProductInfo.
*/
+ explicit ProductInfo( const ResTraits<ResObject>::constPtrType &
package_r );
+
+ public:
+#ifndef SWIG // Swig treats it as syntax error
+ /** Whether this represents a valid- or \ref noProductInfo. */
+ using sat::Solvable::operator bool_type;
+#endif
+
+ public:
+ /** \name Access the associated \ref Package.
+ */
+ //@{
+ /** Access the associated \ref sat:::Solvable. */
+ sat::Solvable satSolvable() const
+ { return *this; }
+
+ /** Access the associated \ref PoolItem. */
+ PoolItem poolItem() const;
+
+ /** Access the associated \ref Package. */
+ ResTraits<Package>::constPtrType package() const;
+ //@}
+
+ public:
+ /** \name Product metadata.
+ */
+ //@{
+ /** Whether this represents an installed Product. */
+ using sat::Solvable::isSystem;
+
+ std::string name() const;
+ Edition edition() const;
+ Arch arch() const;
+ Vendor vendor() const;
+
+ std::string summary( const Locale & lang_r = Locale() ) const;
+ std::string description( const Locale & lang_r = Locale() ) const;
+
+ /** The \ref Repository this \ref Product belongs to. */
+ using sat::Solvable::repository;
+
+ /** \ref RepoInfo associated with the repository
+ * providing this product.
+ */
+ RepoInfo repoInfo() const { return repository().info(); }
+
+
+ //----------------------------------------------
+ // These are the old Product attibutes to be revieved:
+
+ /** Get the product type (base, add-on) */
+ std::string type() const;
+
+ /** The URL to download the release notes for this product */
+ Url releaseNotesUrl() const;
+
+ /**
+ * Online updates for the product.
+ * They are complementary, not alternatives. #163192
+ */
+ std::list<Url> updateUrls() const;
+
+ /**
+ * Additional software for the product
+ * They are complementary, not alternatives.
+ */
+ std::list<Url> extraUrls() const;
+
+ /**
+ * Optional software for the product
+ * (for example. Non OSS repositories)
+ * They are complementary, not alternatives.
+ */
+ std::list<Url> optionalUrls() const;
+
+ /** The product flags */
+ std::list<std::string> flags() const;
+
+ /** Untranslated short name like <tt>SLES 10</tt>*/
+ std::string shortName() const;
+
+ /** Translated long name like <tt>SUSE Linux Enterprise Server 10</tt>*/
+ std::string longName( const Locale & lang_r = Locale() ) const;
+
+ /** Vendor specific distribution id. */
+ std::string distributionName() const;
+
+ /** Vendor specific distribution version. */
+ Edition distributionEdition() const;
+ //@}
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates ProductInfo Stream output */
+ std::ostream & operator<<( std::ostream & str, const ProductInfo & obj );
+
+ /** \relates ProductInfo */
+ inline bool operator==( const ProductInfo & lhs, const ProductInfo & rhs )
+ { return lhs.satSolvable() == rhs.satSolvable(); }
+
+ /** \relates ProductInfo */
+ inline bool operator!=( const ProductInfo & lhs, const ProductInfo & rhs )
+ { return lhs.satSolvable() != rhs.satSolvable(); }
+
+ /** \relates ProductInfo */
+ inline bool operator<( const ProductInfo & lhs, const ProductInfo & rhs )
+ { return lhs.satSolvable() < rhs.satSolvable(); }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PRODUCTINFO_H

Modified: trunk/libzypp/zypp/ResObject.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResObject.cc?rev=10715&r1=10714&r2=10715&view=diff
==============================================================================
--- trunk/libzypp/zypp/ResObject.cc (original)
+++ trunk/libzypp/zypp/ResObject.cc Thu Jul 31 22:57:10 2008
@@ -16,6 +16,7 @@
#include "zypp/sat/Solvable.h"
#include "zypp/Repository.h"
#include "zypp/RepoInfo.h"
+#include "zypp/ProductInfo.h"
#include "zypp/IdString.h"

using namespace zypp;
@@ -55,9 +56,13 @@
}

///////////////////////////////////////////////////////////////////
- //
- // ResObject interface forwarded to implementation
- //
+
+ bool ResObject::hasProductInfo() const
+ { return ProductInfo( *this ); } // this is basically one lookupIdAttribute
call
+
+ ProductInfo ResObject::productInfo() const
+ { return ProductInfo( *this ); }
+
///////////////////////////////////////////////////////////////////

std::string ResObject::summary( const Locale & lang_r ) const

Modified: trunk/libzypp/zypp/ResObject.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResObject.h?rev=10715&r1=10714&r2=10715&view=diff
==============================================================================
--- trunk/libzypp/zypp/ResObject.h (original)
+++ trunk/libzypp/zypp/ResObject.h Thu Jul 31 22:57:10 2008
@@ -30,6 +30,8 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////

+ class ProductInfo;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : ResObject
@@ -65,6 +67,18 @@
//@}

public:
+ /** \name Associated product metadata.
+ * Some \ref Packages may provide additional product metadata.
+ * \see \ref ProductInfo.
+ */
+ //@{
+ /** Whether there is associated \ref ProductInfo available. */
+ bool hasProductInfo() const;
+ /** Return associated \ref ProductInfo or \ref ProductInfo::noProductInfo.
*/
+ ProductInfo productInfo() const;
+ //@}
+
+ public:

/**
* \short Short text describing the resolvable.

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
List Navigation
This Thread
  • No further messages