backup
[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   class PoolItem;
27   namespace sat
28   {
29     class Solvable;
30   }
31
32 /** Definition of vendor equivalence.
33  *
34  * Packages with equivalment vendor strings may replace themself without
35  * creating a solver error.
36  *
37  * Per default vendor strings starting with \c "suse' or \c 'opensuse"
38  * are treated equivalent. This may be changed by providing customized
39  * vendor description files in \c /etc/zypp/vendors.d.
40 */
41 class VendorAttr
42 {
43   public:
44     typedef std::vector<std::string> VendorList;
45
46     /** Singleton */
47     static const VendorAttr & instance();
48
49     /**
50      * Adding new equivalent vendors described in a directory
51      **/
52     bool addVendorDirectory( const Pathname & dirname ) const;
53
54     /**
55      * Adding new equivalent vendors described in a file
56      **/
57     bool addVendorFile( const Pathname & filename ) const;
58
59     /**
60      * Adding new equivalent vendor set from list
61      **/
62     template <class _Iterator>
63     void addVendorList( _Iterator begin, _Iterator end ) const
64     { VendorList tmp( begin, end ); _addVendorList( tmp ); }
65
66     /** Return whether two vendor strings shold be treated as the same vendor.
67      * Usually the solver is allowed to automatically select a package of an
68      * equivalent vendor when updating. Replacing a package with one of a
69      * different vendor usually must be confirmed by the user.
70     */
71     bool equivalent( const Vendor & lVendor, const Vendor & rVendor ) const;
72     /** \overload using \ref IdStrings */
73     bool equivalent( IdString lVendor, IdString rVendor ) const;
74     /** \overload using \ref sat::Solvable */
75     bool equivalent( sat::Solvable lVendor, sat::Solvable rVendor ) const;
76     /** \overload using \ref PoolItem */
77     bool equivalent( const PoolItem & lVendor, const PoolItem & rVendor ) const;
78
79   private:
80     VendorAttr();
81     void _addVendorList( VendorList & ) const;
82 };
83
84 /** \relates VendorAttr Stream output */
85 std::ostream & operator<<( std::ostream & str, const VendorAttr & obj );
86
87 ///////////////////////////////////////////////////////////////////
88 }; // namespace zypp
89 ///////////////////////////////////////////////////////////////////
90
91 #endif // ZYPP_VENDORATTR_H