Use libsolv includes and adjust documentation
[platform/upstream/libzypp.git] / zypp / Repository.h
index ba59269..f23dc60 100644 (file)
@@ -16,6 +16,7 @@
 #include "zypp/base/SafeBool.h"
 #include "zypp/Pathname.h"
 #include "zypp/sat/detail/PoolMember.h"
+#include "zypp/sat/LookupAttr.h"     // LookupAttrTools.h included at EOF
 #include "zypp/sat/Solvable.h"
 #include "zypp/RepoInfo.h"
 #include "zypp/Date.h"
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
-    namespace sat
-    {
-      template<class _ResultT, class _AttrT>
-      class ArrayAttr;
-    }
-
     namespace detail
     {
       struct ByRepository;
@@ -47,9 +42,8 @@ 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;
+
         typedef sat::ArrayAttr<std::string,std::string> Keywords;
-        typedef sat::ArrayAttr<std::string,std::string> Products;
 
     public:
         /** Default ctor creates \ref noRepository.*/
@@ -76,16 +70,19 @@ namespace zypp
 
     public:
          /**
-          * Short unique, convenience string to refer to a repo.
+          * Short unique string to identify a repo.
           * ie: openSUSE-10.3
           *
           * If you are looking for a label to display
-          * see \ref info() which provides \ref RepoInfo::name()
+          * see \ref name().
           * ie: "openSUSE 10.3 Main repository"
           *
           */
         std::string alias() const;
 
+        /** Label to display for this repo. */
+        std::string name() const;
+
         /**
          * Timestamp when this repository was generated
          *
@@ -102,7 +99,7 @@ namespace zypp
          * specify when it was generated.
          *
          */
-        zypp::Date generatedTimestamp() const;
+        Date generatedTimestamp() const;
 
         /**
          * Suggested expiration timestamp.
@@ -120,7 +117,7 @@ namespace zypp
          * an expiration date.
          *
          */
-        zypp::Date suggestedExpirationTimestamp() const;
+        Date suggestedExpirationTimestamp() const;
 
         /**
          * repository keywords (tags)
@@ -128,18 +125,12 @@ namespace zypp
         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
          *
+         * rpm-md repositories can provide this tag using the
+         * expire extension tag:
+         * \see http://en.opensuse.org/Standards/Rpm_Metadata#SUSE_repository_info_.28suseinfo.xml.29.2C_extensions_to_repomd.xml
          */
         bool maybeOutdated() const;
 
@@ -147,18 +138,22 @@ namespace zypp
          * if the repository claims to update something then
          * it is an update repository
          *
-         * This is implemented by looking at an "update" keyword
-         * on the repository tags
+         * This is implemented by looking at the repository updates
+         * tag.
+         * \see http://en.opensuse.org/Standards/Rpm_Metadata#SUSE_repository_info_.28suseinfo.xml.29.2C_extensions_to_repomd.xml
          */
         bool isUpdateRepo() const;
 
         /**
          * wether the repository claims to update something \ref prod
-         * with key \ref cpename
+         * with key \ref cpeid
          *
-         * See http://cpe.mitre.org/ for more information on CPE
+         * \see zypp::Product::cpeId()
+         *
+         * See http://cpe.mitre.org/ for more information on the
+         * Common Platform Enumearation.
          */
-        bool providesUpdatesFor( const std::string &cpename ) const;
+        bool providesUpdatesFor( const std::string &cpeid ) const;
 
         /** Whether \ref Repository contains solvables. */
         bool solvablesEmpty() const;
@@ -173,6 +168,41 @@ namespace zypp
         SolvableIterator solvablesEnd() const;
 
     public:
+
+      /** Query class for Repository */
+      class ProductInfoIterator;
+
+      /**
+       * Get an iterator to the beginning of the repository
+       * compatible distros.
+       * \note This is only a hint. There is no guarantee that
+       * the repository is built for that product.
+       * \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;
+
+    public:
         /** Return any associated \ref RepoInfo. */
         RepoInfo info() const;
 
@@ -232,6 +262,17 @@ namespace zypp
         ::_Repo * get() const;
         /** Expert backdoor. */
         IdType id() const { return _id; }
+        /** libsolv internal priorities.
+         * Unlike the \ref RepoInfo priority which tries to be YUM conform
+         * (H[1-99]L), this one is the solvers internal priority representation.
+         * It is type \c int and as one might expect it, the higher the value
+         * the higher the priority. Subpriority is currently used to express
+         * media preferences (\see \ref MediaPriority).
+         */
+        //@{
+        int satInternalPriority() const;
+        int satInternalSubPriority() const;
+        //@}
     private:
 #ifndef SWIG // Swig treats it as syntax error
         friend base::SafeBool<Repository>::operator bool_type() const;
@@ -258,6 +299,59 @@ namespace zypp
     { return lhs.get() < rhs.get(); }
 
     ///////////////////////////////////////////////////////////////////
+    /**
+     * 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_( it, repo.compatibleWithProductBegin(), repo.compatibleWithProductEnd() )
+     * {
+     *   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                              // Reference
+    >
+    {
+      public:
+        ProductInfoIterator()
+        {}
+
+        /**
+         * 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 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; }
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
     //
     // CLASS NAME : Repository::EraseFromPool
     //
@@ -293,6 +387,7 @@ namespace zypp
            { repository_r.eraseFromPool(); }
     };
     ///////////////////////////////////////////////////////////////////
+
     ///////////////////////////////////////////////////////////////////
     namespace detail
     { /////////////////////////////////////////////////////////////////
@@ -301,57 +396,57 @@ namespace zypp
       //       CLASS NAME : RepositoryIterator
       //
       /** */
-       class RepositoryIterator : public boost::iterator_adaptor<
+      class RepositoryIterator : public boost::iterator_adaptor<
            RepositoryIterator                            // Derived
                           , ::_Repo **                   // Base
-                          , Repository                   // Value
+                           , Repository                   // Value
                           , boost::forward_traversal_tag // CategoryOrTraversal
                           , Repository                   // Reference
                             >
-       {
+      {
         public:
-           RepositoryIterator()
-               : RepositoryIterator::iterator_adaptor_( 0 )
-               {}
+          RepositoryIterator()
+          : RepositoryIterator::iterator_adaptor_( 0 )
+          {}
 
-           explicit RepositoryIterator( ::_Repo ** p )
-               : RepositoryIterator::iterator_adaptor_( p )
-               {}
+          explicit RepositoryIterator( ::_Repo ** p )
+          : RepositoryIterator::iterator_adaptor_( p )
+          {}
 
         private:
-           friend class boost::iterator_core_access;
-
-           Repository dereference() const
-               { return Repository( *base() ); }
-       };
-       ///////////////////////////////////////////////////////////////////
-       ///////////////////////////////////////////////////////////////////
-       //
-       //      CLASS NAME : ByRepository
-       //
-       /** Functor filtering \ref Solvable by \ref Repository.*/
-       struct ByRepository
-       {
+          friend class boost::iterator_core_access;
+
+          Repository dereference() const
+          { return Repository( *base() ); }
+      };
+      ///////////////////////////////////////////////////////////////////
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       CLASS NAME : ByRepository
+      //
+      /** Functor filtering \ref Solvable by \ref Repository.*/
+      struct ByRepository
+      {
         public:
-           ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
-           ByRepository( sat::detail::RepoIdType id_r ) : _repository( id_r ) {}
-           ByRepository() {}
+          ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
+          ByRepository( sat::detail::RepoIdType id_r ) : _repository( id_r ) {}
+          ByRepository() {}
 
-           bool operator()( const sat::Solvable & slv_r ) const
-               { return slv_r.repository() == _repository; }
+          bool operator()( const sat::Solvable & slv_r ) const
+          { return slv_r.repository() == _repository; }
 
         private:
-           Repository _repository;
-       };
-       ///////////////////////////////////////////////////////////////////
-       /////////////////////////////////////////////////////////////////
+          Repository _repository;
+      };
+      ///////////////////////////////////////////////////////////////////
+      /////////////////////////////////////////////////////////////////
     } // namespace detail
     ///////////////////////////////////////////////////////////////////
-
-    /////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
 
-#include "zypp/sat/LookupAttr.h"
+// Late include as sat::ArrayAttr requires Repository.h
+#include "zypp/sat/LookupAttrTools.h"
 
 #endif // ZYPP_SAT_REPOSITORY_H