libzypp 17.37.17
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
13#include <zypp-core/zyppng/base/Base>
14#include <zypp-media/ng/ProvideFwd>
15#include <zypp-core/ByteCount.h>
16
17namespace zyppng
18{
19 class ProvidePrivate;
21
28 class ProvideItem : public Base
29 {
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
51
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
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
Store and operate with byte count.
Definition ByteCount.h:32
Url manipulation class.
Definition Url.h:93
WeakPtr parent() const
Definition base.cc:26
bool safeRedirectTo(ProvideRequestRef startedReq, const zypp::Url &url)
virtual std::chrono::steady_clock::time_point startTime() const
virtual void cacheMiss(ProvideRequestRef req)
ProvideItem(ProvidePrivate &parent)
ProvidePrivate & provider()
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)
virtual ItemStats makeStats()
friend class Provide
Definition provideitem.h:31
virtual void initialize()=0
virtual bool canRedirectTo(ProvideRequestRef startedReq, const zypp::Url &url)
virtual std::chrono::steady_clock::time_point finishedTime() const
virtual zypp::ByteCount bytesExpected() const
ProvideRequestRef _runningReq
void redirectTo(ProvideRequestRef startedReq, const zypp::Url &url)
State state() const
virtual void informalMessage(ProvideQueue &, ProvideRequestRef req, const ProvideMessage &msg)
const std::optional< ItemStats > & previousStats() const
friend class ProvidePrivate
Definition provideitem.h:32
virtual void released()
virtual void finishReq(ProvideQueue &queue, ProvideRequestRef finishedReq, const ProvideMessage &msg)
virtual void cancelWithError(std::exception_ptr error)=0
const std::optional< ItemStats > & currentStats() const
void updateState(const State newState)
friend class ProvideQueue
Definition provideitem.h:33
virtual bool enqueueRequest(ProvideRequestRef request)
SignalProxy< void(ProvideItem &item, State oldState, State newState)> sigStateChanged()
Url details namespace.
Definition UrlBase.cc:58
std::chrono::steady_clock::time_point _pulseTime
Definition provideitem.h:46
#define ZYPP_DECLARE_PRIVATE(Class)
Definition zyppglobal.h:87