#include #include #include #include #include #define MAKE_COMPONENT_TAG(x) \ namespace tag \ { \ constexpr decltype(auto) x = ::ecs::tag::component::value; \ constexpr decltype(auto) warning_supressor_##x() { (void) x; } \ } #define MAKE_SYSTEM_TAG(x) \ namespace tag \ { \ constexpr decltype(auto) x = ::ecs::tag::system::value; \ constexpr decltype(auto) warning_supressor_##x() { (void) x; } \ } namespace test { namespace component { struct position { double x; double y; }; struct velocity { double x; double y; }; struct acceleration { double x; double y; }; struct test { }; MAKE_COMPONENT_TAG(position) MAKE_COMPONENT_TAG(velocity) MAKE_COMPONENT_TAG(acceleration) MAKE_COMPONENT_TAG(test) } namespace system { struct accelerate { }; struct move { }; struct render { }; struct foo { }; MAKE_SYSTEM_TAG(accelerate) MAKE_SYSTEM_TAG(move) MAKE_SYSTEM_TAG(render) MAKE_SYSTEM_TAG(foo) } } using namespace test; namespace c = component; namespace ct = c::tag; namespace cs = ecs::signature::component; namespace csl = ecs::signature_list::component; namespace s = system; namespace st = s::tag; namespace ss = ecs::signature::system; namespace ssl = ecs::signature_list::system; constexpr size_t storage_size = 1024; constexpr decltype(auto) cs_position = cs::make(ct::position) .storage(cs::storage::dynamic); constexpr decltype(auto) cs_velocity = cs::make(ct::velocity) .storage(cs::storage::dynamic); constexpr decltype(auto) cs_acceleration = cs::make(ct::acceleration) .storage(cs::storage::dynamic); constexpr decltype(auto) cs_test = cs::make(ct::test) .storage(cs::storage::dynamic); constexpr decltype(auto) cs_list = csl::make( cs_position, cs_velocity, cs_acceleration, cs_test); constexpr decltype(auto) ss_foo = ss::make(st::foo) .write(ct::test); constexpr decltype(auto) ss_accelerate = ss::make(st::accelerate) .read(ct::acceleration) .write(ct::velocity); constexpr decltype(auto) ss_move = ss::make(st::move) .read(ct::velocity) .write(ct::position); constexpr decltype(auto) ss_render = ss::make(st::render) .read(ct::velocity, ct::position, ct::acceleration, ct::test); constexpr decltype(auto) ss_list = ssl::make( ss_foo, ss_accelerate, ss_move, ss_render); constexpr decltype(auto) settings = ::ecs::settings::make() .component_signatures(cs_list) .system_signatures (ss_list); namespace sea = ::ecs::system_execution_adapter; TEST(DummyTest, fuu) { auto context = ::ecs::context::make(settings); context.step([](auto& step_proxy){ step_proxy.execute_systems()( sea::tags(st::foo) .for_subtasks([](auto& s, auto& data){ std::cout << "foo" << std::endl << " " << type_helper::name() << std::endl; }), sea::tags(st::accelerate) .for_subtasks([](auto& s, auto& data){ std::cout << "accelerate" << std::endl << " " << type_helper::name() << std::endl; }), sea::tags(st::move) .for_subtasks([](auto& s, auto& data){ std::cout << "move" << std::endl << " " << type_helper::name() << std::endl; }), sea::tags(st::render) .for_subtasks([](auto& s, auto& data){ std::cout << "render" << std::endl << " " << type_helper::name() << std::endl; }) ); }); }