You.i Engine
YiAssetDownloadHelper.h
Go to the documentation of this file.
1 // © You i Labs Inc. All rights reserved.
2 #ifndef _YI_ASSET_DOWNLOAD_HELPER_H_
3 #define _YI_ASSET_DOWNLOAD_HELPER_H_
4 
5 #include "asset/YiAsset.h"
6 #include "asset/YiAssetLoader.h"
8 
9 class CYIHTTPRequest;
10 class CYIHTTPResponse;
11 class IYINetworkService;
12 
25 {
26 public:
27  enum class DownloadState
28  {
31  };
32 
33  enum class FailureType
34  {
36  NetworkError = (size_t)CYIDownloadHelper::FailureType::NetworkError,
37  InvalidAsset
38  };
39 
46 
47  virtual ~CYIAssetDownloadHelper();
48 
53 
67 
68 protected:
69  virtual void StartDownloadImpl() override;
70 
77  virtual void OnRequestCompleted(const std::shared_ptr<CYIHTTPRequest> &pRequest, const std::shared_ptr<CYIHTTPResponse> &pResponse, bool cachedResponse) override;
78 
82  virtual void OnDecodeComplete(int32_t jobID, std::shared_ptr<CYIAsset> pAsset, int32_t loadStatus, void *pListenerPrivate) override;
83 
87  virtual void CancelDownloadImplementation() override;
88 
89 private:
93 
97  void StartLocalAssetFetch();
98 
102  bool IsLocalAsset() const;
103 
107  void OnNetworkDecodeComplete(int32_t jobID, std::shared_ptr<CYIAsset> pAsset, int32_t loadStatus, void *pListenerPrivate);
108 
112  void OnLocalDecodeComplete(int32_t jobID, std::shared_ptr<CYIAsset> pAsset, int32_t loadStatus, void *pListenerPrivate);
113 
117  bool IsValidAsset(std::shared_ptr<CYIAsset> pAsset) const;
118 
122  void ConvertDownloadFailedSignals(CYIDownloadHelper::FailureType, const CYIUrl & /*url*/);
123 
124  int32_t m_assetLoaderJobID;
125 
127 };
128 
133 #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:69
FailureType
Definition: YiAssetDownloadHelper.h:33
DownloadState GetDownloadState() const
Listener interface for asynchronously decoded asset objects.
Definition: YiAssetLoader.h:51
CYISignal< const CYIUrl &> AssetDownloadCancelled
Definition: YiAssetDownloadHelper.h:66
Contains information required to configure and perform a HTTP request.
Definition: YiHTTPRequest.h:36
FailureType
Definition: YiDownloadHelper.h:41
The download helper is downloading data.
virtual void CancelDownloadImplementation() override
The base interface class for HTTP Service CYIHTTPService.
Definition: YiNetworkService.h:17
CYISignal< const CYIUrl &> DownloadComplete
Definition: YiDownloadHelper.h:103
DownloadState
Definition: YiAssetDownloadHelper.h:27
An HTTP response class which includes the header and body portions of the response.
Definition: YiHTTPResponse.h:25
CYISignal< FailureType, const CYIUrl &> AssetDownloadFailed
Definition: YiAssetDownloadHelper.h:62
virtual ~CYIAssetDownloadHelper()
CYISignal< const CYIUrl &> DownloadCancelled
Definition: YiDownloadHelper.h:99
virtual void OnRequestCompleted(const std::shared_ptr< CYIHTTPRequest > &pRequest, const std::shared_ptr< CYIHTTPResponse > &pResponse, bool cachedResponse) override
A class used to encapsulate an URL.
Definition: YiUrl.h:24
virtual void OnDecodeComplete(int32_t jobID, std::shared_ptr< CYIAsset > pAsset, int32_t loadStatus, void *pListenerPrivate) override
Definition: YiDownloadHelper.h:26
A download helper class used for downloading assets off of web servers or locally when a local path U...
Definition: YiAssetDownloadHelper.h:24
The download helper is not downloading data.
An error occurred while downloading data.
unsigned int size_t
Definition: YiPredefLinux.h:10
CYISignal< const std::shared_ptr< CYIAsset > &, const CYIUrl &> AssetReady
Definition: YiAssetDownloadHelper.h:57
virtual void StartDownloadImpl() override
Signals and slots are a thread-safe and flexible communication framework that will allow various obje...
Definition: YiSignal.h:169
CYISignal< FailureType, const CYIUrl &> DownloadFailed
Definition: YiDownloadHelper.h:95