#pragma once #include #include #include #include #include #include #include #include #include "loggable.h" #include "component.h" #include "download.h" #include "taskmanager.h" class Collection : protected Loggable, public std::enable_shared_from_this { using Sources = std::set; using Downloads = std::map>; using Components = std::map>; public: Collection( const std::filesystem::path& destination, const std::string& target, const std::shared_ptr& logger, const std::shared_ptr& taskManager ); unsigned int sourcesTotal() const; unsigned int sourcesPending() const; unsigned int sourcesError() const; unsigned int sourcesSuccess() const; bool hasSource(const std::string& source) const; void addSource(const std::string& source); private: void sourceDownaloded(const std::string& source, TaskManager::Error err); void sourceRead(const std::string& source, TaskManager::Error err); void sourceBuilt(const std::string& source, TaskManager::Error err); static bool isRemote(const std::string& source); void queueDownload(const std::string& source); void queueRead(const std::string& source, const std::filesystem::path& location); bool _hasSource(const std::string& source) const; private: mutable std::mutex mutex; std::filesystem::path destination; std::string target; std::shared_ptr taskManager; Sources knownSources; Sources successSources; Downloads downloadingSources; Components readingSources; Components buildingSources; };