diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-12-24 22:03:59 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-12-24 22:03:59 +0100 |
commit | 2b1145fb0aec3feb9cbab2df9be57ab43fc7f975 (patch) | |
tree | f6024cb81077756f5a51d1f70c34420e3c22d249 /oop2eindopdr/DownloadManager.h | |
parent | 21b9726e8a371c193ab326259d22dd4cd0b69898 (diff) |
WIP download manager
Diffstat (limited to 'oop2eindopdr/DownloadManager.h')
-rw-r--r-- | oop2eindopdr/DownloadManager.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/oop2eindopdr/DownloadManager.h b/oop2eindopdr/DownloadManager.h index 45dcbb0..c98ae67 100644 --- a/oop2eindopdr/DownloadManager.h +++ b/oop2eindopdr/DownloadManager.h @@ -1,3 +1,35 @@ #pragma once +#include <string> +#include <thread> +#include <vector> +class DownloadManager { +private: + const unsigned max_files = 50; + + std::vector<std::thread*> download_queue = {}; + std::vector<std::fstream*> file_queue = {}; + + /** + * @brief open file in DownloadManager (THREAD-ONLY) + * + * this function opens a file, but blocks until a slot is available, so + * should only be used in threads + */ + std::fstream* open_file(std::string filename); + /** + * @brief close file in DownloadManager (THREAD-ONLY) + * + * this function closes a file and removes it's pointer from the file_queue + * vector + */ + void close_file(std::fstream* file_ptr); + +public: + DownloadManager(); + virtual ~DownloadManager(); + + /** @brief downlaod `url` to `file` and close `file` when done */ + virtual std::thread* wget(std::string url, std::string filename); +}; |