libzypp: zypp/Patch.h Source File

libzypp 17.38.7

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-core/base/Flags.h>
16#include <zypp/sat/SolvAttr.h>
17#include <zypp/ResObject.h>
18#include <zypp/sat/SolvableSet.h>
19
21namespace zypp
22{
23
24
25 DEFINE_PTR_TYPE(Patch);
26
27
37 class ZYPP_API Patch : public ResObject
38 {
39 public:
40 using Self = Patch;
41 using TraitsType = ResTraits<Self>;
42 using Ptr = TraitsType::PtrType;
43 using constPtr = TraitsType::constPtrType;
44
45 public:
46 using Contents = sat::SolvableSet;
47
48 enum Category {
49 CAT_OTHER = 1,
50 CAT_YAST = 1<<1,
51 CAT_SECURITY = 1<<2,
52 CAT_RECOMMENDED = 1<<3,
53 CAT_OPTIONAL = 1<<4,
54 CAT_DOCUMENT = 1<<5
55 };
56 ZYPP_DECLARE_FLAGS(Categories, Category);
57
62 enum InteractiveFlag {
63 NoFlags = 0x0000,
64 Reboot = 0x0001,
65 Message = 0x0002,
66 License = 0x0004
67 };
68 ZYPP_DECLARE_FLAGS(InteractiveFlags, InteractiveFlag);
69
76 enum SeverityFlag {
77 SEV_OTHER = 1,
78 SEV_NONE = 1<<1,
79 SEV_LOW = 1<<2,
80 SEV_MODERATE = 1<<3,
81 SEV_IMPORTANT = 1<<4,
82 SEV_CRITICAL = 1<<5
83 };
84 ZYPP_DECLARE_FLAGS(SeverityFlags, SeverityFlag);
85
86 public:
91 Date timestamp() const
92 { return buildtime(); }
93
96
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
130
134 std::string severity() const;
135
140 SeverityFlag severityFlag() const;
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 ~Patch() override;
235 };
236 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Patch::Categories);
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 ) ZYPP_API;
242
244 std::string asString( const Patch::InteractiveFlag & obj ) ZYPP_API;
245
247 std::string asString( const Patch::SeverityFlag & obj ) ZYPP_API;
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:
278 ReferenceIterator() {}
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:
301 friend class boost::iterator_core_access;
302 int dereference() const { return 0; }
303 };
304
305 inline Patch::ReferenceIterator Patch::referencesBegin() const
306 { return ReferenceIterator(satSolvable()); }
307
308 inline Patch::ReferenceIterator Patch::referencesEnd() const
309 { return ReferenceIterator(); }
310
312
313} // namespace zypp
315#endif // ZYPP_PATCH_H
Flags.h
ZYPP_DECLARE_OPERATORS_FOR_FLAGS
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
relates: Flags
Definition Flags.h:177
DEFINE_PTR_TYPE
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:639
ResObject.h
SolvAttr.h
SolvableSet.h
zypp::Date
Store and operate on date (time_t).
Definition Date.h:33
zypp::Locale
'Language[_Country]' codes.
Definition Locale.h:51
zypp::Patch::ReferenceIterator
Query class for Patch issue references like bugzilla and security issues the patch is supposed to fix...
Definition Patch.h:276
zypp::Patch::ReferenceIterator::title
std::string title() const
Title describing the issue.
Definition Patch.cc:346
zypp::Patch::ReferenceIterator::ReferenceIterator
ReferenceIterator()
Definition Patch.h:278
zypp::Patch::ReferenceIterator::iterator_core_access
friend class boost::iterator_core_access
Definition Patch.h:301
zypp::Patch::ReferenceIterator::id
std::string id() const
The id of the reference.
Definition Patch.cc:342
zypp::Patch::ReferenceIterator::dereference
int dereference() const
Definition Patch.h:302
zypp::Patch::ReferenceIterator::href
std::string href() const
Url or pointer where to find more information.
Definition Patch.cc:344
zypp::Patch::ReferenceIterator::type
std::string type() const
Type of the reference.
Definition Patch.cc:348
zypp::Patch
Class representing a patch.
Definition Patch.h:38
zypp::Patch::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(SeverityFlags, SeverityFlag)
zypp::Patch::isSeverity
bool isSeverity(const std::string &severity_r) const
Whether this patch's severity matches severity_r.
Definition Patch.cc:145
zypp::Patch::InteractiveFlag
InteractiveFlag
Flags defining if and why this patch is interactive.
Definition Patch.h:62
zypp::Patch::License
@ License
Definition Patch.h:66
zypp::Patch::Message
@ Message
Definition Patch.h:65
zypp::Patch::Reboot
@ Reboot
Definition Patch.h:64
zypp::Patch::NoFlags
@ NoFlags
Definition Patch.h:63
zypp::Patch::SeverityFlag
SeverityFlag
Possible severity levels for (security) patches.
Definition Patch.h:76
zypp::Patch::SEV_CRITICAL
@ SEV_CRITICAL
Critical.
Definition Patch.h:82
zypp::Patch::SEV_LOW
@ SEV_LOW
Low.
Definition Patch.h:79
zypp::Patch::SEV_MODERATE
@ SEV_MODERATE
Moderate.
Definition Patch.h:80
zypp::Patch::SEV_NONE
@ SEV_NONE
no value specified
Definition Patch.h:78
zypp::Patch::SEV_IMPORTANT
@ SEV_IMPORTANT
Important.
Definition Patch.h:81
zypp::Patch::SEV_OTHER
@ SEV_OTHER
unknown value specified
Definition Patch.h:77
zypp::Patch::constPtr
TraitsType::constPtrType constPtr
Definition Patch.h:43
zypp::Patch::TraitsType
ResTraits< Self > TraitsType
Definition Patch.h:41
zypp::Patch::isCategory
bool isCategory(const TContainer &categories_r) const
Definition Patch.h:115
zypp::Patch::Contents
sat::SolvableSet Contents
Definition Patch.h:46
zypp::Patch::referencesBegin
ReferenceIterator referencesBegin() const
Get an iterator to the beginning of the patch references.
Definition Patch.h:305
zypp::Patch::isCategory
bool isCategory(const std::string &category_r) const
Whether this patch's category matches category_r.
Definition Patch.cc:52
zypp::Patch::Category
Category
Definition Patch.h:48
zypp::Patch::CAT_DOCUMENT
@ CAT_DOCUMENT
Definition Patch.h:54
zypp::Patch::CAT_YAST
@ CAT_YAST
Definition Patch.h:50
zypp::Patch::CAT_RECOMMENDED
@ CAT_RECOMMENDED
Definition Patch.h:52
zypp::Patch::CAT_OTHER
@ CAT_OTHER
unknown value specified
Definition Patch.h:49
zypp::Patch::CAT_OPTIONAL
@ CAT_OPTIONAL
Definition Patch.h:53
zypp::Patch::CAT_SECURITY
@ CAT_SECURITY
Definition Patch.h:51
zypp::Patch::isSeverity
bool isSeverity(const TContainer &severities_r) const
Definition Patch.h:151
zypp::Patch::Self
Patch Self
Definition Patch.h:40
zypp::Patch::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(InteractiveFlags, InteractiveFlag)
zypp::Patch::timestamp
Date timestamp() const
Issue date time.
Definition Patch.h:91
zypp::Patch::Patch
Patch(const sat::Solvable &solvable_r)
Ctor.
Definition Patch.cc:32
zypp::Patch::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(Categories, Category)
zypp::Patch::Ptr
TraitsType::PtrType Ptr
Definition Patch.h:42
zypp::Patch::referencesEnd
ReferenceIterator referencesEnd() const
Get an iterator to the end of the patch references.
Definition Patch.h:308
zypp::ResObject::ResObject
ResObject(const sat::Solvable &solvable_r)
Ctor.
Definition ResObject.cc:23
zypp::sat::SolvableSet
Solvable set wrapper to allow adding additional convenience iterators.
Definition SolvableSet.h:36
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::make
ResTraits< TRes >::PtrType make(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition ResObject.h:118
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173
zypp::asString
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
Definition Patch.cc:122
zypp::ResTraits
ResTraits.
Definition ResTraits.h:80
zypp::ResTraits< Self >::PtrType
intrusive_ptr< Self > PtrType
Definition ResTraits.h:82
zypp::ResTraits< Self >::constPtrType
intrusive_ptr< const Self > constPtrType
Definition ResTraits.h:83
zypp::sat::SolvableType< Resolvable >::satSolvable
Solvable satSolvable() const
Definition SolvableType.h:57
zypp::sat::SolvableType< Resolvable >::buildtime
Date buildtime() const
Definition SolvableType.h:96