mason/src2/collection.h

47 lines
1.2 KiB
C++

#pragma once
#include <string>
#include <filesystem>
#include <map>
#include <set>
#include <exception>
class Collection {
public:
class UnknownSource;
class DuplicateSource;
class DuplicatePath;
Collection();
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);
void sourceError(const std::string& source);
void sourceSuccess(const std::string& source, const std::filesystem::path& path);
private:
std::set<std::string> errorSources;
std::set<std::string> pendingSources;
std::map<std::string, std::filesystem::path> successSources; //would be nice to have a bimap here
};
class Collection::UnknownSource : public std::runtime_error {
public:
explicit UnknownSource(const std::string& source);
};
class Collection::DuplicateSource : public std::runtime_error {
public:
explicit DuplicateSource(const std::string& source);
};
class Collection::DuplicatePath : public std::runtime_error {
public:
explicit DuplicatePath(const std::string& source, const std::filesystem::path& path);
};