1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/VendorAttr.h
11 #ifndef ZYPP_VENDORATTR_H
12 #define ZYPP_VENDORATTR_H
18 #include <zypp/base/PtrTypes.h>
19 #include <zypp/IdString.h>
20 #include <zypp/PathInfo.h>
21 #include <zypp/Vendor.h>
23 #include <zypp/APIConfig.h> // LEGACY macros
25 ///////////////////////////////////////////////////////////////////
27 //////////////////////////////////////////////////////////////////
35 /** Definition of vendor equivalence.
37 * Packages with equivalent vendor strings may replace themselves without
38 * creating a solver error.
40 * Per default vendor strings starting with \c "suse" are treated as
41 * being equivalent. This may be tuned by providing customized
42 * vendor description files in \c /etc/zypp/vendors.d.
46 * vendors = MyVendor,AlternateName
49 * By this vendor strings starting with "MyVendor" or "AlternateName"
50 * are considered to be equivalent. Packages from equivalent vendors
51 * may replace each other without being considered as a 'vendor change'.
53 * \note bnc#812608: Within the "opensuse*" namespace exact matches
54 * (case insensitive) are required. "vendors = suse,opensuse" will
55 * allow switching between "suse*" and "opensuse", but not e.g.
56 * "opensuse build service".
58 * \see \ref pg_zypp-solv-vendorchange
62 friend std::ostream & operator<<( std::ostream & str, const VendorAttr & obj );
65 /** (Pseudo)Singleton, mapped to the current \ref Target::vendorAttr settings or to \ref noTargetInstance. */
66 static const VendorAttr & instance();
68 /** Singleton, settings used if no \ref Target is active.
69 * The instance is initialized with the settings found in the system below /.
70 * The active Targets settings can be changed via \ref Target::vendorAttr.
72 static VendorAttr & noTargetInstance();
75 /** Ctor providing the default set. */
78 /** Ctor reading the \a initial_r definitions from a dir or file. */
79 VendorAttr( const Pathname & initial_r );
85 * Adding new equivalent vendors described in a directory
87 bool addVendorDirectory( const Pathname & dirname_r );
89 /** \deprecated This is NOT a CONST operation. */
90 bool addVendorDirectory( const Pathname & dirname_r ) const ZYPP_DEPRECATED;
94 * Adding new equivalent vendors described in a file
96 bool addVendorFile( const Pathname & filename_r );
98 /** \deprecated This is NOT a CONST operation. */
99 bool addVendorFile( const Pathname & filename_r ) const ZYPP_DEPRECATED;
102 /** Preferred type to pass equivalent vendor strings. */
103 typedef std::vector<std::string> VendorList;
106 * Adding new equivalent vendor strings container.
108 void addVendorList( VendorList && list_r )
109 { _addVendorList( std::move(list_r) ); }
110 /** \overload copying the data */
111 void addVendorList( const VendorList & list_r )
112 { _addVendorList( VendorList(list_r) ); }
113 /** \overload from arbitrary string container */
114 template <class TContainer>
115 void addVendorList( const TContainer & container_r )
118 for ( const auto & el : container_r )
119 tmp.push_back( std::string(el) );
120 _addVendorList( std::move(tmp) );
122 /** \overload from std::initializer_list */
123 template <class TStr>
124 void addVendorList( const std::initializer_list<TStr> & container_r )
127 for ( const auto & el : container_r )
128 tmp.push_back( std::string(el) );
129 _addVendorList( std::move(tmp) );
132 /** Return whether two vendor strings should be treated as the same vendor.
133 * Usually the solver is allowed to automatically select a package of an
134 * equivalent vendor when updating. Replacing a package with one of a
135 * different vendor usually must be confirmed by the user.
137 bool equivalent( const Vendor & lVendor, const Vendor & rVendor ) const;
138 /** \overload using \ref IdStrings */
139 bool equivalent( IdString lVendor, IdString rVendor ) const;
140 /** \overload using \ref sat::Solvable */
141 bool equivalent( sat::Solvable lVendor, sat::Solvable rVendor ) const;
142 /** \overload using \ref PoolItem */
143 bool equivalent( const PoolItem & lVendor, const PoolItem & rVendor ) const;
146 class Impl; ///< Implementation class.
147 RWCOW_pointer<Impl> _pimpl; ///< Pointer to implementation.
151 void _addVendorList( std::vector<std::string> & list_r ) const ZYPP_DEPRECATED;
153 void _addVendorList( std::vector<IdString> && list_r );
155 void _addVendorList( VendorList && list_r );
158 /** \relates VendorAttr Stream output */
159 std::ostream & operator<<( std::ostream & str, const VendorAttr & obj );
161 ///////////////////////////////////////////////////////////////////
163 ///////////////////////////////////////////////////////////////////
165 #endif // ZYPP_VENDORATTR_H