Mailinglist Archive: zypp-commit (606 mails)

< Previous Next >
[zypp-commit] r9486 - in /trunk/libzypp/zypp: Patch.cc Patch.h
  • From: dmacvicar@xxxxxxxxxxxxxxxx
  • Date: Wed, 09 Apr 2008 14:41:28 -0000
  • Message-id: <20080409144128.518C02D271@xxxxxxxxxxxxxxxx>
Author: dmacvicar
Date: Wed Apr 9 16:41:27 2008
New Revision: 9486

URL: http://svn.opensuse.org/viewcvs/zypp?rev=9486&view=rev
Log:
API for retrieving bugzilla and security references using a nice iterator
(thanks
Michael for the tips)

The implementation needs to fix the attribute names

Modified:
trunk/libzypp/zypp/Patch.cc
trunk/libzypp/zypp/Patch.h

Modified: trunk/libzypp/zypp/Patch.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Patch.cc?rev=9486&r1=9485&r2=9486&view=diff
==============================================================================
--- trunk/libzypp/zypp/Patch.cc (original)
+++ trunk/libzypp/zypp/Patch.cc Wed Apr 9 16:41:27 2008
@@ -79,5 +79,51 @@
}

/////////////////////////////////////////////////////////////////
+
+
+ Patch::ReferenceIterator::ReferenceIterator()
+ {}
+
+ Patch::ReferenceIterator::ReferenceIterator( const sat::Solvable & val_r )
+ {
+ base_reference() = sat::LookupAttr(
sat::SolvAttr("update::referenceid"),
+ val_r ).begin();
+ _hrefit = sat::LookupAttr( sat::SolvAttr("update::referencehref"),
+ val_r ).begin();
+ _titleit = sat::LookupAttr( sat::SolvAttr("update::referencetitle"),
+ val_r ).begin();
+ _typeit = sat::LookupAttr( sat::SolvAttr("update::referencetype"),
+ val_r ).begin();
+ }
+
+
+ std::string Patch::ReferenceIterator::id() const
+ { return base_reference().asString(); }
+ std::string Patch::ReferenceIterator::href() const
+ { return _hrefit.asString(); }
+ std::string Patch::ReferenceIterator::title() const
+ { return _titleit.asString(); }
+ std::string Patch::ReferenceIterator::type() const
+ { return _typeit.asString(); }
+
+
+
+ int Patch::ReferenceIterator::dereference() const
+ { return 0; }
+
+ void Patch::ReferenceIterator::increment()
+ {
+ ++base_reference();
+ ++_hrefit;
+ ++_titleit;
+ ++_typeit;
+ }
+
+ inline Patch::ReferenceIterator Patch::referencesBegin() const
+ { return ReferenceIterator(satSolvable()); }
+ inline Patch::ReferenceIterator Patch::referencesEnd() const
+ { return ReferenceIterator(); }
+
+
} // namespace zypp
///////////////////////////////////////////////////////////////////

Modified: trunk/libzypp/zypp/Patch.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Patch.h?rev=9486&r1=9485&r2=9486&view=diff
==============================================================================
--- trunk/libzypp/zypp/Patch.h (original)
+++ trunk/libzypp/zypp/Patch.h Wed Apr 9 16:41:27 2008
@@ -12,22 +12,26 @@
#ifndef ZYPP_PATCH_H
#define ZYPP_PATCH_H

+#include "zypp/sat/SolvAttr.h"
#include "zypp/ResObject.h"

///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////

+
DEFINE_PTR_TYPE(Patch);

- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : Patch
- //
- /** Class representing a patch.
- * \todo Patch::atoms can't be const, if Impl does not
- * provide a const method. Check it.
- */
+
+ /**
+ * Class representing a patch.
+ *
+ * A patch represents a specific problem that
+ * can be fixed by pulling in the patch dependencies.
+ *
+ * Patches can be marked for installation but their
+ * installation is a no-op.
+ */
class Patch : public ResObject
{
public:
@@ -40,23 +44,114 @@
typedef sat::SolvableSet Contents;

public:
- /** Patch time stamp */
+ /**
+ * issue date time
+ */
Date timestamp() const
{ return buildtime(); }
- /** Patch category (recommended, security,...) */
+
+ /**
+ * Patch category (recommended, security,...)
+ */
std::string category() const;
- /** Does the system need to reboot to finish the update process? */
+
+ /**
+ * Does the system need to reboot to finish the update process?
+ */
bool reboot_needed() const;
- /** Does the patch affect the package manager itself? */
+
+ /**
+ * Does the patch affect the package manager itself?
+ */
bool affects_pkg_manager() const;
- /** Is the patch installation interactive? (does it need user input?) */
+
+ /**
+ * Is the patch installation interactive? (does it need user input?)
+ */
bool interactive() const;

public:
- /** The collection of packages associated with this patch. */
+ /**
+ * The collection of packages associated with this patch.
+ */
Contents contents() const;

public:
+
+ /**
+ * Query class for Patch issue references
+ * like bugzilla and security issues the
+ * patch is supposed to fix.
+ *
+ * The iterator does not provide a dereference
+ * operator so you can do * on it, but you can
+ * access the attributes of each patch issue reference
+ * directly from the iterator.
+ *
+ * \code
+ * for ( Patch::ReferenceIterator it = patch->referencesBegin();
+ * it != patch->referencesEnd();
+ * ++it )
+ * {
+ * cout << it.href() << endl;
+ * }
+ * \endcode
+ *
+ */
+ class ReferenceIterator : public boost::iterator_adaptor<
+ Patch::ReferenceIterator // Derived
+ , sat::LookupAttr::iterator // Base
+ , int // Value
+ , boost::forward_traversal_tag // CategoryOrTraversal
+ , int
+ >
+ {
+ public:
+ ReferenceIterator();
+ explicit ReferenceIterator( const sat::Solvable & val_r );
+
+ /**
+ * The id of the reference. For bugzilla entries
+ * this is the bug number as a string.
+ */
+ std::string id() const;
+ /**
+ * Url or ponter where to find more information
+ */
+ std::string href() const;
+ /**
+ * Title describing the issue
+ */
+ std::string title() const;
+ /**
+ * Type of the reference. For example
+ * "bugzilla"
+ */
+ std::string type() const;
+ private:
+ friend class boost::iterator_core_access;
+
+ int dereference() const;
+ void increment();
+ private:
+ sat::LookupAttr::iterator _hrefit;
+ sat::LookupAttr::iterator _titleit;
+ sat::LookupAttr::iterator _typeit;
+ };
+
+ /**
+ * Get an iterator to the beginning of the patch
+ * references. \see Patch::ReferenceIterator
+ */
+ ReferenceIterator referencesBegin() const;
+ /**
+ * Get an iterator to the end of the patch
+ * references. \see Patch::ReferenceIterator
+ */
+ ReferenceIterator referencesEnd() const;
+
+
+ public:
/** Patch ID
* \deprecated Seems to be unsused autobuild interal data?
*/
@@ -79,6 +174,7 @@
};

/////////////////////////////////////////////////////////////////
+
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_PATCH_H

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

< Previous Next >
This Thread
  • No further messages