diff --git a/libs/ecs/include/psemek/ecs/declare_uuid.hpp b/libs/ecs/include/psemek/ecs/declare_uuid.hpp new file mode 100644 index 00000000..2a2ae1fb --- /dev/null +++ b/libs/ecs/include/psemek/ecs/declare_uuid.hpp @@ -0,0 +1,6 @@ +#pragma once + +#include + +#define psemek_declare_uuid(seed) \ + static ::psemek::util::uuid uuid() { static constexpr auto value = ::psemek::util::make_uuid(seed); return value; } diff --git a/libs/ecs/tests/apply.cpp b/libs/ecs/tests/apply.cpp index 1a5ba187..35d25cc1 100644 --- a/libs/ecs/tests/apply.cpp +++ b/libs/ecs/tests/apply.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -14,20 +15,14 @@ namespace { int value; - static constexpr util::uuid uuid() - { - return {1, 0}; - } + psemek_declare_uuid("component_1") }; struct component_2 { int value; - static constexpr util::uuid uuid() - { - return {2, 0}; - } + psemek_declare_uuid("component_2") }; } diff --git a/libs/ecs/tests/component.cpp b/libs/ecs/tests/component.cpp index 65dd7a39..91e694d7 100644 --- a/libs/ecs/tests/component.cpp +++ b/libs/ecs/tests/component.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -14,40 +15,28 @@ namespace { int value; - static constexpr util::uuid uuid() - { - return {1, 0}; - } + psemek_declare_uuid("component_small") }; struct component_big { int values[16]; - static constexpr util::uuid uuid() - { - return {2, 0}; - } + psemek_declare_uuid("component_big") }; struct component_noncopyable { std::unique_ptr value; - static constexpr util::uuid uuid() - { - return {2, 0}; - } + psemek_declare_uuid("component_noncopyable") }; struct component_counter { std::shared_ptr value; - static constexpr util::uuid uuid() - { - return {2, 0}; - } + psemek_declare_uuid("component_counter") }; } diff --git a/libs/ecs/tests/entity.cpp b/libs/ecs/tests/entity.cpp index 9fd3e52c..eced3bd6 100644 --- a/libs/ecs/tests/entity.cpp +++ b/libs/ecs/tests/entity.cpp @@ -1,8 +1,10 @@ #include #include +#include #include #include +#include using namespace psemek; using namespace psemek::ecs; @@ -14,20 +16,14 @@ namespace { int value; - static constexpr util::uuid uuid() - { - return {1, 0}; - } + psemek_declare_uuid("component_1") }; struct component_2 { int value; - static constexpr util::uuid uuid() - { - return {2, 0}; - } + psemek_declare_uuid("component_2") }; }