#pragma once #include #include #include #include #include #include #include #include #include #include #include "loggable.h" #include "loggger.h" class Collection; 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, const std::shared_ptr& logger ); Type getType() const; State getState() const; void read(); void build(const std::filesystem::path& destination, const std::string& target); private: void tryReadingBuildScenarios(); bool readAsMason(); bool errorScenario(const std::string& message); private: State state; Type type; std::shared_ptr collection; std::filesystem::path location; std::optional scenario; }; class Component::WrongState : public std::runtime_error { public: explicit WrongState(State state, const std::string& action); };