libzypp  17.32.5
VendorAttr.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
11 #ifndef ZYPP_VENDORATTR_H
12 #define ZYPP_VENDORATTR_H
13 
14 #include <iosfwd>
15 #include <string>
16 #include <vector>
17 
18 #include <zypp/base/PtrTypes.h>
19 #include <zypp/IdString.h>
20 #include <zypp/PathInfo.h>
21 #include <zypp/Vendor.h>
22 
23 #include <zypp/APIConfig.h> // LEGACY macros
24 
26 namespace zypp {
28 
29  class PoolItem;
30  namespace sat
31  {
32  class Solvable;
33  }
34 
61 {
62  friend std::ostream & operator<<( std::ostream & str, const VendorAttr & obj );
63 
64  public:
66  static const VendorAttr & instance();
67 
72  static VendorAttr & noTargetInstance();
73 
74  public:
76  VendorAttr();
77 
79  VendorAttr( const Pathname & initial_r );
80 
82  ~VendorAttr();
83 
84  VendorAttr(const VendorAttr &) = default;
85  VendorAttr(VendorAttr &&) noexcept = default;
86  VendorAttr &operator=(const VendorAttr &) = default;
87  VendorAttr &operator=(VendorAttr &&) noexcept = default;
88 
92  bool addVendorDirectory( const Pathname & dirname_r );
93 #if LEGACY(1722)
94 
95  bool addVendorDirectory( const Pathname & dirname_r ) const ZYPP_DEPRECATED;
96 #endif
97 
101  bool addVendorFile( const Pathname & filename_r );
102 #if LEGACY(1722)
103 
104  bool addVendorFile( const Pathname & filename_r ) const ZYPP_DEPRECATED;
105 #endif
106 
108  using VendorList = std::vector<std::string>;
109 
113  void addVendorList( VendorList && list_r )
114  { _addVendorList( std::move(list_r) ); }
116  void addVendorList( const VendorList & list_r )
117  { _addVendorList( VendorList(list_r) ); }
119  template <class TContainer>
120  void addVendorList( const TContainer & container_r )
121  {
122  VendorList tmp;
123  for ( const auto & el : container_r )
124  tmp.push_back( std::string(el) );
125  _addVendorList( std::move(tmp) );
126  }
128  template <class TStr>
129  void addVendorList( const std::initializer_list<TStr> & container_r )
130  {
131  VendorList tmp;
132  for ( const auto & el : container_r )
133  tmp.push_back( std::string(el) );
134  _addVendorList( std::move(tmp) );
135  }
136 
142  bool equivalent( const Vendor & lVendor, const Vendor & rVendor ) const;
144  bool equivalent( IdString lVendor, IdString rVendor ) const;
146  bool equivalent( sat::Solvable lVendor, sat::Solvable rVendor ) const;
148  bool equivalent( const PoolItem & lVendor, const PoolItem & rVendor ) const;
149 
151  bool relaxedEquivalent( const Vendor & lVendor, const Vendor & rVendor ) const;
153  bool relaxedEquivalent( IdString lVendor, IdString rVendor ) const;
155  bool relaxedEquivalent( sat::Solvable lVendor, sat::Solvable rVendor ) const;
157  bool relaxedEquivalent( const PoolItem & lVendor, const PoolItem & rVendor ) const;
158 
159  public:
163  unsigned foreachVendorList( std::function<bool(VendorList)> fnc_r ) const;
164 
165  public:
166  class Impl;
168 
169 #if LEGACY(1722)
170 
171  void _addVendorList( std::vector<std::string> & list_r ) const ZYPP_DEPRECATED;
173  void _addVendorList( std::vector<IdString> && list_r );
174 #endif
175  void _addVendorList( VendorList && list_r );
176 };
177 
179 std::ostream & operator<<( std::ostream & str, const VendorAttr & obj );
180 
182 }; // namespace zypp
184 
185 #endif // ZYPP_VENDORATTR_H
A Solvable object within the sat Pool.
Definition: Solvable.h:53
void addVendorList(const VendorList &list_r)
Definition: VendorAttr.h:116
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings should be treated as the same vendor.
Definition: VendorAttr.cc:331
void addVendorList(const TContainer &container_r)
Definition: VendorAttr.h:120
VendorAttr()
Ctor providing the default set.
Definition: VendorAttr.cc:242
RWCOW_pointer< Impl > _pimpl
Implementation class.
Definition: VendorAttr.h:166
String related utilities and Regular expression matching.
unsigned foreachVendorList(std::function< bool(VendorList)> fnc_r) const
Call fnc_r for each equivalent vendor list (return false to break).
Definition: VendorAttr.cc:303
bool addVendorDirectory(const Pathname &dirname_r)
Adding new equivalent vendors described in a directory.
Definition: VendorAttr.cc:258
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
Access to the sat-pools string space.
Definition: IdString.h:42
void _addVendorList(VendorList &&list_r)
Definition: VendorAttr.cc:300
bool addVendorFile(const Pathname &filename_r)
Adding new equivalent vendors described in a file.
Definition: VendorAttr.cc:275
~VendorAttr()
Dtor.
Definition: VendorAttr.cc:255
VendorAttr implementation.
Definition: VendorAttr.cc:40
static VendorAttr & noTargetInstance()
Singleton, settings used if no Target is active.
Definition: VendorAttr.cc:236
Definition of vendor equivalence.
Definition: VendorAttr.h:60
bool relaxedEquivalent(const Vendor &lVendor, const Vendor &rVendor) const
Like equivalent but always unifies suse and openSUSE vendor.
Definition: VendorAttr.cc:344
void addVendorList(VendorList &&list_r)
Adding new equivalent vendor strings container.
Definition: VendorAttr.h:113
void addVendorList(const std::initializer_list< TStr > &container_r)
Definition: VendorAttr.h:129
std::vector< std::string > VendorList
Preferred type to pass equivalent vendor strings.
Definition: VendorAttr.h:108
friend std::ostream & operator<<(std::ostream &str, const VendorAttr &obj)
Definition: VendorAttr.cc:355
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
static const VendorAttr & instance()
(Pseudo)Singleton, mapped to the current Target::vendorAttr settings or to noTargetInstance.
Definition: VendorAttr.cc:230
VendorAttr & operator=(const VendorAttr &)=default
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3...
Definition: Globals.h:99
std::string Vendor
Definition: Vendor.h:22