file_upload_task.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
19 
22 
24 
25 #include <future>
26 #include <memory>
27 
28 #pragma once
29 
30 namespace Aws {
31 namespace FileManagement {
32 
38 template<typename T>
40  public:
42 
43  explicit FileUploadTask(
44  FileObject<T> &&batch_data,
45  FileUploadStatusFunc upload_status_function
46  ) : Aws::DataFlow::Task<T>()
47  {
48  this->batch_data_ = batch_data;
49  this->upload_status_function_ = upload_status_function;
50  }
51 
52  ~FileUploadTask() override = default;
53 
54  void onComplete(const Aws::DataFlow::UploadStatus &status) override {
57  }
58  }
59 
60  T& getBatchData() override {
61  return batch_data_.batch_data;
62  }
63 
64 private:
67 };
68 
74 template<typename T>
76  public:
78  FileObject<T> &&batch_data) : Aws::DataFlow::Task<T>()
79  {
80  this->batch_data_ = batch_data;
81  }
82 
83  virtual ~FileUploadTaskAsync() = default;
84 
85  void onComplete(const Aws::DataFlow::UploadStatus &status) override {
86  file_upload_promise_.set_value(
88  }
89 
90  inline std::future<std::pair<FileObject<T>, Aws::DataFlow::UploadStatus>> getResult() {
91  return file_upload_promise_.get_future();
92  }
93 
94  T& getBatchData() override {
95  return batch_data_.batch_data;
96  }
97 
98 private:
100  std::promise<std::pair<FileObject<T>, Aws::DataFlow::UploadStatus>> file_upload_promise_ = nullptr;
101 };
102 
103 //------------- Definitions --------------//
104 template<typename T>
105 using TaskPtr = std::shared_ptr<Aws::DataFlow::Task<T>>;
106 
107 template<typename T>
108 using FileUploadTaskPtr = std::shared_ptr<FileUploadTask<T>>;
109 
110 template<typename T>
112 
113 template<typename T>
115 
116 template<typename T>
118 //----------------------------------------//
119 
120 } // namespace FileManagement
121 } // namespace Aws
FileUploadTask(FileObject< T > &&batch_data, FileUploadStatusFunc upload_status_function)
void onComplete(const Aws::DataFlow::UploadStatus &status) override
std::function< void(const Status &upload_status, const T &message)> UploadStatusFunction
Aws::DataFlow::UploadStatusFunction< Aws::DataFlow::UploadStatus, FileObject< T >> FileUploadStatusFunc
FileUploadStatusFunc upload_status_function_
std::shared_ptr< FileUploadTask< T >> FileUploadTaskPtr
std::future< std::pair< FileObject< T >, Aws::DataFlow::UploadStatus > > getResult()
FileUploadTaskAsync(FileObject< T > &&batch_data)
void onComplete(const Aws::DataFlow::UploadStatus &status) override
std::shared_ptr< Aws::DataFlow::Task< T >> TaskPtr


file_management
Author(s): AWS RoboMaker
autogenerated on Fri May 7 2021 02:18:23