diff options
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); +}; |