libzypp 17.31.23
Patch.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_PATCH_H
13#define ZYPP_PATCH_H
14
15#include <zypp/base/Flags.h>
16#include <zypp/sat/SolvAttr.h>
17#include <zypp/ResObject.h>
19
21namespace zypp
22{
23
24
26
27
37 class Patch : public ResObject
38 {
39 public:
40 typedef Patch Self;
44
45 public:
47
48 enum Category {
50 CAT_YAST = 1<<1,
51 CAT_SECURITY = 1<<2,
53 CAT_OPTIONAL = 1<<4,
54 CAT_DOCUMENT = 1<<5
55 };
57
63 NoFlags = 0x0000,
64 Reboot = 0x0001,
65 Message = 0x0002,
66 License = 0x0004
67 };
69
78 SEV_NONE = 1<<1,
79 SEV_LOW = 1<<2,
80 SEV_MODERATE = 1<<3,
82 SEV_CRITICAL = 1<<5
83 };
85
86 public:
92 { return buildtime(); }
93
99 std::string category() const;
100
104 Category categoryEnum() const;
105
107 bool isCategory( const std::string & category_r ) const;
109 bool isCategory( Categories category_r ) const;
110
114 template <class TContainer, typename = typename TContainer::value_type>
115 bool isCategory( const TContainer & categories_r ) const
116 {
117 for ( const std::string & el : categories_r )
118 { if ( isCategory( el ) ) return true; }
119 return false;
120 }
121
125 static Category categoryEnum( const std::string & category_r );
127
134 std::string severity() const;
135
141
143 bool isSeverity( const std::string & severity_r ) const;
145 bool isSeverity( SeverityFlags severity_r ) const;
146
150 template <class TContainer, typename = typename TContainer::value_type>
151 bool isSeverity( const TContainer & severities_r ) const
152 {
153 for ( const std::string & el : severities_r )
154 { if ( isSeverity( el ) ) return true; }
155 return false;
156 }
157
161 static SeverityFlag severityFlag( const std::string & category_r );
163
167 bool rebootSuggested() const;
168
173 bool restartSuggested() const;
174
179 bool reloginSuggested() const;
180
184 std::string message( const Locale & lang_r = Locale() ) const;
185
189 InteractiveFlags interactiveFlags() const;
190
194 bool interactiveWhenIgnoring( InteractiveFlags flags_r = NoFlags ) const;
195
206 bool interactive() const;
207
208 public:
212 Contents contents() const;
213
214 public:
215
217 class ReferenceIterator;
222 ReferenceIterator referencesBegin() const;
227 ReferenceIterator referencesEnd() const;
228
229 protected:
230 friend Ptr make<Self>( const sat::Solvable & solvable_r );
232 Patch( const sat::Solvable & solvable_r );
234 virtual ~Patch();
235 };
237 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Patch::InteractiveFlags);
238 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Patch::SeverityFlags);
239
241 std::string asString( const Patch::Category & obj );
242
244 std::string asString( const Patch::InteractiveFlag & obj );
245
247 std::string asString( const Patch::SeverityFlag & obj );
248
269 class Patch::ReferenceIterator : public boost::iterator_adaptor<
270 Patch::ReferenceIterator // Derived
271 , sat::LookupAttr::iterator // Base
272 , int // Value
273 , boost::forward_traversal_tag // CategoryOrTraversal
274 , int // Reference
275 >
276 {
277 public:
279 explicit ReferenceIterator( const sat::Solvable & val_r );
280
285 std::string id() const;
289 std::string href() const;
293 std::string title() const;
298 std::string type() const;
299
300 private:
302 int dereference() const { return 0; }
303 };
304
306 { return ReferenceIterator(satSolvable()); }
307
309 { return ReferenceIterator(); }
310
312
313} // namespace zypp
315#endif // ZYPP_PATCH_H
Store and operate on date (time_t).
Definition: Date.h:33
'Language[_Country]' codes.
Definition: Locale.h:50
Query class for Patch issue references like bugzilla and security issues the patch is supposed to fix...
Definition: Patch.h:276
std::string title() const
Title describing the issue.
Definition: Patch.cc:346
friend class boost::iterator_core_access
Definition: Patch.h:301
std::string id() const
The id of the reference.
Definition: Patch.cc:342
std::string href() const
Url or pointer where to find more information.
Definition: Patch.cc:344
std::string type() const
Type of the reference.
Definition: Patch.cc:348
Class representing a patch.
Definition: Patch.h:38
ResTraits< Self > TraitsType
Definition: Patch.h:41
ZYPP_DECLARE_FLAGS(SeverityFlags, SeverityFlag)
Category categoryEnum() const
This patch's category as enum of wellknown categories.
Definition: Patch.cc:49
bool isSeverity(const std::string &severity_r) const
Whether this patch's severity matches severity_r.
Definition: Patch.cc:145
TraitsType::constPtrType constPtr
Definition: Patch.h:43
bool interactive() const
Is the patch installation interactive? (does it need user input?)
Definition: Patch.cc:259
InteractiveFlag
Flags defining if and why this patch is interactive.
Definition: Patch.h:62
@ License
Definition: Patch.h:66
@ Message
Definition: Patch.h:65
@ Reboot
Definition: Patch.h:64
@ NoFlags
Definition: Patch.h:63
SeverityFlag
Possible severity levels for (security) patches.
Definition: Patch.h:76
@ SEV_CRITICAL
Critical.
Definition: Patch.h:82
@ SEV_LOW
Low.
Definition: Patch.h:79
@ SEV_MODERATE
Moderate.
Definition: Patch.h:80
@ SEV_NONE
no value specified
Definition: Patch.h:78
@ SEV_IMPORTANT
Important.
Definition: Patch.h:81
@ SEV_OTHER
unknown value specified
Definition: Patch.h:77
InteractiveFlags interactiveFlags() const
Get the InteractiveFlags of this Patch.
Definition: Patch.cc:223
std::string severity() const
Severity string as specified in metadata.
Definition: Patch.cc:139
std::string category() const
Patch category (recommended, security,...)
Definition: Patch.cc:46
bool isCategory(const TContainer &categories_r) const
Definition: Patch.h:115
TraitsType::PtrType Ptr
Definition: Patch.h:42
bool rebootSuggested() const
Does the system need to reboot to finish the update process?
Definition: Patch.cc:214
bool reloginSuggested() const
Does the patch needs the user to relogin to take effect? relogin is suggested then.
Definition: Patch.cc:220
ReferenceIterator referencesBegin() const
Get an iterator to the beginning of the patch references.
Definition: Patch.h:305
bool isCategory(const std::string &category_r) const
Whether this patch's category matches category_r.
Definition: Patch.cc:52
Contents contents() const
The collection of packages associated with this patch.
Definition: Patch.cc:276
@ CAT_DOCUMENT
Definition: Patch.h:54
@ CAT_YAST
Definition: Patch.h:50
@ CAT_RECOMMENDED
Definition: Patch.h:52
@ CAT_OTHER
unknown value specified
Definition: Patch.h:49
@ CAT_OPTIONAL
Definition: Patch.h:53
@ CAT_SECURITY
Definition: Patch.h:51
bool isSeverity(const TContainer &severities_r) const
Definition: Patch.h:151
virtual ~Patch()
Dtor.
Definition: Patch.cc:41
ZYPP_DECLARE_FLAGS(InteractiveFlags, InteractiveFlag)
Patch Self
Definition: Patch.h:40
std::string message(const Locale &lang_r=Locale()) const
Information or warning to be displayed to the user.
Definition: Patch.cc:211
Date timestamp() const
Issue date time.
Definition: Patch.h:91
SeverityFlag severityFlag() const
Severity string mapped to an enum.
Definition: Patch.cc:142
bool restartSuggested() const
Does the patch affect the package manager itself? restart is suggested then.
Definition: Patch.cc:217
sat::SolvableSet Contents
Definition: Patch.h:46
ZYPP_DECLARE_FLAGS(Categories, Category)
bool interactiveWhenIgnoring(InteractiveFlags flags_r=NoFlags) const
Is the patch still interactive when ignoring this flags?
Definition: Patch.cc:247
ReferenceIterator referencesEnd() const
Get an iterator to the end of the patch references.
Definition: Patch.h:308
Base for resolvable objects.
Definition: ResObject.h:38
Solvable set wrapper to allow adding additional convenience iterators.
Definition: SolvableSet.h:36
A Solvable object within the sat Pool.
Definition: Solvable.h:54
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
ResTraits.
Definition: ResTraits.h:80
intrusive_ptr< const TRes > constPtrType
Definition: ResTraits.h:83
intrusive_ptr< TRes > PtrType
Definition: ResTraits.h:82
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition: Flags.h:177
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition: PtrTypes.h:623