libzypp  15.28.6
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 
20 namespace zypp
21 {
22 
23 
24  DEFINE_PTR_TYPE(Patch);
25 
26 
36  class Patch : public ResObject
37  {
38  public:
39  typedef Patch Self;
43 
44  public:
46 
47  enum Category {
48  CAT_OTHER = 1,
49  CAT_YAST = 1<<1,
50  CAT_SECURITY = 1<<2,
51  CAT_RECOMMENDED = 1<<3,
52  CAT_OPTIONAL = 1<<4,
53  CAT_DOCUMENT = 1<<5
54  };
55  ZYPP_DECLARE_FLAGS(Categories, Category);
56 
62  NoFlags = 0x0000,
63  Reboot = 0x0001,
64  Message = 0x0002,
65  License = 0x0004
66  };
67  ZYPP_DECLARE_FLAGS(InteractiveFlags, InteractiveFlag);
68 
75  enum SeverityFlag {
76  SEV_OTHER = 1,
77  SEV_NONE = 1<<1,
78  SEV_LOW = 1<<2,
79  SEV_MODERATE = 1<<3,
80  SEV_IMPORTANT = 1<<4,
81  SEV_CRITICAL = 1<<5
82  };
83  ZYPP_DECLARE_FLAGS(SeverityFlags, SeverityFlag);
84 
85  public:
90  Date timestamp() const
91  { return buildtime(); }
92 
98  std::string category() const;
99 
103  Category categoryEnum() const;
104 
106  bool isCategory( const std::string & category_r ) const;
108  bool isCategory( Categories category_r ) const;
109 #ifndef SWIG // Swig treats it as syntax error
110 
113  template <class TContainer, typename = typename TContainer::value_type>
114  bool isCategory( const TContainer & categories_r ) const
115  {
116  for ( const std::string & el : categories_r )
117  { if ( isCategory( el ) ) return true; }
118  return false;
119  }
120 #endif
121 
124  static Category categoryEnum( const std::string & category_r );
126 
133  std::string severity() const;
134 
139  SeverityFlag severityFlag() const;
140 
142  bool isSeverity( const std::string & severity_r ) const;
144  bool isSeverity( SeverityFlags severity_r ) const;
145 #ifndef SWIG // Swig treats it as syntax error
146 
149  template <class TContainer, typename = typename TContainer::value_type>
150  bool isSeverity( const TContainer & severities_r ) const
151  {
152  for ( const std::string & el : severities_r )
153  { if ( isSeverity( el ) ) return true; }
154  return false;
155  }
156 #endif
157 
160  static SeverityFlag severityFlag( const std::string & category_r );
162 
166  bool rebootSuggested() const;
167 
172  bool restartSuggested() const;
173 
178  bool reloginSuggested() const;
179 
183  std::string message( const Locale & lang_r = Locale() ) const;
184 
188  InteractiveFlags interactiveFlags() const;
189 
193  bool interactiveWhenIgnoring( InteractiveFlags flags_r = NoFlags ) const;
194 
205  bool interactive() const;
206 
207  public:
211  Contents contents() const;
212 
213  public:
214 
216  class ReferenceIterator;
221  ReferenceIterator referencesBegin() const;
226  ReferenceIterator referencesEnd() const;
227 
228  protected:
229  friend Ptr make<Self>( const sat::Solvable & solvable_r );
231  Patch( const sat::Solvable & solvable_r );
233  virtual ~Patch();
234  };
235  ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Patch::Categories);
236  ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Patch::InteractiveFlags);
237  ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Patch::SeverityFlags);
238 
240  std::string asString( const Patch::Category & obj );
241 
243  std::string asString( const Patch::InteractiveFlag & obj );
244 
246  std::string asString( const Patch::SeverityFlag & obj );
247 
268  class Patch::ReferenceIterator : public boost::iterator_adaptor<
269  Patch::ReferenceIterator // Derived
270  , sat::LookupAttr::iterator // Base
271  , int // Value
272  , boost::forward_traversal_tag // CategoryOrTraversal
273  , int // Reference
274  >
275  {
276  public:
278  explicit ReferenceIterator( const sat::Solvable & val_r );
279 
284  std::string id() const;
288  std::string href() const;
292  std::string title() const;
297  std::string type() const;
298 
299  private:
301  int dereference() const { return 0; }
302  };
303 
305  { return ReferenceIterator(satSolvable()); }
306 
308  { return ReferenceIterator(); }
309 
311 
312 } // namespace zypp
314 #endif // ZYPP_PATCH_H
std::string asString(const Patch::Category &obj)
Definition: Patch.cc:117
virtual ~Patch()
Dtor.
Definition: Patch.cc:41
A Solvable object within the sat Pool.
Definition: Solvable.h:53
SeverityFlag
Possible severity levels for (security) patches.
Definition: Patch.h:75
intrusive_ptr< const TRes > constPtrType
Definition: ResTraits.h:83
std::string type() const
Type of the reference.
Definition: Patch.cc:343
ResTraits< Self > TraitsType
Definition: Patch.h:40
std::string href() const
Url or pointer where to find more information.
Definition: Patch.cc:339
unknown value specified
Definition: Patch.h:76
Date timestamp() const
Issue date time.
Definition: Patch.h:90
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(DiskUsageCounter::MountPoint::HintFlags)
Category categoryEnum() const
This patch's category as enum of wellknown categories.
Definition: Patch.cc:49
std::string category() const
Patch category (recommended, security,...)
Definition: Patch.cc:46
Contents contents() const
The collection of packages associated with this patch.
Definition: Patch.cc:271
ResTraits.
Definition: ResTraits.h:79
Class representing a patch.
Definition: Patch.h:36
no value specified
Definition: Patch.h:77
bool interactiveWhenIgnoring(InteractiveFlags flags_r=NoFlags) const
Is the patch still interactive when ignoring this flags?
Definition: Patch.cc:242
bool isCategory(const std::string &category_r) const
Whether this patch's category matches category_r.
Definition: Patch.cc:52
SeverityFlag severityFlag() const
Severity string mapped to an enum.
Definition: Patch.cc:137
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:268
DEFINE_PTR_TYPE(Application)
bool isSeverity(const std::string &severity_r) const
Whether this patch's severity matches severity_r.
Definition: Patch.cc:140
std::string title() const
Title describing the issue.
Definition: Patch.cc:341
sat::SolvableSet Contents
Definition: Patch.h:45
int dereference() const
Definition: Patch.h:301
ReferenceIterator referencesBegin() const
Get an iterator to the beginning of the patch references.
Definition: Patch.h:304
Patch(const sat::Solvable &solvable_r)
Ctor.
Definition: Patch.cc:32
Patch Self
Definition: Patch.h:39
ZYPP_DECLARE_FLAGS(Categories, Category)
TraitsType::constPtrType constPtr
Definition: Patch.h:42
Base for resolvable objects.
Definition: ResObject.h:38
intrusive_ptr< TRes > PtrType
Definition: ResTraits.h:82
unknown value specified
Definition: Patch.h:48
'Language[_Country]' codes.
Definition: Locale.h:49
InteractiveFlag
Flags defining if and why this patch is interactive.
Definition: Patch.h:61
std::string message(const Locale &lang_r=Locale()) const
Information or warning to be displayed to the user.
Definition: Patch.cc:206
bool reloginSuggested() const
Does the patch needs the user to relogin to take effect? relogin is suggested then.
Definition: Patch.cc:215
friend class boost::iterator_core_access
Definition: Patch.h:300
bool interactive() const
Is the patch installation interactive? (does it need user input?)
Definition: Patch.cc:254
bool rebootSuggested() const
Does the system need to reboot to finish the update process?
Definition: Patch.cc:209
std::string id() const
The id of the reference.
Definition: Patch.cc:337
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
ReferenceIterator referencesEnd() const
Get an iterator to the end of the patch references.
Definition: Patch.h:307
std::string severity() const
Severity string as specified in metadata.
Definition: Patch.cc:134
bool isSeverity(const TContainer &severities_r) const
Definition: Patch.h:150
bool restartSuggested() const
Does the patch affect the package manager itself? restart is suggested then.
Definition: Patch.cc:212
InteractiveFlags interactiveFlags() const
Get the InteractiveFlags of this Patch.
Definition: Patch.cc:218
bool isCategory(const TContainer &categories_r) const
Definition: Patch.h:114
TraitsType::PtrType Ptr
Definition: Patch.h:41
Solvable set wrapper to allow adding additioanal convenience iterators.
Definition: SolvableSet.h:35