repository keys work
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 11 Sep 2008 14:50:27 +0000 (14:50 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 11 Sep 2008 14:50:27 +0000 (14:50 +0000)
package/libzypp.changes
zypp/Repository.cc
zypp/Repository.h
zypp/sat/SolvAttr.cc
zypp/sat/SolvAttr.h

index 118f74a..528a5fe 100644 (file)
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Thu Sep 11 16:01:57 CEST 2008 - dmacvicar@suse.de
+
+- add Repostiroy::updateKeys and 
+  Repository::providesUpdatesForKey(string) for repo and
+  product matching
+- Provide Repository::isUpdateRepo
+
+-------------------------------------------------------------------
 Thu Sep 11 14:41:28 CEST 2008 - ma@suse.de
 
 - Fix evaluation of vendor support flags.
index 09dd10f..d2fac68 100644 (file)
@@ -123,7 +123,6 @@ namespace zypp
       return Date();
     }
 
-    
     bool Repository::maybeOutdated() const
     {
         // system repo is not mirrored
@@ -138,7 +137,21 @@ namespace zypp
 
         return suggestedExpirationTimestamp() < Date::now();
     }
+
+    Repository::UpdateKeys Repository::updateKeys() const
+    { return UpdateKeys( sat::SolvAttr::repositoryUpdates, *this ); }
+    
+    bool Repository::providesUpdatesForKey( const std::string &key ) const
+    {
+        UpdateKeys keys(updateKeys());
+        return ( keys.find(key) != keys.end() );
+    }
     
+    bool Repository::isUpdateRepo() const
+    {
+        return ( ! updateKeys().empty() );
+    }
+
     bool Repository::solvablesEmpty() const
     {
        NO_REPOSITORY_RETURN( true );
index 0a516dd..932402b 100644 (file)
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
+    namespace sat
+    {
+      template<class _ResultT, class _AttrT>
+      class ArrayAttr;
+    }
+
     namespace detail
     {
       struct ByRepository;
@@ -41,6 +47,7 @@ namespace zypp
         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;
 
     public:
         /** Default ctor creates \ref noRepository.*/
@@ -133,6 +140,23 @@ namespace zypp
          */
         bool maybeOutdated() const;
 
+        /**
+         * if the repository claims to update something then
+         * it is an update repository
+         */
+        bool isUpdateRepo() const;
+
+        /**
+         * Wether the reposity claims to provide updates to \ref prod
+         */
+        UpdateKeys updateKeys() const;
+
+        /**
+         * wether the repository claims to update something \ref prod
+         * with key &\key
+         */
+        bool providesUpdatesForKey( const std::string &key ) const;
+
         /** Whether \ref Repository contains solvables. */
         bool solvablesEmpty() const;
 
@@ -315,4 +339,7 @@ namespace zypp
     /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
+
+#include "zypp/sat/LookupAttr.h"
+
 #endif // ZYPP_SAT_REPOSITORY_H
index a25ef1b..3a5f360 100644 (file)
@@ -113,7 +113,7 @@ namespace sat
   // repository
   const SolvAttr SolvAttr::repositoryTimestamp ( REPOSITORY_TIMESTAMP );
   const SolvAttr SolvAttr::repositoryExpire ( REPOSITORY_EXPIRE );
-
+  const SolvAttr SolvAttr::repositoryUpdates ( REPOSITORY_UPDATES );
 
 } // namespace sat
   /////////////////////////////////////////////////////////////////
index 6e1dbdf..b700b67 100644 (file)
@@ -140,6 +140,7 @@ namespace sat
       //@{
       static const SolvAttr repositoryTimestamp;
       static const SolvAttr repositoryExpire;
+      static const SolvAttr repositoryUpdates;
       //@}
 
       //@}