libzypp: zypp::MirroredOriginSet Class Reference

libzypp 17.38.6

zypp::MirroredOriginSet Class Reference

A smart container that manages a collection of MirroredOrigin objects, automatically grouping endpoints and preserving the insertion order of their schemes. More...

`#include <zypp-core/MirroredOrigin.h>`

## Classes
struct | Private

## Public Types
using | iterator = std::vector<MirroredOrigin>::iterator
using | const_iterator = std::vector<MirroredOrigin>::const_iterator
using | size_type = size_t
using | value_type = MirroredOrigin

## Public Member Functions
| MirroredOriginSet ()
| MirroredOriginSet (std::vector< OriginEndpoint > eps)
| Constructs the set, initializing it with a starting list of endpoints.
| MirroredOriginSet (std::vector< zypp::Url > urls)
| MirroredOriginSet (std::list< zypp::Url > urls)
const MirroredOrigin & | at (size_type idx) const
| Accesses the MirroredOrigin at a specific index.
MirroredOrigin & | at (size_type idx)
| Accesses the MirroredOrigin at a specific index.
const_iterator | findByUrl (const zypp::Url &url) const
| Finds the MirroredOrigin that contains a specific URL.
iterator | findByUrl (const zypp::Url &url)
| Finds the MirroredOrigin that contains a specific URL.
template<typename InputIterator>
void | addEndpoints (InputIterator first, InputIterator last)
| A convenience method to add multiple endpoints from a range.
void | addAuthorityEndpoint (OriginEndpoint endpoint)
| Adds a single endpoint as an authority, routing it to the correct MirroredOrigin.
void | addEndpoint (OriginEndpoint endpoint)
| Adds a single endpoint, routing it to the correct MirroredOrigin.
void | addEndpoints (std::vector< OriginEndpoint > endpoints)
| A convenience method to add multiple endpoints from a vector.
iterator | begin ()
| Returns an iterator to the first MirroredOrigin in insertion order.
iterator | end ()
| Returns an iterator to the element following the last MirroredOrigin.
const_iterator | begin () const
| Returns a const_iterator to the first MirroredOrigin in insertion order.
const_iterator | end () const
| Returns a const_iterator to the element following the last MirroredOrigin.
size_type | size () const
| Returns the number of MirroredOrigin objects in the set.
bool | empty () const
void | clear ()
bool | hasFallbackUrls () const
| Whether this set contains more than one Url in total (authorities or mirrors).

## Private Attributes
RWCOW_pointer< Private > | _pimpl

## Detailed Description

A smart container that manages a collection of MirroredOrigin objects, automatically grouping endpoints and preserving the insertion order of their schemes.

This class acts as a high-level manager for data sources. When an OriginEndpoint is added, this set automatically determines its URL scheme (e.g., 'http', 'ftp', 'file') and adds it to the appropriate MirroredOrigin instance. Currently only schemes seen as "downloading" are grouped.

See also
  zypp::Url::schemeIsDownloading

If a MirroredOrigin for a given scheme does not yet exist, it is created automatically, with the first added endpoint for that scheme becoming the authoritative endpoint. Subsequent endpoints for the same scheme are added as mirrors.

Ordering Guarantee
  This class guarantees that iterating over the origins will follow the order in which schemes were first introduced. For example, if the first endpoint added is HTTP, then DVD, then another HTTP, the "http" origin will always appear before the "dvd" origin during iteration.

Definition at line 336 of file MirroredOrigin.h.

## Member Typedef Documentation

## ◆ iterator

using zypp::MirroredOriginSet::iterator = std::vector<MirroredOrigin>::iterator

Definition at line 339 of file MirroredOrigin.h.

## ◆ const_iterator

using zypp::MirroredOriginSet::const_iterator = std::vector<MirroredOrigin>::const_iterator

Definition at line 340 of file MirroredOrigin.h.

## ◆ size_type

using zypp::MirroredOriginSet::size_type = size_t

Definition at line 341 of file MirroredOrigin.h.

## ◆ value_type

using zypp::MirroredOriginSet::value_type = MirroredOrigin

Definition at line 342 of file MirroredOrigin.h.

## Constructor & Destructor Documentation

## ◆ MirroredOriginSet() [1/4]

zypp::MirroredOriginSet::MirroredOriginSet | ( |  | ) |

Definition at line 359 of file MirroredOrigin.cc.

## ◆ MirroredOriginSet() [2/4]

zypp::MirroredOriginSet::MirroredOriginSet | ( | std::vector< OriginEndpoint > | eps | ) |

Constructs the set, initializing it with a starting list of endpoints.

Parameters

  eps | A vector of OriginEndpoint objects to add to the set upon construction. The standard grouping logic will be applied to these endpoints.

Definition at line 363 of file MirroredOrigin.cc.

## ◆ MirroredOriginSet() [3/4]

zypp::MirroredOriginSet::MirroredOriginSet | ( | std::vector< zypp::Url > | urls | ) |

Definition at line 377 of file MirroredOrigin.cc.

## ◆ MirroredOriginSet() [4/4]

zypp::MirroredOriginSet::MirroredOriginSet | ( | std::list< zypp::Url > | urls | ) |

## Member Function Documentation

## ◆ at() [1/2]

const MirroredOrigin & zypp::MirroredOriginSet::at | ( | size_type | idx | ) | const

Accesses the MirroredOrigin at a specific index.

Parameters

  idx | The index of the element to return (respects insertion order).

Returns
  A const reference to the requested MirroredOrigin.

Exceptions

  std::out_of_range | if idx >= size().

Definition at line 384 of file MirroredOrigin.cc.

## ◆ at() [2/2]

MirroredOrigin & zypp::MirroredOriginSet::at | ( | size_type | idx | ) |

Accesses the MirroredOrigin at a specific index.

Parameters

  idx | The index of the element to return (respects insertion order).

Returns
  A reference to the requested MirroredOrigin.

Exceptions

  std::out_of_range | if idx >= size().

Definition at line 389 of file MirroredOrigin.cc.

## ◆ findByUrl() [1/2]

MirroredOriginSet::const_iterator zypp::MirroredOriginSet::findByUrl | ( | const zypp::Url & | url | ) | const

Finds the MirroredOrigin that contains a specific URL.

This method searches through both the authority and all mirror URLs of every MirroredOrigin in the set.

Parameters

  url | The URL to search for.

Returns
  A const_iterator to the matching MirroredOrigin, or end() if not found.

Definition at line 413 of file MirroredOrigin.cc.

## ◆ findByUrl() [2/2]

MirroredOriginSet::iterator zypp::MirroredOriginSet::findByUrl | ( | const zypp::Url & | url | ) |

Finds the MirroredOrigin that contains a specific URL.

This method searches through both the authority and all mirror URLs of every MirroredOrigin in the set.

Parameters

  url | The URL to search for.

Returns
  An iterator to the matching MirroredOrigin, or end() if not found.

Definition at line 403 of file MirroredOrigin.cc.

## ◆ addEndpoints() [1/2]

template<typename InputIterator>

void zypp::MirroredOriginSet::addEndpoints | ( | InputIterator | first,
|  | InputIterator | last )
| inline

A convenience method to add multiple endpoints from a range.

Template Parameters

  InputIterator | The type of the iterator for the source range.

Parameters

  first | An iterator to the beginning of the range of OriginEndpoints to insert.
  last | An iterator to the end of the range of OriginEndpoints to insert.

Definition at line 398 of file MirroredOrigin.h.

## ◆ addAuthorityEndpoint()

void zypp::MirroredOriginSet::addAuthorityEndpoint | ( | OriginEndpoint | endpoint | ) |

Adds a single endpoint as an authority, routing it to the correct MirroredOrigin.

Extracts the scheme from the endpoint's URL. If a MirroredOrigin for that scheme exists, the endpoint is added as an authority. Otherwise, a new MirroredOrigin is created with this endpoint as its first authority.

Parameters

  endpoint | The OriginEndpoint to add.

Definition at line 423 of file MirroredOrigin.cc.

## ◆ addEndpoint()

void zypp::MirroredOriginSet::addEndpoint | ( | OriginEndpoint | endpoint | ) |

Adds a single endpoint, routing it to the correct MirroredOrigin.

Extracts the scheme from the endpoint's URL. If a MirroredOrigin for that scheme exists, the endpoint is added as a mirror. Otherwise, a new MirroredOrigin is created with this endpoint as its authority.

Parameters

  endpoint | The OriginEndpoint to add.

Definition at line 440 of file MirroredOrigin.cc.

## ◆ addEndpoints() [2/2]

void zypp::MirroredOriginSet::addEndpoints | ( | std::vector< OriginEndpoint > | endpoints | ) |

A convenience method to add multiple endpoints from a vector.

Parameters

  endpoints | A vector of OriginEndpoint objects to add.

Definition at line 458 of file MirroredOrigin.cc.

## ◆ begin() [1/2]

MirroredOriginSet::iterator zypp::MirroredOriginSet::begin | ( |  | ) |

Returns an iterator to the first MirroredOrigin in insertion order.

Definition at line 475 of file MirroredOrigin.cc.

## ◆ end() [1/2]

MirroredOriginSet::iterator zypp::MirroredOriginSet::end | ( |  | ) |

Returns an iterator to the element following the last MirroredOrigin.

Definition at line 481 of file MirroredOrigin.cc.

## ◆ begin() [2/2]

MirroredOriginSet::const_iterator zypp::MirroredOriginSet::begin | ( |  | ) | const

Returns a const_iterator to the first MirroredOrigin in insertion order.

Definition at line 487 of file MirroredOrigin.cc.

## ◆ end() [2/2]

MirroredOriginSet::const_iterator zypp::MirroredOriginSet::end | ( |  | ) | const

Returns a const_iterator to the element following the last MirroredOrigin.

Definition at line 493 of file MirroredOrigin.cc.

## ◆ size()

MirroredOriginSet::size_type zypp::MirroredOriginSet::size | ( |  | ) | const

Returns the number of MirroredOrigin objects in the set.

Returns
  The number of elements.

Definition at line 498 of file MirroredOrigin.cc.

## ◆ empty()

bool zypp::MirroredOriginSet::empty | ( |  | ) | const

Definition at line 464 of file MirroredOrigin.cc.

## ◆ clear()

void zypp::MirroredOriginSet::clear | ( |  | ) |

Definition at line 469 of file MirroredOrigin.cc.

## ◆ hasFallbackUrls()

bool zypp::MirroredOriginSet::hasFallbackUrls | ( |  | ) | const

Whether this set contains more than one Url in total (authorities or mirrors).

Some parts of the code like to raise an interactive MediaChangeReport only if the Repository itself does not provide any fallbacks.

Definition at line 503 of file MirroredOrigin.cc.

## Member Data Documentation

## ◆ _pimpl

RWCOW_pointer<Private> zypp::MirroredOriginSet::_pimpl
| private

Definition at line 456 of file MirroredOrigin.h.

The documentation for this class was generated from the following files:

- zypp-core/MirroredOrigin.h
- zypp-core/MirroredOrigin.cc