57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <filesystem>
|
|
#include <map>
|
|
#include <set>
|
|
#include <exception>
|
|
#include <string_view>
|
|
#include <regex>
|
|
|
|
#include "loggable.h"
|
|
#include "component.h"
|
|
#include "download.h"
|
|
#include "taskmanager.h"
|
|
|
|
class Collection : protected Loggable, public std::enable_shared_from_this<Collection> {
|
|
using Sources = std::set<std::string>;
|
|
using Downloads = std::map<std::string, std::unique_ptr<Download>>;
|
|
using Components = std::map<std::string, std::unique_ptr<Component>>;
|
|
|
|
public:
|
|
Collection(
|
|
const std::filesystem::path& destination,
|
|
const std::string& target,
|
|
const std::shared_ptr<Logger>& logger,
|
|
const std::shared_ptr<TaskManager>& 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);
|
|
|
|
private:
|
|
std::filesystem::path destination;
|
|
std::string target;
|
|
std::shared_ptr<TaskManager> taskManager;
|
|
Sources knownSources;
|
|
Sources successSources;
|
|
Downloads downloadingSources;
|
|
Components readingSources;
|
|
Components buildingSources;
|
|
};
|