libzypp: zypp/Patch.h Source File

libzypp 17.25.10

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>
18 #include <zypp/sat/SolvableSet.h>
19
21 namespace zypp
22 {
23
24
25 DEFINE_PTR_TYPE(Patch);
26
27
37 class Patch : public ResObject
38 {
39 public:
40 typedef Patch Self;
41 typedef ResTraits<Self> TraitsType;
42 typedef TraitsType::PtrType Ptr;
43 typedef TraitsType::constPtrType constPtr;
44
45 public:
46 typedef sat::SolvableSet Contents;
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
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
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 virtual ~Patch();
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 );
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:
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
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:50
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::TraitsType
ResTraits< Self > TraitsType
Definition: Patch.h:41
zypp::Patch::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(SeverityFlags, SeverityFlag)
zypp::Patch::categoryEnum
Category categoryEnum() const
This patch's category as enum of wellknown categories.
Definition: Patch.cc:49
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::constPtr
TraitsType::constPtrType constPtr
Definition: Patch.h:43
zypp::Patch::interactive
bool interactive() const
Is the patch installation interactive? (does it need user input?)
Definition: Patch.cc:259
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::interactiveFlags
InteractiveFlags interactiveFlags() const
Get the InteractiveFlags of this Patch.
Definition: Patch.cc:223
zypp::Patch::severity
std::string severity() const
Severity string as specified in metadata.
Definition: Patch.cc:139
zypp::Patch::category
std::string category() const
Patch category (recommended, security,...)
Definition: Patch.cc:46
zypp::Patch::isCategory
bool isCategory(const TContainer &categories_r) const
Definition: Patch.h:115
zypp::Patch::Ptr
TraitsType::PtrType Ptr
Definition: Patch.h:42
zypp::Patch::rebootSuggested
bool rebootSuggested() const
Does the system need to reboot to finish the update process?
Definition: Patch.cc:214
zypp::Patch::reloginSuggested
bool reloginSuggested() const
Does the patch needs the user to relogin to take effect? relogin is suggested then.
Definition: Patch.cc:220
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::contents
Contents contents() const
The collection of packages associated with this patch.
Definition: Patch.cc:276
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::~Patch
virtual ~Patch()
Dtor.
Definition: Patch.cc:41
zypp::Patch::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(InteractiveFlags, InteractiveFlag)
zypp::Patch::Self
Patch Self
Definition: Patch.h:40
zypp::Patch::message
std::string message(const Locale &lang_r=Locale()) const
Information or warning to be displayed to the user.
Definition: Patch.cc:211
zypp::Patch::timestamp
Date timestamp() const
Issue date time.
Definition: Patch.h:91
zypp::Patch::severityFlag
SeverityFlag severityFlag() const
Severity string mapped to an enum.
Definition: Patch.cc:142
zypp::Patch::restartSuggested
bool restartSuggested() const
Does the patch affect the package manager itself? restart is suggested then.
Definition: Patch.cc:217
zypp::Patch::Contents
sat::SolvableSet Contents
Definition: Patch.h:46
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::interactiveWhenIgnoring
bool interactiveWhenIgnoring(InteractiveFlags flags_r=NoFlags) const
Is the patch still interactive when ignoring this flags?
Definition: Patch.cc:247
zypp::Patch::referencesEnd
ReferenceIterator referencesEnd() const
Get an iterator to the end of the patch references.
Definition: Patch.h:308
zypp::ResObject
Base for resolvable objects.
Definition: ResObject.h:38
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::asString
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
Definition: DefaultIntegral.h:98
zypp::DEFINE_PTR_TYPE
DEFINE_PTR_TYPE(Application)
zypp::ZYPP_DECLARE_OPERATORS_FOR_FLAGS
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(DiskUsageCounter::MountPoint::HintFlags)
zypp::ResTraits
ResTraits.
Definition: ResTraits.h:80
zypp::ResTraits::constPtrType
intrusive_ptr< const TRes > constPtrType
Definition: ResTraits.h:83
zypp::ResTraits::PtrType
intrusive_ptr< TRes > PtrType
Definition: ResTraits.h:82
zypp::sat::SolvableType< Resolvable >::satSolvable
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
zypp::sat::SolvableType< Resolvable >::buildtime
Date buildtime() const
Definition: SolvableType.h:87