libzypp  17.36.3
OptionalDownloadProgressReport.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
9 #ifndef ZYPP_MEDIA_DETAIL_OPTIONALDOWNLOADPROGRESSREPORT_INCLUDED
10 #define ZYPP_MEDIA_DETAIL_OPTIONALDOWNLOADPROGRESSREPORT_INCLUDED
11 
12 #include <zypp/ZYppCallbacks.h>
13 #include <zypp/Callback.h>
14 
15 
16 namespace internal {
17 
21  struct OptionalDownloadProgressReport : public zypp::callback::ReceiveReport<zypp::media::DownloadProgressReport>
22  {
23  using TimePoint = std::chrono::steady_clock::time_point;
24 
25  OptionalDownloadProgressReport( bool isOptional=false );
26 
31 
33 
34  void reportbegin() override;
35 
36  void reportend() override;
37 
38  void report( const UserData & userData_r = UserData() ) override;
39 
40  void start( const zypp::Url & file_r, zypp::Pathname localfile_r ) override;
41 
42  bool progress( int value_r, const zypp::Url & file_r, double dbps_avg_r = -1, double dbps_current_r = -1 ) override;
43 
44  Action problem( const zypp::Url & file_r, Error error_r, const std::string & description_r ) override;
45 
46  void finish( const zypp::Url & file_r, Error error_r, const std::string & reason_r ) override;
47 
48  private:
49  // _isOptional also indicates the delayed start
50  bool notStarted() const;
51 
52  void sendStart();
53 
54  private:
55  Receiver *const _oldRec;
60  };
61 
62 
63 }
64 
65 
66 #endif
std::chrono::steady_clock::time_point TimePoint
ReceiveReport< zypp::media::DownloadProgressReport > Receiver
Definition: Callback.h:171
callback::UserData UserData
Definition: Callback.h:151
bool progress(int value_r, const zypp::Url &file_r, double dbps_avg_r=-1, double dbps_current_r=-1) override
Download progress.
Bottleneck filtering all DownloadProgressReport issued from Media[Muli]Curl.
Action problem(const zypp::Url &file_r, Error error_r, const std::string &description_r) override
OptionalDownloadProgressReport & operator=(const OptionalDownloadProgressReport &)=delete
Typesafe passing of user data via callbacks.
Definition: UserData.h:39
void start(const zypp::Url &file_r, zypp::Pathname localfile_r) override
void report(const UserData &userData_r=UserData()) override
The most generic way of sending/receiving data.
void finish(const zypp::Url &file_r, Error error_r, const std::string &reason_r) override
Url manipulation class.
Definition: Url.h:92