Author: dmacvicar Date: Thu Nov 20 11:55:13 2008 New Revision: 11737 URL: http://svn.opensuse.org/viewcvs/zypp?rev=11737&view=rev Log: adding the API for product information, ma will make it compile... Modified: trunk/libzypp/zypp/Repository.cc trunk/libzypp/zypp/Repository.h trunk/libzypp/zypp/sat/SolvAttr.cc trunk/libzypp/zypp/sat/SolvAttr.h trunk/sat-solver/src/knownid.h trunk/sat-solver/tools/repo_repomdxml.c Modified: trunk/libzypp/zypp/Repository.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.cc?rev=11737&r1=11736&r2=11737&view=diff ============================================================================== --- trunk/libzypp/zypp/Repository.cc (original) +++ trunk/libzypp/zypp/Repository.cc Thu Nov 20 11:55:13 2008 @@ -129,9 +129,6 @@ Repository::Keywords Repository::keywords() const { return Keywords(sat::SolvAttr::repositoryKeywords); } - Repository::Products Repository::products() const - { return Products(sat::SolvAttr::repositoryProducts); } - bool Repository::maybeOutdated() const { // system repo is not mirrored @@ -286,6 +283,17 @@ return myPool()._addSolvables( _repo, count_r ); } +#if 0 + Repository::ProductInfoIterator::ProductInfoIterator( const sat::Solvable & val_r, + const sat::SolvAttr & arrayid ) + { base_reference() = sat::LookupAttr( arrayid, val_r ).begin(); } + + std::string Repository::ProductInfoIterator::label() const + { return base_reference().subFind( sat::SolvAttr::repositoryProductLabel ).asString(); } + std::string Repository::ProductInfoIterator::cpeId() const + { return base_reference().subFind( sat::SolvAttr::repositoryProductCpeid ).asString(); } +#endif + /****************************************************************** ** ** FUNCTION NAME : operator<< Modified: trunk/libzypp/zypp/Repository.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.h?rev=11737&r1=11736&r2=11737&view=diff ============================================================================== --- trunk/libzypp/zypp/Repository.h (original) +++ trunk/libzypp/zypp/Repository.h Thu Nov 20 11:55:13 2008 @@ -17,6 +17,7 @@ #include "zypp/Pathname.h" #include "zypp/sat/detail/PoolMember.h" #include "zypp/sat/Solvable.h" +#include "zypp/sat/SolvAttr.h" #include "zypp/RepoInfo.h" #include "zypp/Date.h" @@ -128,15 +129,6 @@ Keywords keywords() const; /** - * Products this repository claims it is - * built for. - * - * Products are specified using the CPE form - * See http://cpe.mitre.org/ for more information on CPE - */ - Products products() const; - - /** * The suggested expiration date of this repository * already passed * @@ -173,6 +165,39 @@ SolvableIterator solvablesEnd() const; public: +#if 0 + /** Query class for Repository */ + class ProductInfoIterator; + + /** + * Get an iterator to the beginning of the repository + * compatible distros. + * \see Repository::ProductInfoIterator + */ + ProductInfoIterator compatibleWithProductBegin() const; + + /** + * Get an iterator to the end of the repository + * compatible distros. + * \see Repository::ProductInfoIterator + */ + ProductInfoIterator compatibleWithProductEnd() const; + + /** + * Get an iterator to the beginning of the repository + * compatible distros. + * \see Repository::ProductInfoIterator + */ + ProductInfoIterator updatesProductBegin() const; + + /** + * Get an iterator to the end of the repository + * compatible distros. + * \see Repository::ProductInfoIterator + */ + ProductInfoIterator updatesProductEnd() const; +#endif + public: /** Return any associated \ref RepoInfo. */ RepoInfo info() const; @@ -354,4 +379,75 @@ #include "zypp/sat/LookupAttr.h" +#if 0 + +namespace zypp +{ + /** + * Query class for Repository related products + * + * The iterator does not provide a dereference + * operator so you can do * on it, but you can + * access the attributes of each related product + * directly from the iterator. + * + * \code + * for ( Repository::ProductInfoIterator it = repo->compatibleWithProductBegin(); + * it != repo->compatibleWithProductEnd(); + * ++it ) + * { + * cout << it.cpeid() << endl; + * } + * \endcode + * + */ + class Repository::ProductInfoIterator : public boost::iterator_adaptor< + Repository::ProductInfoIterator // Derived + , sat::LookupAttr::iterator // Base + , int // Value + , boost::forward_traversal_tag // CategoryOrTraversal + , int + > + { + public: + ProductInfoIterator() {} + explicit ProductInfoIterator( const sat::Solvable & val_r, + const sat::SolvAttr & arrayid ); + + /** + * Product label + */ + std::string label() const; + + /** + * The Common Platform Enumeration name + * for this product. + * + * See http://cpe.mitre.org + */ + std::string cpeid() const; + + private: + friend class boost::iterator_core_access; + int dereference() const { return 0; } + }; + + inline Repository::ProductInfoIterator Repository::compatibleWithProductBegin() const + { return ProductInfoIterator(satSolvable(), sat::SolvAttr::repositoryDistros); } + + inline Repository::ProductInfoIterator Repository::compatibleWithProductEnd() const + { return ProductInfoIterator(); } + + inline Repository::ProductInfoIterator Repository::updatesProductBegin() const + { return ProductInfoIterator(satSolvable(), , sat::SolvAttr::repositoryUpdates); } + + inline Repository::ProductInfoIterator Repository::updatesProductEnd() const + { return ProductInfoIterator(); } + + +} +#endif + #endif // ZYPP_SAT_REPOSITORY_H + + Modified: trunk/libzypp/zypp/sat/SolvAttr.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvAttr.cc?rev=11737&r1=11736&r2=11737&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/SolvAttr.cc (original) +++ trunk/libzypp/zypp/sat/SolvAttr.cc Thu Nov 20 11:55:13 2008 @@ -116,10 +116,10 @@ // repository const SolvAttr SolvAttr::repositoryTimestamp ( REPOSITORY_TIMESTAMP ); const SolvAttr SolvAttr::repositoryExpire ( REPOSITORY_EXPIRE ); + /** array of repositoryProductLabel repositoryProductCpeid pairs */ const SolvAttr SolvAttr::repositoryUpdates ( REPOSITORY_UPDATES ); - const SolvAttr SolvAttr::repositoryUpdateLabel ( REPOSITORY_UPDATE_LABEL ); - const SolvAttr SolvAttr::repositoryUpdateCpeid ( REPOSITORY_UPDATE_CPEID ); - const SolvAttr SolvAttr::repositoryProducts ( REPOSITORY_PRODUCTS ); + /** array of repositoryProductLabel repositoryProductCpeid pairs */ + const SolvAttr SolvAttr::repositoryDistros ( REPOSITORY_DISTROS ); const SolvAttr SolvAttr::repositoryProductLabel( REPOSITORY_PRODUCT_LABEL ); const SolvAttr SolvAttr::repositoryProductCpeid( REPOSITORY_PRODUCT_CPEID ); const SolvAttr SolvAttr::repositoryKeywords ( REPOSITORY_KEYWORDS ); Modified: trunk/libzypp/zypp/sat/SolvAttr.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvAttr.h?rev=11737&r1=11736&r2=11737&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/SolvAttr.h (original) +++ trunk/libzypp/zypp/sat/SolvAttr.h Thu Nov 20 11:55:13 2008 @@ -148,11 +148,9 @@ //@{ static const SolvAttr repositoryTimestamp; static const SolvAttr repositoryExpire; - static const SolvAttr repositoryUpdates; - static const SolvAttr repositoryUpdateLabel; - static const SolvAttr repositoryUpdateCpeid; static const SolvAttr repositoryKeywords; - static const SolvAttr repositoryProducts; + static const SolvAttr repositoryUpdates; + static const SolvAttr repositoryDistros; static const SolvAttr repositoryProductLabel; static const SolvAttr repositoryProductCpeid; static const SolvAttr repositoryRevision; Modified: trunk/sat-solver/src/knownid.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/knownid.h?rev=11737&r1=11736&r2=11737&view=diff ============================================================================== --- trunk/sat-solver/src/knownid.h (original) +++ trunk/sat-solver/src/knownid.h Thu Nov 20 11:55:13 2008 @@ -182,11 +182,11 @@ /* which things does this repo provides updates for, if it does (array) */ KNOWNID(REPOSITORY_UPDATES, "repository:updates"), -KNOWNID(REPOSITORY_UPDATE_LABEL, "repository:update:label"), -KNOWNID(REPOSITORY_UPDATE_CPEID, "repository:update:cpeid"), +/* for the repository:update label and cpeid, use the repository:product + sub attributes */ /* which products this repository is supposed to be for (array) */ -KNOWNID(REPOSITORY_PRODUCTS, "repository:products"), +KNOWNID(REPOSITORY_DISTROS, "repository:distros"), KNOWNID(REPOSITORY_PRODUCT_LABEL, "repository:product:label"), KNOWNID(REPOSITORY_PRODUCT_CPEID, "repository:product:cpeid"), Modified: trunk/sat-solver/tools/repo_repomdxml.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_repomdxml.c?rev=11737&r1=11736&r2=11737&view=diff ============================================================================== --- trunk/sat-solver/tools/repo_repomdxml.c (original) +++ trunk/sat-solver/tools/repo_repomdxml.c Thu Nov 20 11:55:13 2008 @@ -275,7 +275,7 @@ /* set the cpeid for the product the label is set in the content of the tag */ if (cpeid) - repodata_set_poolstr(pd->data, pd->ruhandle, REPOSITORY_UPDATE_CPEID, cpeid); + repodata_set_poolstr(pd->data, pd->ruhandle, REPOSITORY_PRODUCT_CPEID, cpeid); break; } case STATE_DATA: break; @@ -354,13 +354,13 @@ made for */ if (pd->content) repodata_set_str(pd->data, pd->rphandle, REPOSITORY_PRODUCT_LABEL, pd->content); - repodata_add_flexarray(pd->data, SOLVID_META, REPOSITORY_PRODUCTS, pd->rphandle); + repodata_add_flexarray(pd->data, SOLVID_META, REPOSITORY_DISTROS, pd->rphandle); break; case STATE_UPDATES: /* distro tag is used in suseinfo.xml to say the repo updates a product however it s not yet a tag standarized for repomd.xml */ if (pd->content) - repodata_set_str(pd->data, pd->ruhandle, REPOSITORY_UPDATE_LABEL, pd->content); + repodata_set_str(pd->data, pd->ruhandle, REPOSITORY_PRODUCT_LABEL, pd->content); repodata_add_flexarray(pd->data, SOLVID_META, REPOSITORY_UPDATES, pd->ruhandle); break; case STATE_SUSEINFO: break; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org