1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
15 #include "zypp/sat/SolvAttr.h"
16 #include "zypp/ResObject.h"
18 ///////////////////////////////////////////////////////////////////
20 { /////////////////////////////////////////////////////////////////
23 DEFINE_PTR_TYPE(Patch);
27 * Class representing a patch.
29 * A patch represents a specific problem that
30 * can be fixed by pulling in the patch dependencies.
32 * Patches can be marked for installation but their
33 * installation is a no-op.
35 class Patch : public ResObject
39 typedef ResTraits<Self> TraitsType;
40 typedef TraitsType::PtrType Ptr;
41 typedef TraitsType::constPtrType constPtr;
44 typedef sat::SolvableSet Contents;
57 * Issue date time. For now it is the same as
60 Date timestamp() const
61 { return buildtime(); }
64 * Patch category (recommended, security,...)
66 std::string category() const;
68 /** Patch category as enum of wellknown categories.
69 * Unknown values are mapped to \ref CAT_OTHER.
71 Category categoryEnum() const;
74 * Does the system need to reboot to finish the update process?
76 bool rebootSuggested() const;
79 * Does the patch affect the package manager itself?
80 * restart is suggested then
82 bool restartSuggested() const;
85 * Does the patch needs the user to relogin to take effect?
86 * relogin is suggested then
88 bool reloginSuggested() const;
91 * \short Information or warning to be displayed to the user
93 std::string message( const Locale & lang_r = Locale() ) const;
96 * Is the patch installation interactive? (does it need user input?)
98 bool interactive() const;
102 * The collection of packages associated with this patch.
104 Contents contents() const;
108 /** Query class for Patch issue references */
109 class ReferenceIterator;
111 * Get an iterator to the beginning of the patch
112 * references. \see Patch::ReferenceIterator
114 ReferenceIterator referencesBegin() const;
116 * Get an iterator to the end of the patch
117 * references. \see Patch::ReferenceIterator
119 ReferenceIterator referencesEnd() const;
122 friend Ptr make<Self>( const sat::Solvable & solvable_r );
124 Patch( const sat::Solvable & solvable_r );
131 * Query class for Patch issue references
132 * like bugzilla and security issues the
133 * patch is supposed to fix.
135 * The iterator does not provide a dereference
136 * operator so you can do * on it, but you can
137 * access the attributes of each patch issue reference
138 * directly from the iterator.
141 * for ( Patch::ReferenceIterator it = patch->referencesBegin();
142 * it != patch->referencesEnd();
145 * cout << it.href() << endl;
150 class Patch::ReferenceIterator : public boost::iterator_adaptor<
151 Patch::ReferenceIterator // Derived
152 , sat::LookupAttr::iterator // Base
154 , boost::forward_traversal_tag // CategoryOrTraversal
159 ReferenceIterator() {}
160 explicit ReferenceIterator( const sat::Solvable & val_r );
163 * The id of the reference. For bugzilla entries
164 * this is the bug number as a string.
166 std::string id() const;
168 * Url or pointer where to find more information
170 std::string href() const;
172 * Title describing the issue
174 std::string title() const;
176 * Type of the reference. For example
179 std::string type() const;
182 friend class boost::iterator_core_access;
183 int dereference() const { return 0; }
186 inline Patch::ReferenceIterator Patch::referencesBegin() const
187 { return ReferenceIterator(satSolvable()); }
189 inline Patch::ReferenceIterator Patch::referencesEnd() const
190 { return ReferenceIterator(); }
192 /////////////////////////////////////////////////////////////////
195 ///////////////////////////////////////////////////////////////////
196 #endif // ZYPP_PATCH_H