You.i Engine
YiAbstractDownloadHelper.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_ABSTRACT_DOWNLOAD_HELPER_H_
3 #define _YI_ABSTRACT_DOWNLOAD_HELPER_H_
4 
6 #include "network/YiUrl.h"
7 #include "signal/YiSignal.h"
9 
10 class CYIHTTPRequest;
11 class CYIHTTPResponse;
12 
24 {
25 public:
30  {
31  IDLE = 0,
33  };
34 
39  {
42  };
43 
49 
54 
56 
60  const CYIUrl &GetUrl() const;
61 
66  void SetUrl(const CYIUrl &url);
67 
71  void StartDownload();
72 
79  void StartDownload(const CYIUrl &url);
80 
84  void CancelDownload();
85 
90 
104 
105 protected:
109  virtual void OnRequestCompleted(const std::shared_ptr<CYIHTTPRequest> &, const std::shared_ptr<CYIHTTPResponse> &, bool);
110 
114  virtual void OnRequestFailed(const std::shared_ptr<CYIHTTPRequest> &pRequest);
115 
123  virtual void CancelDownloadImplementation() = 0;
124 
127  std::shared_ptr<CYIHTTPRequest> m_pCurrentRequest;
128  std::shared_ptr<CYIHTTPResponse> m_pCurrentResponse;
130 
131 private:
133 };
134 
139 #endif
#define YI_DISALLOW_COPY_AND_ASSIGN(TypeName)
Delete the copy constructor and assignment operator (and consequently the move constructor as well) ...
Definition: YiPredef.h:114
DOWNLOAD_STATE GetDownloadState() const
CYIUrl m_url
Definition: YiAbstractDownloadHelper.h:126
The url provided is empty.
Definition: YiAbstractDownloadHelper.h:40
CYISignal< const CYIUrl & > DownloadComplete
Definition: YiAbstractDownloadHelper.h:103
std::shared_ptr< CYIHTTPRequest > m_pCurrentRequest
Definition: YiAbstractDownloadHelper.h:127
CYIRecursiveMutex m_stateMutex
Definition: YiAbstractDownloadHelper.h:129
DOWNLOAD_STATE m_state
Definition: YiAbstractDownloadHelper.h:125
Contains information required to configure and perform a HTTP request.
Definition: YiHTTPRequest.h:34
The base class for an object accessible from script source code.
Definition: YiScriptableObject.h:28
Definition: YiRecursiveMutex.h:15
FAILURE_TYPE
Definition: YiAbstractDownloadHelper.h:38
virtual void CancelDownloadImplementation()=0
void SetUrl(const CYIUrl &url)
std::shared_ptr< CYIHTTPResponse > m_pCurrentResponse
Definition: YiAbstractDownloadHelper.h:128
An HTTP response class which includes the header and body portions of the response.
Definition: YiHTTPResponse.h:24
Definition: YiAbstractDownloadHelper.h:23
The download helper is downloading data.
Definition: YiAbstractDownloadHelper.h:32
A class used to encapsulate an URL.
Definition: YiUrl.h:24
CYISignal< const CYIUrl & > DownloadCancelled
Definition: YiAbstractDownloadHelper.h:99
Definition: YiSignalHandler.h:174
DOWNLOAD_STATE
Definition: YiAbstractDownloadHelper.h:29
CYISignal< FAILURE_TYPE, const CYIUrl & > DownloadFailed
Definition: YiAbstractDownloadHelper.h:95
virtual void OnRequestFailed(const std::shared_ptr< CYIHTTPRequest > &pRequest)
const CYIUrl & GetUrl() const
The download helper is not downloading data.
Definition: YiAbstractDownloadHelper.h:31
Signals and slots are a thread-safe and flexible communication framework that will allow various obje...
Definition: YiSignal.h:164
virtual void OnRequestCompleted(const std::shared_ptr< CYIHTTPRequest > &, const std::shared_ptr< CYIHTTPResponse > &, bool)
virtual ~CYIAbstractDownloadHelper()
An error occurred while downloading data.
Definition: YiAbstractDownloadHelper.h:41