libzypp  17.16.0
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;
44 
45  public:
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 
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 #ifndef SWIG // Swig treats it as syntax error
111 
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 #endif
122 
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 #ifndef SWIG // Swig treats it as syntax error
147 
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 #endif
158 
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:
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
virtual ~Patch()
Dtor.
Definition: Patch.cc:41
bool reloginSuggested() const
Does the patch needs the user to relogin to take effect? relogin is suggested then.
Definition: Patch.cc:215
A Solvable object within the sat Pool.
Definition: Solvable.h:53
SeverityFlag
Possible severity levels for (security) patches.
Definition: Patch.h:76
intrusive_ptr< const TRes > constPtrType
Definition: ResTraits.h:83
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
ResTraits< Self > TraitsType
Definition: Patch.h:41
std::string severity() const
Severity string as specified in metadata.
Definition: Patch.cc:134
unknown value specified
Definition: Patch.h:77
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(DiskUsageCounter::MountPoint::HintFlags)
std::string title() const
Title describing the issue.
Definition: Patch.cc:341
ResTraits.
Definition: ResTraits.h:79
Class representing a patch.
Definition: Patch.h:37
Category categoryEnum() const
This patch's category as enum of wellknown categories.
Definition: Patch.cc:49
no value specified
Definition: Patch.h:78
ReferenceIterator referencesEnd() const
Get an iterator to the end of the patch references.
Definition: Patch.h:308
ReferenceIterator referencesBegin() const
Get an iterator to the beginning of the patch references.
Definition: Patch.h:305
Store and operate on date (time_t).
Definition: Date.h:32
Query class for Patch issue references like bugzilla and security issues the patch is supposed to fix...
Definition: Patch.h:269
SeverityFlag severityFlag() const
Severity string mapped to an enum.
Definition: Patch.cc:137
std::string href() const
Url or pointer where to find more information.
Definition: Patch.cc:339
DEFINE_PTR_TYPE(Application)
bool interactive() const
Is the patch installation interactive? (does it need user input?)
Definition: Patch.cc:254
sat::SolvableSet Contents
Definition: Patch.h:46
std::string message(const Locale &lang_r=Locale()) const
Information or warning to be displayed to the user.
Definition: Patch.cc:206
bool isCategory(const std::string &category_r) const
Whether this patch's category matches category_r.
Definition: Patch.cc:52
Patch(const sat::Solvable &solvable_r)
Ctor.
Definition: Patch.cc:32
Patch Self
Definition: Patch.h:40
ZYPP_DECLARE_FLAGS(Categories, Category)
TraitsType::constPtrType constPtr
Definition: Patch.h:43
Base for resolvable objects.
Definition: ResObject.h:37
std::string id() const
The id of the reference.
Definition: Patch.cc:337
Contents contents() const
The collection of packages associated with this patch.
Definition: Patch.cc:271
intrusive_ptr< TRes > PtrType
Definition: ResTraits.h:82
InteractiveFlags interactiveFlags() const
Get the InteractiveFlags of this Patch.
Definition: Patch.cc:218
unknown value specified
Definition: Patch.h:49
'Language[_Country]' codes.
Definition: Locale.h:49
InteractiveFlag
Flags defining if and why this patch is interactive.
Definition: Patch.h:62
friend class boost::iterator_core_access
Definition: Patch.h:301
bool rebootSuggested() const
Does the system need to reboot to finish the update process?
Definition: Patch.cc:209
Date timestamp() const
Issue date time.
Definition: Patch.h:91
bool restartSuggested() const
Does the patch affect the package manager itself? restart is suggested then.
Definition: Patch.cc:212
bool isCategory(const TContainer &categories_r) const
Definition: Patch.h:115
bool isSeverity(const TContainer &severities_r) const
Definition: Patch.h:151
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
std::string category() const
Patch category (recommended, security,...)
Definition: Patch.cc:46
bool isSeverity(const std::string &severity_r) const
Whether this patch's severity matches severity_r.
Definition: Patch.cc:140
bool interactiveWhenIgnoring(InteractiveFlags flags_r=NoFlags) const
Is the patch still interactive when ignoring this flags?
Definition: Patch.cc:242
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
TraitsType::PtrType Ptr
Definition: Patch.h:42
std::string type() const
Type of the reference.
Definition: Patch.cc:343
Solvable set wrapper to allow adding additional convenience iterators.
Definition: SolvableSet.h:35