mason/src2/component.h

56 lines
1.0 KiB
C
Raw Normal View History

2023-09-20 19:45:22 +00:00
#pragma once
#include <string>
#include <filesystem>
#include <memory>
#include <exception>
#include <functional>
#include "loggable.h"
#include "loggger.h"
class Collection;
2023-09-20 19:45:22 +00:00
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<Logger>& logger
);
Type getType() const;
State getState() const;
void read();
void build(const std::filesystem::path& destination, const std::string& target);
private:
State state;
Type type;
std::shared_ptr<Collection> collection;
std::filesystem::path location;
};
class Component::WrongState : public std::runtime_error {
public:
explicit WrongState(State state, const std::string& action);
};