just some more thoughts
This commit is contained in:
parent
ec63dc655b
commit
02df7de0c3
11 changed files with 163 additions and 143 deletions
61
src2/component.h
Normal file
61
src2/component.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
|
||||
#include "loggable.h"
|
||||
#include "loggger.h"
|
||||
#include "collection.h"
|
||||
#include "taskmanager.h"
|
||||
|
||||
class Component : protected Loggable {
|
||||
public:
|
||||
class WrongState;
|
||||
enum State {
|
||||
initial,
|
||||
reading,
|
||||
ready,
|
||||
building,
|
||||
error,
|
||||
done
|
||||
};
|
||||
|
||||
enum Type {
|
||||
unknown,
|
||||
file,
|
||||
directory,
|
||||
mason
|
||||
};
|
||||
|
||||
Component(
|
||||
const std::filesystem::path& path,
|
||||
const std::shared_ptr<Collection>& collection,
|
||||
const std::shared_ptr<TaskManager>& taskManager,
|
||||
const std::shared_ptr<Logger>& logger
|
||||
);
|
||||
|
||||
Type getType() const;
|
||||
State getState() const;
|
||||
|
||||
void read();
|
||||
void build(const std::filesystem::path& destination, const std::string& target);
|
||||
|
||||
private:
|
||||
void performRead();
|
||||
void performBuild(std::filesystem::path destination, std::string target);
|
||||
|
||||
private:
|
||||
State state;
|
||||
Type type;
|
||||
std::shared_ptr<Collection> collection;
|
||||
std::shared_ptr<TaskManager> taskManager;
|
||||
std::filesystem::path location;
|
||||
};
|
||||
|
||||
class Component::WrongState : public std::runtime_error {
|
||||
public:
|
||||
explicit WrongState(State state, const std::string& action);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue