libzypp: zypp::MirroredOrigin Class Reference

libzypp 17.38.10

zypp::MirroredOrigin Class Reference

Manages a data source characterized by an authoritative URL and a list of mirror URLs. More...

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

## Classes
class | iter
struct | Private

## Public Types
using | endpoint_iterator = iter<MirroredOrigin, OriginEndpoint>
using | endpoint_const_iterator = iter<MirroredOrigin const, OriginEndpoint const>

## Public Member Functions
| MirroredOrigin ()
| MirroredOrigin (OriginEndpoint authority, std::vector< OriginEndpoint > mirrors={})
void | setAuthority (OriginEndpoint newAuthority)
const std::vector< OriginEndpoint > & | authorities () const
const OriginEndpoint & | authority () const
const std::vector< OriginEndpoint > & | mirrors () const
bool | isValid () const
bool | addAuthority (OriginEndpoint newAuthority)
bool | addMirror (OriginEndpoint newMirror)
void | setMirrors (std::vector< OriginEndpoint > mirrors)
void | clearMirrors ()
std::string | scheme () const
bool | schemeIsDownloading () const
endpoint_iterator | begin ()
endpoint_iterator | end ()
endpoint_const_iterator | begin () const
endpoint_const_iterator | end () const
uint | endpointCount () const
uint | authorityCount () const
const OriginEndpoint & | operator[] (uint index) const
OriginEndpoint & | operator[] (uint index)
const OriginEndpoint & | at (uint index) const
OriginEndpoint & | at (uint index)

## Private Attributes
RWCOW_pointer< Private > | _pimpl

## Detailed Description

Manages a data source characterized by an authoritative URL and a list of mirror URLs.

A MirroredOrigin object encapsulates the access information for a data source that has a primary (authoritative) access point and potentially multiple alternative (mirror) access points. This class is designed to be generic and can be used for various types of data sources where redundancy or alternative access points are needed.

The core components managed by MirroredOrigin are:

- An authoritative URL: This is the main, canonical URL for accessing the data source.
- A collection of mirror URLs: These are alternative URLs that point to (ideally) identical copies of the data source. Mirrors are typically used for improving download speeds, providing redundancy, or distributing load.

Beyond just the URLs, this class can be extended or used in conjunction with mechanisms to store configuration settings pertinent to accessing these URLs (e.g., priorities, credentials, retry strategies). This makes it a more comprehensive definition for a data endpoint than a simple URL string.

Example Use Case:
  A software component might need to download a large data file. A MirroredOrigin instance could define the primary download server and several mirror servers. The component would then use this information to attempt downloads, potentially falling back to mirrors if the primary is unavailable or slow.

This class provides a structured way to handle primary and alternative locations for any resource that might be replicated.

Definition at line 170 of file MirroredOrigin.h.

## Member Typedef Documentation

## ◆ endpoint_iterator

using zypp::MirroredOrigin::endpoint_iterator = iter<MirroredOrigin, OriginEndpoint>

Definition at line 216 of file MirroredOrigin.h.

## ◆ endpoint_const_iterator

using zypp::MirroredOrigin::endpoint_const_iterator = iter<MirroredOrigin const, OriginEndpoint const>

Definition at line 217 of file MirroredOrigin.h.

## Constructor & Destructor Documentation

## ◆ MirroredOrigin() [1/2]

zypp::MirroredOrigin::MirroredOrigin | ( |  | ) |

Definition at line 155 of file MirroredOrigin.cc.

## ◆ MirroredOrigin() [2/2]

zypp::MirroredOrigin::MirroredOrigin | ( | OriginEndpoint | authority,
|  | std::vector< OriginEndpoint > | mirrors = {} )

Definition at line 159 of file MirroredOrigin.cc.

## Member Function Documentation

## ◆ setAuthority()

void zypp::MirroredOrigin::setAuthority | ( | OriginEndpoint | newAuthority | ) |

Changes the authorities to newAuthority

Definition at line 170 of file MirroredOrigin.cc.

## ◆ authorities()

const std::vector< OriginEndpoint > & zypp::MirroredOrigin::authorities | ( |  | ) | const

Returns
  the authority Urls

Definition at line 200 of file MirroredOrigin.cc.

## ◆ authority()

const OriginEndpoint & zypp::MirroredOrigin::authority | ( |  | ) | const

Returns
  the first authority Url if present, empty Url otherwise

Definition at line 205 of file MirroredOrigin.cc.

## ◆ mirrors()

const std::vector< OriginEndpoint > & zypp::MirroredOrigin::mirrors | ( |  | ) | const

Returns
  the mirrors for this origin, may be empty

Definition at line 214 of file MirroredOrigin.cc.

## ◆ isValid()

bool zypp::MirroredOrigin::isValid | ( |  | ) | const

Returns
  true if the authority contains a valid URL

Definition at line 219 of file MirroredOrigin.cc.

## ◆ addAuthority()

bool zypp::MirroredOrigin::addAuthority | ( | OriginEndpoint | newAuthority | ) |

Definition at line 224 of file MirroredOrigin.cc.

## ◆ addMirror()

bool zypp::MirroredOrigin::addMirror | ( | OriginEndpoint | newMirror | ) |

Definition at line 252 of file MirroredOrigin.cc.

## ◆ setMirrors()

void zypp::MirroredOrigin::setMirrors | ( | std::vector< OriginEndpoint > | mirrors | ) |

Definition at line 285 of file MirroredOrigin.cc.

## ◆ clearMirrors()

void zypp::MirroredOrigin::clearMirrors | ( |  | ) |

Definition at line 292 of file MirroredOrigin.cc.

## ◆ scheme()

std::string zypp::MirroredOrigin::scheme | ( |  | ) | const

Returns
  Returns the authority's scheme, all mirrors should follow

Definition at line 297 of file MirroredOrigin.cc.

## ◆ schemeIsDownloading()

bool zypp::MirroredOrigin::schemeIsDownloading | ( |  | ) | const

Returns
  true if the authority has a downloading scheme

Definition at line 304 of file MirroredOrigin.cc.

## ◆ begin() [1/2]

endpoint_iterator zypp::MirroredOrigin::begin | ( |  | ) |
| inline

A iterator over all endpoints, including authority at index 0

Definition at line 265 of file MirroredOrigin.h.

## ◆ end() [1/2]

endpoint_iterator zypp::MirroredOrigin::end | ( |  | ) |
| inline

End iterator over all endpoints, including authority at index 0

Definition at line 272 of file MirroredOrigin.h.

## ◆ begin() [2/2]

endpoint_const_iterator zypp::MirroredOrigin::begin | ( |  | ) | const
| inline

Definition at line 276 of file MirroredOrigin.h.

## ◆ end() [2/2]

endpoint_const_iterator zypp::MirroredOrigin::end | ( |  | ) | const
| inline

Definition at line 280 of file MirroredOrigin.h.

## ◆ endpointCount()

uint zypp::MirroredOrigin::endpointCount | ( |  | ) | const

Returns
  the total number of endpoints, including authority

Definition at line 311 of file MirroredOrigin.cc.

## ◆ authorityCount()

uint zypp::MirroredOrigin::authorityCount | ( |  | ) | const

Returns
  the total number of authorities

Definition at line 316 of file MirroredOrigin.cc.

## ◆ operator[]() [1/2]

const OriginEndpoint & zypp::MirroredOrigin::operator[] | ( | uint | index | ) | const
| inline

Index based access to endpoints, index 0 is always the authority

Exceptions

  std::out_of_range | on a out of range index param

Definition at line 298 of file MirroredOrigin.h.

## ◆ operator[]() [2/2]

OriginEndpoint & zypp::MirroredOrigin::operator[] | ( | uint | index | ) |
| inline

Definition at line 299 of file MirroredOrigin.h.

## ◆ at() [1/2]

const OriginEndpoint & zypp::MirroredOrigin::at | ( | uint | index | ) | const

Index based access to endpoints, index 0 is always the authority

Definition at line 321 of file MirroredOrigin.cc.

## ◆ at() [2/2]

OriginEndpoint & zypp::MirroredOrigin::at | ( | uint | index | ) |

Definition at line 333 of file MirroredOrigin.cc.

## Member Data Documentation

## ◆ _pimpl

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

Definition at line 309 of file MirroredOrigin.h.

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

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