62 lines
1.3 KiB
C
62 lines
1.3 KiB
C
|
#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);
|
||
|
};
|