some more thoughts of how to organize it better
This commit is contained in:
parent
02df7de0c3
commit
7b9112c0dd
8 changed files with 363 additions and 29 deletions
|
@ -3,23 +3,24 @@
|
|||
#include <array>
|
||||
#include <string_view>
|
||||
|
||||
#include "collection.h"
|
||||
|
||||
constexpr std::array<std::string_view, Component::done + 1> stringStates {
|
||||
"initial",
|
||||
"reading",
|
||||
"ready",
|
||||
"building",
|
||||
"error",
|
||||
"done"
|
||||
};
|
||||
|
||||
Component::Component(
|
||||
const std::filesystem::path& path,
|
||||
const std::shared_ptr<Collection>& collection,
|
||||
const std::shared_ptr<TaskManager>& taskManager,
|
||||
const std::shared_ptr<Logger>& logger
|
||||
):
|
||||
Loggable(logger),
|
||||
collection(collection),
|
||||
taskManager(taskManager),
|
||||
location(path)
|
||||
{}
|
||||
|
||||
|
@ -27,14 +28,13 @@ void Component::read() {
|
|||
if (state != initial)
|
||||
throw WrongState(state, "read");
|
||||
|
||||
try {
|
||||
collection->addSource(location);
|
||||
} catch (const Collection::DuplicateSource e) {
|
||||
state = error;
|
||||
throw e;
|
||||
}
|
||||
// try {
|
||||
// collection->addSource(location);
|
||||
// } catch (const Collection::DuplicateSource e) {
|
||||
// state = error;
|
||||
// throw e;
|
||||
// }
|
||||
state = reading;
|
||||
taskManager->queue(std::bind(&Component::performRead, this));
|
||||
}
|
||||
|
||||
void Component::build(const std::filesystem::path& destination, const std::string& target) {
|
||||
|
@ -42,13 +42,6 @@ void Component::build(const std::filesystem::path& destination, const std::strin
|
|||
throw WrongState(state, "build");
|
||||
|
||||
state = building;
|
||||
taskManager->queue(std::bind(&Component::performBuild, this, destination, target));
|
||||
}
|
||||
|
||||
void Component::performRead() {
|
||||
}
|
||||
|
||||
void Component::performBuild(std::filesystem::path destination, std::string target) {
|
||||
}
|
||||
|
||||
Component::State Component::getState() const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue