libzypp 17.37.17
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 OriginEndpointauthority () const
const std::vector< OriginEndpoint > & mirrors () const
bool isValid () const
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
const OriginEndpointoperator[] (uint index) const
OriginEndpointoperator[] (uint index)
const OriginEndpointat (uint index) const
OriginEndpointat (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

◆ endpoint_const_iterator

Constructor & Destructor Documentation

◆ MirroredOrigin() [1/2]

zypp::MirroredOrigin::MirroredOrigin ( )

Definition at line 151 of file MirroredOrigin.cc.

◆ MirroredOrigin() [2/2]

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

Definition at line 155 of file MirroredOrigin.cc.

Member Function Documentation

◆ setAuthority()

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

Changes the authority to newAuthority

Definition at line 161 of file MirroredOrigin.cc.

◆ authority()

const OriginEndpoint & zypp::MirroredOrigin::authority ( ) const
Returns
the authority Url

Definition at line 184 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 189 of file MirroredOrigin.cc.

◆ isValid()

bool zypp::MirroredOrigin::isValid ( ) const
Returns
true if the authority contains a valid URL

Definition at line 194 of file MirroredOrigin.cc.

◆ addMirror()

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

Definition at line 199 of file MirroredOrigin.cc.

◆ setMirrors()

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

Definition at line 213 of file MirroredOrigin.cc.

◆ clearMirrors()

void zypp::MirroredOrigin::clearMirrors ( )

Definition at line 220 of file MirroredOrigin.cc.

◆ scheme()

std::string zypp::MirroredOrigin::scheme ( ) const
Returns
Returns the authority's scheme, all mirrors should follow

Definition at line 225 of file MirroredOrigin.cc.

◆ schemeIsDownloading()

bool zypp::MirroredOrigin::schemeIsDownloading ( ) const
Returns
true if the authority has a downloading scheme

Definition at line 230 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 259 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 266 of file MirroredOrigin.h.

◆ begin() [2/2]

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

Definition at line 270 of file MirroredOrigin.h.

◆ end() [2/2]

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

Definition at line 274 of file MirroredOrigin.h.

◆ endpointCount()

uint zypp::MirroredOrigin::endpointCount ( ) const
Returns
the total number of endpoints, including authority

Definition at line 235 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_rangeon a out of range index param

Definition at line 287 of file MirroredOrigin.h.

◆ operator[]() [2/2]

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

Definition at line 288 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 241 of file MirroredOrigin.cc.

◆ at() [2/2]

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

Definition at line 253 of file MirroredOrigin.cc.

Member Data Documentation

◆ _pimpl

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

Definition at line 298 of file MirroredOrigin.h.


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