Cleanup and remove deprecated interface methods
[platform/upstream/libzypp.git] / zypp / Patch.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Patch.h
10  *
11 */
12 #ifndef ZYPP_PATCH_H
13 #define ZYPP_PATCH_H
14
15 #include "zypp/sat/SolvAttr.h"
16 #include "zypp/ResObject.h"
17
18 ///////////////////////////////////////////////////////////////////
19 namespace zypp
20 { /////////////////////////////////////////////////////////////////
21
22
23   DEFINE_PTR_TYPE(Patch);
24
25
26   /**
27    * Class representing a patch.
28    *
29    * A patch represents a specific problem that
30    * can be fixed by pulling in the patch dependencies.
31    *
32    * Patches can be marked for installation but their
33    * installation is a no-op.
34    */
35   class Patch : public ResObject
36   {
37     public:
38       typedef Patch                    Self;
39       typedef ResTraits<Self>          TraitsType;
40       typedef TraitsType::PtrType      Ptr;
41       typedef TraitsType::constPtrType constPtr;
42
43     public:
44       typedef sat::SolvableSet Contents;
45
46       enum Category {
47         CAT_OTHER,
48         CAT_YAST,
49         CAT_SECURITY,
50         CAT_RECOMMENDED,
51         CAT_OPTIONAL,
52         CAT_DOCUMENT
53       };
54
55     public:
56       /**
57        * Issue date time. For now it is the same as
58        * \ref buildtime().
59        */
60       Date timestamp() const
61       { return buildtime(); }
62
63       /**
64        * Patch category (recommended, security,...)
65        */
66       std::string category() const;
67
68       /** Patch category as enum of wellknown categories.
69        * Unknown values are mapped to \ref CAT_OTHER.
70        */
71       Category categoryEnum() const;
72
73       /**
74        * Does the system need to reboot to finish the update process?
75        */
76       bool rebootSuggested() const;
77
78       /**
79        * Does the patch affect the package manager itself?
80        * restart is suggested then
81        */
82       bool restartSuggested() const;
83
84       /**
85        * Does the patch needs the user to relogin to take effect?
86        * relogin is suggested then
87        */
88       bool reloginSuggested() const;
89
90       /**
91        * \short Information or warning to be displayed to the user
92        */
93       std::string message( const Locale & lang_r = Locale() ) const;
94
95       /**
96        * Is the patch installation interactive? (does it need user input?)
97        */
98       bool interactive() const;
99
100     public:
101       /**
102        * The collection of packages associated with this patch.
103        */
104       Contents contents() const;
105
106     public:
107
108       /** Query class for Patch issue references */
109       class ReferenceIterator;
110       /**
111        * Get an iterator to the beginning of the patch
112        * references. \see Patch::ReferenceIterator
113        */
114       ReferenceIterator referencesBegin() const;
115       /**
116        * Get an iterator to the end of the patch
117        * references. \see Patch::ReferenceIterator
118        */
119       ReferenceIterator referencesEnd() const;
120
121     protected:
122       friend Ptr make<Self>( const sat::Solvable & solvable_r );
123       /** Ctor */
124       Patch( const sat::Solvable & solvable_r );
125       /** Dtor */
126       virtual ~Patch();
127   };
128
129
130   /**
131    * Query class for Patch issue references
132    * like bugzilla and security issues the
133    * patch is supposed to fix.
134    *
135    * The iterator does not provide a dereference
136    * operator so you can do * on it, but you can
137    * access the attributes of each patch issue reference
138    * directly from the iterator.
139    *
140    * \code
141    * for ( Patch::ReferenceIterator it = patch->referencesBegin();
142    *       it != patch->referencesEnd();
143    *       ++it )
144    * {
145    *   cout << it.href() << endl;
146    * }
147    * \endcode
148    *
149    */
150   class Patch::ReferenceIterator : public boost::iterator_adaptor<
151       Patch::ReferenceIterator           // Derived
152       , sat::LookupAttr::iterator        // Base
153       , int                              // Value
154       , boost::forward_traversal_tag     // CategoryOrTraversal
155       , int                              // Reference
156   >
157   {
158     public:
159       ReferenceIterator() {}
160       explicit ReferenceIterator( const sat::Solvable & val_r );
161
162       /**
163        * The id of the reference. For bugzilla entries
164        * this is the bug number as a string.
165        */
166       std::string id() const;
167       /**
168        * Url or pointer where to find more information
169        */
170       std::string href() const;
171       /**
172        * Title describing the issue
173        */
174       std::string title() const;
175       /**
176        * Type of the reference. For example
177        * "bugzilla"
178        */
179       std::string type() const;
180
181     private:
182       friend class boost::iterator_core_access;
183       int dereference() const { return 0; }
184   };
185
186   inline Patch::ReferenceIterator Patch::referencesBegin() const
187   { return ReferenceIterator(satSolvable()); }
188
189   inline Patch::ReferenceIterator Patch::referencesEnd() const
190   { return ReferenceIterator(); }
191
192   /////////////////////////////////////////////////////////////////
193
194 } // namespace zypp
195 ///////////////////////////////////////////////////////////////////
196 #endif // ZYPP_PATCH_H