mason/src2/collection.h

62 lines
1.7 KiB
C
Raw Normal View History

2023-09-17 19:34:00 +00:00
#pragma once
#include <string>
#include <filesystem>
#include <map>
#include <set>
#include <exception>
#include "loggable.h"
#include "component.h"
#include "taskmanager.h"
class Collection : protected Loggable {
2023-09-17 19:34:00 +00:00
public:
class UnknownSource;
class DuplicateSource;
class DuplicatePath;
Collection(
const std::shared_ptr<Logger>& logger,
const std::shared_ptr<TaskManager>& taskManager
);
2023-09-17 19:34:00 +00:00
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 sourceDownloadError(const std::string& source);
void sourceBuildError(const std::string& source);
void sourceDownaloded(const std::string& source);
void sourceBuilt(const std::string& source);
private:
std::shared_ptr<TaskManager> taskManager;
2023-09-17 19:34:00 +00:00
std::set<std::string> errorSources;
std::set<std::string> pendingSources;
std::map<std::string, std::unique_ptr<Component>> failedSources;
std::map<std::string, std::unique_ptr<Component>> downloadedSources;
std::map<std::string, std::unique_ptr<Component>> buildingSources;
std::map<std::string, std::unique_ptr<Component>> successSources;
2023-09-17 19:34:00 +00:00
};
2023-09-20 19:45:22 +00:00
class Collection::UnknownSource : public std::runtime_error {
2023-09-17 19:34:00 +00:00
public:
2023-09-20 19:45:22 +00:00
explicit UnknownSource(const std::string& source);
2023-09-17 19:34:00 +00:00
};
2023-09-20 19:45:22 +00:00
class Collection::DuplicateSource : public std::runtime_error {
2023-09-17 19:34:00 +00:00
public:
2023-09-20 19:45:22 +00:00
explicit DuplicateSource(const std::string& source);
2023-09-17 19:34:00 +00:00
};
2023-09-20 19:45:22 +00:00
class Collection::DuplicatePath : public std::runtime_error {
2023-09-17 19:34:00 +00:00
public:
2023-09-20 19:45:22 +00:00
explicit DuplicatePath(const std::string& source, const std::filesystem::path& path);
2023-09-17 19:34:00 +00:00
};