libzypp 17.37.10

provideitem.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9#ifndef ZYPP_MEDIA_PROVIDEITEM_H_INCLUDED
10#define ZYPP_MEDIA_PROVIDEITEM_H_INCLUDED
11
12#include <zypp-core/zyppng/base/zyppglobal.h>
13#include <zypp-core/zyppng/base/Base>
14#include <zypp-media/ng/ProvideFwd>
15#include <zypp-core/ByteCount.h>
16
17 namespace zyppng
18{
19 class ProvidePrivate;
20 class ProvideItemPrivate;
21
28 class ProvideItem : public Base
29 {
30 ZYPP_DECLARE_PRIVATE(ProvideItem)
31 friend class Provide;
32 friend class ProvidePrivate;
33 friend class ProvideQueue;
34 public:
35 enum State {
36 Uninitialized, //< Item was added to the queue but not yet initialized
37 Pending, //< The Item is waiting to be queued and does nothing
38 Downloading, //< The Item is fetching data
39 Processing, //< The Item has fetched all data but is still doing other things
40 Cancelling, //< The Item was cancelled and waits
41 Finalizing, //< The Item has finished all work and is currently cleaning up
42 Finished //< The Item is done and can be dequeued
43 };
44
45 struct ItemStats {
46 std::chrono::steady_clock::time_point _pulseTime;
47 uint _runningRequests;
48 zypp::ByteCount _bytesProvided;
49 zypp::ByteCount _bytesExpected;
50 };
51
52 ProvideItem( ProvidePrivate &parent );
53 ~ProvideItem ();
54
58 virtual void initialize () = 0;
59
63 virtual void released ();
64
65 State state () const;
66
70 SignalProxy<void( ProvideItem &item, State oldState, State newState )> sigStateChanged();
71
72 ProvidePrivate &provider();
73
78 virtual bool canRedirectTo ( ProvideRequestRef startedReq, const zypp::Url &url );
79
84 const std::optional<ItemStats> &currentStats() const;
85
90 const std::optional<ItemStats> &previousStats() const;
91
96 virtual std::chrono::steady_clock::time_point startTime() const;
97
102 virtual std::chrono::steady_clock::time_point finishedTime() const;
103
108 void pulse ();
109
113 virtual zypp::ByteCount bytesExpected () const;
114
115 protected:
116 virtual ItemStats makeStats ();
117
121 virtual void informalMessage ( ProvideQueue &, ProvideRequestRef req, const ProvideMessage &msg );
122
126 virtual void cacheMiss ( ProvideRequestRef req );
127
135 virtual void finishReq ( ProvideQueue &queue, ProvideRequestRef finishedReq, const ProvideMessage &msg );
136
143 virtual void finishReq ( ProvideQueue *queue, ProvideRequestRef finishedReq, const std::exception_ptr excpt );
144
149 virtual expected<zypp::media::AuthData> authenticationRequired ( ProvideQueue &queue, ProvideRequestRef req, const zypp::Url &effectiveUrl, int64_t lastTimestamp, const std::map<std::string, std::string> &extraFields );
150
155 bool safeRedirectTo ( ProvideRequestRef startedReq, const zypp::Url &url );
156
160 void redirectTo ( ProvideRequestRef startedReq, const zypp::Url &url );
161
166 virtual bool enqueueRequest( ProvideRequestRef request );
167
171 virtual void cancelWithError ( std::exception_ptr error ) = 0;
172
177 bool dequeue ();
178
184 void updateState( const State newState );
185
186 void setFinished ();
187
188 protected:
189 ProvideRequestRef _runningReq;
190 };
191}
192#endif // ZYPP_MEDIA_PROVIDEITEM_H_INCLUDED
zypp::ByteCount
Store and operate with byte count.
Definition ByteCount.h:32
zypp::Url
Url manipulation class.
Definition Url.h:93
zyppng::Base::parent
WeakPtr parent() const
Definition base.cc:26
zyppng::Base::Base
Base()
Definition base.cc:20
zyppng::ProvideItemPrivate
Definition provideitem_p.h:95
zyppng::ProvideItem::pulse
void pulse()
Definition provideitem.cc:141
zyppng::ProvideItem::safeRedirectTo
bool safeRedirectTo(ProvideRequestRef startedReq, const zypp::Url &url)
Definition provideitem.cc:95
zyppng::ProvideItem::startTime
virtual std::chrono::steady_clock::time_point startTime() const
Definition provideitem.cc:132
zyppng::ProvideItem::cacheMiss
virtual void cacheMiss(ProvideRequestRef req)
Definition provideitem.cc:180
zyppng::ProvideItem::ProvideItem
ProvideItem(ProvidePrivate &parent)
Definition provideitem.cc:83
zyppng::ProvideItem::provider
ProvidePrivate & provider()
Definition provideitem.cc:90
zyppng::ProvideItem::dequeue
bool dequeue()
zyppng::ProvideItem::~ProvideItem
~ProvideItem()
Definition provideitem.cc:87
zyppng::ProvideItem::setFinished
void setFinished()
zyppng::ProvideItem::authenticationRequired
virtual expected< zypp::media::AuthData > authenticationRequired(ProvideQueue &queue, ProvideRequestRef req, const zypp::Url &effectiveUrl, int64_t lastTimestamp, const std::map< std::string, std::string > &extraFields)
Definition provideitem.cc:402
zyppng::ProvideItem::makeStats
virtual ItemStats makeStats()
Definition provideitem.cc:159
zyppng::ProvideItem::Provide
friend class Provide
Definition provideitem.h:31
zyppng::ProvideItem::initialize
virtual void initialize()=0
zyppng::ProvideItem::canRedirectTo
virtual bool canRedirectTo(ProvideRequestRef startedReq, const zypp::Url &url)
Definition provideitem.cc:110
zyppng::ProvideItem::finishedTime
virtual std::chrono::steady_clock::time_point finishedTime() const
Definition provideitem.cc:137
zyppng::ProvideItem::bytesExpected
virtual zypp::ByteCount bytesExpected() const
Definition provideitem.cc:154
zyppng::ProvideItem::_runningReq
ProvideRequestRef _runningReq
Definition provideitem.h:189
zyppng::ProvideItem::redirectTo
void redirectTo(ProvideRequestRef startedReq, const zypp::Url &url)
Definition provideitem.cc:104
zyppng::ProvideItem::state
State state() const
Definition provideitem.cc:498
zyppng::ProvideItem::State
State
Definition provideitem.h:35
zyppng::ProvideItem::Downloading
@ Downloading
Definition provideitem.h:38
zyppng::ProvideItem::Uninitialized
@ Uninitialized
Definition provideitem.h:36
zyppng::ProvideItem::Processing
@ Processing
Definition provideitem.h:39
zyppng::ProvideItem::Finalizing
@ Finalizing
Definition provideitem.h:41
zyppng::ProvideItem::Pending
@ Pending
Definition provideitem.h:37
zyppng::ProvideItem::Finished
@ Finished
Definition provideitem.h:42
zyppng::ProvideItem::Cancelling
@ Cancelling
Definition provideitem.h:40
zyppng::ProvideItem::informalMessage
virtual void informalMessage(ProvideQueue &, ProvideRequestRef req, const ProvideMessage &msg)
Definition provideitem.cc:167
zyppng::ProvideItem::previousStats
const std::optional< ItemStats > & previousStats() const
Definition provideitem.cc:127
zyppng::ProvideItem::ProvidePrivate
friend class ProvidePrivate
Definition provideitem.h:32
zyppng::ProvideItem::released
virtual void released()
Definition provideitem.cc:489
zyppng::ProvideItem::finishReq
virtual void finishReq(ProvideQueue &queue, ProvideRequestRef finishedReq, const ProvideMessage &msg)
Definition provideitem.cc:190
zyppng::ProvideItem::cancelWithError
virtual void cancelWithError(std::exception_ptr error)=0
zyppng::ProvideItem::currentStats
const std::optional< ItemStats > & currentStats() const
Definition provideitem.cc:122
zyppng::ProvideItem::updateState
void updateState(const State newState)
Definition provideitem.cc:461
zyppng::ProvideItem::ProvideQueue
friend class ProvideQueue
Definition provideitem.h:33
zyppng::ProvideItem::enqueueRequest
virtual bool enqueueRequest(ProvideRequestRef request)
Definition provideitem.cc:451
zyppng::ProvideItem::sigStateChanged
SignalProxy< void(ProvideItem &item, State oldState, State newState)> sigStateChanged()
zyppng::ProvideMessage
Definition providemessage_p.h:521
zyppng::ProvidePrivate
Definition provide_p.h:42
zyppng::SignalProxy
Definition signals.h:325
zyppng::expected
Definition expected.h:27
zypp::url
Url details namespace.
Definition UrlBase.cc:58
zyppng
Definition MediaNetworkRequestExecutor.h:16
zyppng::ProvideItem::ItemStats
Definition provideitem.h:45
zyppng::ProvideItem::ItemStats::_bytesProvided
zypp::ByteCount _bytesProvided
Definition provideitem.h:48
zyppng::ProvideItem::ItemStats::_bytesExpected
zypp::ByteCount _bytesExpected
Definition provideitem.h:49
zyppng::ProvideItem::ItemStats::_pulseTime
std::chrono::steady_clock::time_point _pulseTime
Definition provideitem.h:46
zyppng::ProvideItem::ItemStats::_runningRequests
uint _runningRequests
Definition provideitem.h:47
ByteCount.h
zyppglobal.h
ZYPP_DECLARE_PRIVATE
#define ZYPP_DECLARE_PRIVATE(Class)
Definition zyppglobal.h:87