New Resolver interface to turn vendor checks on/off.
[platform/upstream/libzypp.git] / zypp / VendorAttr.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/VendorAttr.h
10  *
11 */
12 #ifndef ZYPP_VENDORATTR_H
13 #define ZYPP_VENDORATTR_H
14
15 #include <iosfwd>
16 #include <string>
17 #include <vector>
18
19 #include "zypp/PathInfo.h"
20 #include "zypp/Vendor.h"
21
22 ///////////////////////////////////////////////////////////////////
23 namespace zypp {
24 //////////////////////////////////////////////////////////////////
25
26 /** Definition of vendor equivalence.
27  *
28  * Packages with equivalment vendor strings may replace themself without
29  * creating a solver error.
30  *
31  * Per default vendor strings starting with \c "suse' or \c 'opensuse"
32  * are treated equivalent. This may be changed by providing customized
33  * vendor description files in \c /etc/zypp/vendors.d.
34 */
35 class VendorAttr
36 {
37   public:
38     typedef std::vector<std::string> VendorList;
39
40     /** Singleton */
41     static const VendorAttr & instance();
42
43     /**
44      * Adding new equivalent vendors described in a directory
45      **/
46     bool addVendorDirectory( const Pathname & dirname ) const;
47
48     /**
49      * Adding new equivalent vendors described in a file
50      **/
51     bool addVendorFile( const Pathname & filename ) const;
52
53     /**
54      * Adding new equivalent vendor set from list
55      **/
56     template <class _Iterator>
57     void addVendorList( _Iterator begin, _Iterator end ) const
58     { VendorList tmp( begin, end ); _addVendorList( tmp ); }
59
60     /** Return whether two vendor strings shold be treated as the same vendor.
61      * Usually the solver is allowed to automatically select a package of an
62      * equivalent vendor when updating. Replacing a package with one of a
63      * different vendor usually must be confirmed by the user.
64     */
65     bool equivalent( const Vendor & lVendor, const Vendor & rVendor ) const;
66
67   private:
68     VendorAttr();
69     void _addVendorList( VendorList & ) const;
70 };
71
72 /** \relates VendorAttr Stream output */
73 std::ostream & operator<<( std::ostream & str, const VendorAttr & obj );
74
75 ///////////////////////////////////////////////////////////////////
76 }; // namespace zypp
77 ///////////////////////////////////////////////////////////////////
78
79 #endif // ZYPP_VENDORATTR_H