Mailinglist Archive: zypp-commit (266 mails)

< Previous Next >
[zypp-commit] r11760 - in /trunk/libzypp: package/libzypp.changes zypp/Repository.cc zypp/Repository.h
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Thu, 20 Nov 2008 21:20:26 -0000
  • Message-id: <20081120212026.BA431E02D2@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Thu Nov 20 22:20:26 2008
New Revision: 11760

URL: http://svn.opensuse.org/viewcvs/zypp?rev=11760&view=rev
Log:
Fix retrieval of Repository attributes like timestamps, keywords and product
info.

Modified:
trunk/libzypp/package/libzypp.changes
trunk/libzypp/zypp/Repository.cc
trunk/libzypp/zypp/Repository.h

Modified: trunk/libzypp/package/libzypp.changes
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=11760&r1=11759&r2=11760&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Thu Nov 20 22:20:26 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Thu Nov 20 22:15:28 CET 2008 - ma@xxxxxxx
+
+- Fix retrieval of Repository attributes like timestamps, keywords
+ and product info.
+- revision 11760
+
+-------------------------------------------------------------------
Thu Nov 20 19:30:05 CET 2008 - ma@xxxxxxx

- Enhance class LookupAttr and add convenience class LookupRepoAttr to

Modified: trunk/libzypp/zypp/Repository.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.cc?rev=11760&r1=11759&r2=11760&view=diff
==============================================================================
--- trunk/libzypp/zypp/Repository.cc (original)
+++ trunk/libzypp/zypp/Repository.cc Thu Nov 20 22:20:26 2008
@@ -54,142 +54,125 @@

std::string Repository::alias() const
{
- NO_REPOSITORY_RETURN( std::string() );
- if ( ! _repo->name )
- return std::string();
- return _repo->name;
+ NO_REPOSITORY_RETURN( std::string() );
+ if ( ! _repo->name )
+ return std::string();
+ return _repo->name;
}

-#warning FIX to iterator
zypp::Date Repository::generatedTimestamp() const
{
- ::Dataiterator di;
- ::dataiterator_init(&di, sat::Pool::instance().get(), get(),
SOLVID_META, REPOSITORY_TIMESTAMP, 0, 0);
- if (::dataiterator_step(&di))
- {
- do
- {
- switch (di.key->name)
- {
- case REPOSITORY_TIMESTAMP:
- {
- return di.kv.num;
- break;
- }
- }
- }
- while (::dataiterator_step(&di));
- }
- else
- {
- if ( isSystemRepo() )
- return 0;
- ERR << "the attribute generated timestamp does not exist in the
repo" << endl;
- }
-
- return Date();
+ NO_REPOSITORY_RETURN( 0 );
+ sat::LookupRepoAttr q( sat::SolvAttr::repositoryTimestamp, *this );
+ return( q.empty() ? 0 : q.begin().asUnsigned() );
}

-
zypp::Date Repository::suggestedExpirationTimestamp() const
{
- ::Dataiterator di;
- ::dataiterator_init(&di, sat::Pool::instance().get(), get(),
SOLVID_META, REPOSITORY_EXPIRE, 0, 0);
- Date generated = generatedTimestamp();
- // do not calculate over a missing generated
- // timestamp
- if ( generated == Date() )
- return Date();
-
- if (::dataiterator_step(&di))
- {
- do
- {
- switch (di.key->name)
- {
- case REPOSITORY_EXPIRE:
- {
- return generated + di.kv.num;
- break;
- }
- }
- }
- while (::dataiterator_step(&di));
- }
- else
- {
- if ( isSystemRepo() )
- return 0;
- ERR << "the attribute suggested expiration timestamp does not exist in
the repo" << endl;
- }
+ NO_REPOSITORY_RETURN( 0 );
+ Date generated = generatedTimestamp();
+ if ( ! generated )
+ return 0; // do not calculate over a missing generated timestamp
+
+ sat::LookupRepoAttr q( sat::SolvAttr::repositoryExpire, *this );
+ if ( q.empty() )
+ return 0;

- return Date();
+ return generated + q.begin().asUnsigned();
}

Repository::Keywords Repository::keywords() const
- { return Keywords(sat::SolvAttr::repositoryKeywords); }
+ {
+ NO_REPOSITORY_RETURN( Keywords() );
+ return Keywords( sat::SolvAttr::repositoryKeywords, *this,
sat::LookupAttr::REPO_ATTR );
+ }

bool Repository::maybeOutdated() const
{
- // system repo is not mirrored
- if ( isSystemRepo() )
- return false;
+ NO_REPOSITORY_RETURN( false );
+ // system repo is not mirrored
+ if ( isSystemRepo() )
+ return false;

- Date suggested = suggestedExpirationTimestamp();
+ Date suggested = suggestedExpirationTimestamp();

- // if no data, don't suggest
- if ( suggested == Date() )
- return false;
+ // if no data, don't suggest
+ if ( ! suggested )
+ return false;

- return suggestedExpirationTimestamp() < Date::now();
+ return suggestedExpirationTimestamp() < Date::now();
}

bool Repository::providesUpdatesFor( const std::string &key ) const
{
- return false;
+ NO_REPOSITORY_RETURN( false );
+ return false;
}

bool Repository::isUpdateRepo() const
{
- return false;
+ NO_REPOSITORY_RETURN( false );
+ return false;
}

bool Repository::solvablesEmpty() const
{
- NO_REPOSITORY_RETURN( true );
- return !_repo->nsolvables;
+ NO_REPOSITORY_RETURN( true );
+ return !_repo->nsolvables;
}

Repository::size_type Repository::solvablesSize() const
{
- NO_REPOSITORY_RETURN( 0 );
- return _repo->nsolvables;
+ NO_REPOSITORY_RETURN( 0 );
+ return _repo->nsolvables;
}

Repository::SolvableIterator Repository::solvablesBegin() const
{
- NO_REPOSITORY_RETURN( make_filter_iterator( detail::ByRepository( *this
),
- sat::detail::SolvableIterator(),
- sat::detail::SolvableIterator() )
);
- return make_filter_iterator( detail::ByRepository( *this ),
-
sat::detail::SolvableIterator(_repo->start),
- sat::detail::SolvableIterator(_repo->end)
);
+ NO_REPOSITORY_RETURN( make_filter_iterator( detail::ByRepository( *this
),
+ sat::detail::SolvableIterator(),
+ sat::detail::SolvableIterator() ) );
+ return make_filter_iterator( detail::ByRepository( *this ),
+ sat::detail::SolvableIterator(_repo->start),
+ sat::detail::SolvableIterator(_repo->end) );
}

Repository::SolvableIterator Repository::solvablesEnd() const
{
- NO_REPOSITORY_RETURN( make_filter_iterator( detail::ByRepository( *this
),
- sat::detail::SolvableIterator(),
- sat::detail::SolvableIterator() )
);
- return make_filter_iterator(detail::ByRepository( *this ),
- sat::detail::SolvableIterator(_repo->end),
- sat::detail::SolvableIterator(_repo->end) );
+ NO_REPOSITORY_RETURN( make_filter_iterator( detail::ByRepository( *this
),
+ sat::detail::SolvableIterator(),
+ sat::detail::SolvableIterator() ) );
+ return make_filter_iterator(detail::ByRepository( *this ),
+ sat::detail::SolvableIterator(_repo->end),
+ sat::detail::SolvableIterator(_repo->end) );
+ }
+
+ Repository::ProductInfoIterator Repository::compatibleWithProductBegin()
const
+ {
+ NO_REPOSITORY_RETURN( ProductInfoIterator() );
+ return ProductInfoIterator( sat::SolvAttr::repositoryDistros, *this );
+ }
+
+ Repository::ProductInfoIterator Repository::compatibleWithProductEnd()
const
+ {
+ return ProductInfoIterator();
+ }
+
+ Repository::ProductInfoIterator Repository::updatesProductBegin() const
+ {
+ NO_REPOSITORY_RETURN( ProductInfoIterator() );
+ return ProductInfoIterator( sat::SolvAttr::repositoryUpdates, *this );
+ }
+
+ Repository::ProductInfoIterator Repository::updatesProductEnd() const
+ {
+ return ProductInfoIterator();
}

RepoInfo Repository::info() const
{
- NO_REPOSITORY_RETURN( RepoInfo() );
- return myPool().repoInfo( _repo );
+ NO_REPOSITORY_RETURN( RepoInfo() );
+ return myPool().repoInfo( _repo );
}

void Repository::setInfo( const RepoInfo & info_r )
@@ -283,17 +266,6 @@
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<<
@@ -308,9 +280,23 @@
<< "{"
<< "prio " << obj.get()->priority
<< ", size " << obj.solvablesSize()
- <<"}";
+ << "}";
}

+ ///////////////////////////////////////////////////////////////////
+ //
+ // Repository::ProductInfoIterator
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ Repository::ProductInfoIterator::ProductInfoIterator( sat::SolvAttr
attr_r, Repository repo_r )
+ { base_reference() = sat::LookupRepoAttr( attr_r, repo_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(); }

/////////////////////////////////////////////////////////////////
} // namespace zypp

Modified: trunk/libzypp/zypp/Repository.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.h?rev=11760&r1=11759&r2=11760&view=diff
==============================================================================
--- trunk/libzypp/zypp/Repository.h (original)
+++ trunk/libzypp/zypp/Repository.h Thu Nov 20 22:20:26 2008
@@ -42,9 +42,8 @@
typedef filter_iterator<detail::ByRepository,
sat::detail::SolvableIterator> SolvableIterator;
typedef sat::detail::size_type size_type;
typedef sat::detail::RepoIdType IdType;
- typedef sat::ArrayAttr<std::string,std::string> UpdateKeys;
+
typedef sat::ArrayAttr<std::string,std::string> Keywords;
- typedef sat::ArrayAttr<std::string,std::string> Products;

public:
/** Default ctor creates \ref noRepository.*/
@@ -97,7 +96,7 @@
* specify when it was generated.
*
*/
- zypp::Date generatedTimestamp() const;
+ Date generatedTimestamp() const;

/**
* Suggested expiration timestamp.
@@ -115,7 +114,7 @@
* an expiration date.
*
*/
- zypp::Date suggestedExpirationTimestamp() const;
+ Date suggestedExpirationTimestamp() const;

/**
* repository keywords (tags)
@@ -276,7 +275,7 @@
inline bool operator<( const Repository & lhs, const Repository & rhs )
{ return lhs.get() < rhs.get(); }

-
+ ///////////////////////////////////////////////////////////////////
/**
* Query class for Repository related products
*
@@ -286,9 +285,7 @@
* directly from the iterator.
*
* \code
- * for ( Repository::ProductInfoIterator it =
repo->compatibleWithProductBegin();
- * it != repo->compatibleWithProductEnd();
- * ++it )
+ * for_( it, repo.compatibleWithProductBegin(),
repo.compatibleWithProductEnd() )
* {
* cout << it.cpeid() << endl;
* }
@@ -300,12 +297,12 @@
, sat::LookupAttr::iterator // Base
, int // Value
, boost::forward_traversal_tag // CategoryOrTraversal
- , int
+ , int // Reference
>
{
public:
- ProductInfoIterator() {}
- explicit ProductInfoIterator( const sat::SolvAttr & arrayid );
+ ProductInfoIterator()
+ {}

/**
* Product label
@@ -318,24 +315,18 @@
*
* See http://cpe.mitre.org
*/
- std::string cpeid() const;
+ std::string cpeId() const;
+
+ private:
+ friend class Repository;
+ /** Hide ctor as just a limited set of attributes is valid. */
+ explicit ProductInfoIterator( sat::SolvAttr attr_r, Repository repo_r
);

private:
friend class boost::iterator_core_access;
int dereference() const { return 0; }
};
-
- inline Repository::ProductInfoIterator
Repository::compatibleWithProductBegin() const
- { return ProductInfoIterator( sat::SolvAttr::repositoryDistros ); }
-
- inline Repository::ProductInfoIterator
Repository::compatibleWithProductEnd() const
- { return ProductInfoIterator(); }
-
- inline Repository::ProductInfoIterator Repository::updatesProductBegin()
const
- { return ProductInfoIterator( sat::SolvAttr::repositoryUpdates ); }
-
- inline Repository::ProductInfoIterator Repository::updatesProductEnd()
const
- { return ProductInfoIterator(); }
+ ///////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////
//

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

< Previous Next >
This Thread
  • No further messages