Cleanup and remove deprecated interface methods
[platform/upstream/libzypp.git] / zypp / Product.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Product.h
10  *
11 */
12 #ifndef ZYPP_PRODUCT_H
13 #define ZYPP_PRODUCT_H
14
15 #include <list>
16 #include <string>
17
18 #include "zypp/ResObject.h"
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23
24   DEFINE_PTR_TYPE(Product);
25
26   ///////////////////////////////////////////////////////////////////
27   //
28   //    CLASS NAME : Product
29   //
30   /** Product interface.
31   */
32   class Product : public ResObject
33   {
34   public:
35     typedef Product                  Self;
36     typedef ResTraits<Self>          TraitsType;
37     typedef TraitsType::PtrType      Ptr;
38     typedef TraitsType::constPtrType constPtr;
39
40   public:
41     /** The reference package providing the product metadata,
42      *  if such a package exists.
43      */
44     sat::Solvable referencePackage() const;
45
46     /** For installed products the name of the coddesponding
47      * \c /etc/products.d entry.
48     .*/
49     std::string referenceFilename() const;
50
51   public:
52     /***/
53     typedef std::vector<constPtr> ReplacedProducts;
54
55     /** Array of \b installed Products that would be replaced by
56      *  installing this one.
57      */
58     ReplacedProducts replacedProducts() const;
59
60     /** Vendor specific string denoting the product line. */
61     std::string productLine() const;
62
63   public:
64     /** Untranslated short name like <tt>SLES 10</tt>*/
65     std::string shortName() const;
66
67     /** The product flavor (LiveCD Demo, FTP edition,...). */
68     std::string flavor() const;
69
70     /** Get the product type
71      * Well, in an ideal world there is only one base product.
72      * It's the installed product denoted by a symlink in
73      * \c /etc/products.d.
74      * \deprecated Use isTargetDistribution to test for the installed base product,
75      * other wise type is empty for almost all products.
76     */
77     std::string type() const ZYPP_DEPRECATED;
78
79     /** The product flags */
80     std::list<std::string> flags() const;
81
82   public:
83     /** This is the \b installed product that is also targeted by the
84      *  \c /etc/products.d/baseproduct symlink.
85     */
86     bool isTargetDistribution() const;
87
88     /** This is \c register.target attribute of an \b installed product.
89       * Used for registration.
90       */
91     std::string registerTarget() const;
92
93     /** This is \c register.release attribute of an \b installed product.
94       * Used for registration.
95       */
96     std::string registerRelease() const;
97
98   public:
99     /***/
100     class UrlList;
101
102     /** Rerieve urls flagged with \c key_r for this product.
103      *
104      * This is the most common interface. There are convenience methods for
105      * wellknown flags like \c "releasenotes", \c "register", \c "updateurls",
106      * \c "extraurls", \c "optionalurls" and \c "smolt" below.
107      */
108     UrlList urls( const std::string & key_r ) const;
109
110     /** The URL to download the release notes for this product. */
111     UrlList releaseNotesUrls() const;
112
113     /** The URL for registration. */
114     UrlList registerUrls() const;
115
116     /** The URL for SMOLT \see http://smolts.org/wiki/Main_Page. */
117     UrlList smoltUrls() const;
118
119     /**
120      * Online updates for the product.
121      * They are complementary, not alternatives. #163192
122      */
123     UrlList updateUrls() const;
124
125     /**
126      * Additional software for the product
127      * They are complementary, not alternatives.
128      */
129     UrlList extraUrls() const;
130
131     /**
132      * Optional software for the product.
133      * (for example. Non OSS repositories)
134      * They are complementary, not alternatives.
135      */
136     UrlList optionalUrls() const;
137
138   protected:
139     friend Ptr make<Self>( const sat::Solvable & solvable_r );
140     /** Ctor */
141     Product( const sat::Solvable & solvable_r );
142     /** Dtor */
143     virtual ~Product();
144   };
145
146   /** Helper to iterate a products URL lists.
147    * \ref first is a convenience for 'lists' with just
148    * one entry (e.g. releaseNotesUrls)
149    */
150   class Product::UrlList
151   {
152     private:
153       /** \todo Change to directly iterate the .solv */
154       typedef std::list<Url> ListType;
155
156     public:
157       typedef ListType::value_type     value_type;
158       typedef ListType::size_type      size_type;
159       typedef ListType::const_iterator const_iterator;
160
161       bool empty() const
162       { return _list.empty(); }
163
164       size_type size() const
165       { return _list.size(); }
166
167       const_iterator begin() const
168       { return _list.begin(); }
169
170       const_iterator end() const
171       { return _list.end(); }
172
173       /** The first Url or an empty Url. */
174       Url first() const
175       { return empty() ? value_type() : _list.front(); }
176
177     public:
178       /** The key used to retrieve this list (for debug) */
179       std::string key() const
180       { return _key; }
181
182     private:
183       friend class Product;
184       /** Change to directly iterate the .solv */
185       std::string _key;
186       ListType    _list;
187   };
188
189   /** \relates Product::UrlList Stream output. */
190   std::ostream & operator<<( std::ostream & str, const Product::UrlList & obj );
191
192   /////////////////////////////////////////////////////////////////
193 } // namespace zypp
194 ///////////////////////////////////////////////////////////////////
195 #endif // ZYPP_PRODUCT_H