#pragma once #include #include namespace Seele { template struct Dependencies; template<> struct Dependencies<> { int x; }; template struct Dependencies : public Dependencies { template Dependencies operator|(const Dependencies& other) { return Dependencies(); } int x; }; namespace Component { template static int accessComponent(Comp& comp); } template concept has_dependencies = requires(Comp) { Comp::dependencies; }; #define REQUIRE_COMPONENT(x) \ private: \ x& get##x() { return *tl_##x; } \ const x& get##x() const { return *tl_##x; }; \ public: \ constexpr static Dependencies dependencies; #define DECLARE_COMPONENT(x) \ thread_local extern x* tl_##x; \ template<> \ int accessComponent(x& val) { tl_##x = &val; return 0; } #define DEFINE_COMPONENT(x) \ thread_local x* Seele::Component::tl_##x; } // namespace Seele