refactoring seems to be done, added ability to specify files as dependencies
This commit is contained in:
parent
b07d017f86
commit
2b913d1d42
21 changed files with 148 additions and 793 deletions
60
src/collection.h
Normal file
60
src/collection.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <exception>
|
||||
#include <string_view>
|
||||
#include <regex>
|
||||
#include <mutex>
|
||||
|
||||
#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);
|
||||
|
||||
bool _hasSource(const std::string& source) const;
|
||||
|
||||
private:
|
||||
mutable std::mutex mutex;
|
||||
std::filesystem::path destination;
|
||||
std::string target;
|
||||
std::shared_ptr<TaskManager> taskManager;
|
||||
Sources knownSources;
|
||||
Sources successSources;
|
||||
Downloads downloadingSources;
|
||||
Components readingSources;
|
||||
Components buildingSources;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue