CARLA
CustomFileDownloader.h
Go to the documentation of this file.
1 // Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB). This work is licensed under the terms of the MIT license. For a copy, see <https://opensource.org/licenses/MIT>.
2 
3 #pragma once
4 
5 #include "CoreMinimal.h"
6 #include "Interfaces/IHttpRequest.h"
7 #include "CustomFileDownloader.generated.h"
8 /**
9  *
10  */
11 
12 DECLARE_DELEGATE(FDownloadComplete)
13 
14 UCLASS(Blueprintable)
15 class CARLA_API UCustomFileDownloader : public UObject
16 {
17  GENERATED_BODY()
18 public:
19  UFUNCTION(BlueprintCallable)
20  void StartDownload();
21  UFUNCTION(BlueprintCallable)
22  void ConvertOSMInOpenDrive(FString FilePath, float Lat_0 = 0, float Lon_0 = 0);
23 
24  FString ResultFileName;
25 
26  FString Url;
27 
28  FDownloadComplete DownloadDelegate;
29 
30 private:
31  void RequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded);
32 
33  FString Payload;
34 };
35 
37 {
38 public:
39  /**
40  *
41  * @param Verb - verb to use for request (GET,POST,DELETE,etc)
42  * @param Url - url address to connect to
43  */
44  FHttpDownloader( const FString& InVerb, const FString& InUrl, const FString& InFilename, FDownloadComplete& Delegate );
45 
46  // Kick off the Http request and wait for delegate to be called
47  void Run(void);
48 
49  /**
50  * Delegate called when the request completes
51  *
52  * @param HttpRequest - object that started/processed the request
53  * @param HttpResponse - optional response object if request completed
54  * @param bSucceeded - true if Url connection was made and response was received
55  */
56  void RequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded);
57 
58 private:
59  FString Verb;
60  FString Url;
61  FString Filename;
62  FDownloadComplete DelegateToCall;
63 };
FHttpDownloader(const FString &InVerb, const FString &InUrl, const FString &InFilename, FDownloadComplete &Delegate)
FDownloadComplete DelegateToCall
FDownloadComplete DownloadDelegate
void RequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
Delegate called when the request completes.