#define ZYPP_VENDORATTR_H
#include <iosfwd>
-#include <map>
-#include <list>
#include <string>
+#include <vector>
-#include "zypp/NeedAType.h"
+#include "zypp/PathInfo.h"
+#include "zypp/Vendor.h"
///////////////////////////////////////////////////////////////////
namespace zypp {
//////////////////////////////////////////////////////////////////
-class VendorAttr {
+ class PoolItem;
+ namespace sat
+ {
+ class Solvable;
+ }
- private:
- typedef std::map<Vendor,bool> TrustMap;
-
- TrustMap _trustMap;
-
- typedef std::list<std::string> VendorList;
- VendorList _trustedVendors;
+/** Definition of vendor equivalence.
+ *
+ * Packages with equivalment vendor strings may replace themself without
+ * creating a solver error.
+ *
+ * Per default vendor strings starting with \c "suse" or \c "opensuse"
+ * are treated equivalent. This may be changed by providing customized
+ * vendor description files in \c /etc/zypp/vendors.d.
+ *
+ * \see \ref pg_zypp-solv-vendorchange
+*/
+class VendorAttr
+{
+ public:
+ typedef std::vector<std::string> VendorList;
- private:
+ /** Singleton */
+ static const VendorAttr & instance();
- VendorAttr ();
- ~VendorAttr ();
+ /**
+ * Adding new equivalent vendors described in a directory
+ **/
+ bool addVendorDirectory( const Pathname & dirname ) const;
- bool trusted ( const Vendor & vendor_r );
+ /**
+ * Adding new equivalent vendors described in a file
+ **/
+ bool addVendorFile( const Pathname & filename ) const;
- public:
- static VendorAttr *vendorAttr (void);
+ /**
+ * Adding new equivalent vendor set from list
+ **/
+ template <class _Iterator>
+ void addVendorList( _Iterator begin, _Iterator end ) const
+ { VendorList tmp( begin, end ); _addVendorList( tmp ); }
- /**
- * Return whether it's a known vendor
- **/
- bool isKnown( const Vendor & vendor_r );
+ /** Return whether two vendor strings shold be treated as the same vendor.
+ * Usually the solver is allowed to automatically select a package of an
+ * equivalent vendor when updating. Replacing a package with one of a
+ * different vendor usually must be confirmed by the user.
+ */
+ bool equivalent( const Vendor & lVendor, const Vendor & rVendor ) const;
+ /** \overload using \ref IdStrings */
+ bool equivalent( IdString lVendor, IdString rVendor ) const;
+ /** \overload using \ref sat::Solvable */
+ bool equivalent( sat::Solvable lVendor, sat::Solvable rVendor ) const;
+ /** \overload using \ref PoolItem */
+ bool equivalent( const PoolItem & lVendor, const PoolItem & rVendor ) const;
- /**
- * Return whether this vendors packages should be protected by
- * default.
- **/
- bool autoProtect( const Vendor & vendor_r );
+ private:
+ VendorAttr();
+ void _addVendorList( VendorList & ) const;
};
+/** \relates VendorAttr Stream output */
+std::ostream & operator<<( std::ostream & str, const VendorAttr & obj );
+
///////////////////////////////////////////////////////////////////
}; // namespace zypp
///////////////////////////////////////////////////////////////////