Sfoglia il codice sorgente

meta: separate resolve.hpp file

Michele Caini 5 anni fa
parent
commit
9a67652c0c

+ 1 - 0
src/entt/entt.hpp

@@ -22,6 +22,7 @@
 #include "locator/locator.hpp"
 #include "meta/factory.hpp"
 #include "meta/meta.hpp"
+#include "meta/resolve.hpp"
 #include "meta/policy.hpp"
 #include "process/process.hpp"
 #include "process/scheduler.hpp"

+ 0 - 54
src/entt/meta/factory.hpp

@@ -834,60 +834,6 @@ inline meta_factory<Type> meta() ENTT_NOEXCEPT {
 }
 
 
-/**
- * @brief Returns the meta type associated with a given type.
- * @tparam Type Type to use to search for a meta type.
- * @return The meta type associated with the given type, if any.
- */
-template<typename Type>
-inline meta_type resolve() ENTT_NOEXCEPT {
-    return internal::meta_info<Type>::resolve();
-}
-
-
-/**
- * @brief Returns the first meta type that satisfies specific criteria, if any.
- * @tparam Func Type of the unary predicate to use to test the meta types.
- * @param func Unary predicate which returns ​true for the required element.
- * @return The first meta type satisfying the condition, if any.
- */
-template<typename Func>
-inline meta_type resolve_if(Func func) ENTT_NOEXCEPT {
-    return internal::find_if([&func](const auto *curr) {
-        return func(meta_type{curr});
-    }, *internal::meta_context::global);
-}
-
-
-/**
- * @brief Returns the meta type associated with a given identifier, if any.
- * @param id Unique identifier.
- * @return The meta type associated with the given identifier, if any.
- */
-inline meta_type resolve_id(const id_type id) ENTT_NOEXCEPT {
-    return resolve_if([id](const auto type) { return type.id() == id; });
-}
-
-
-/*! @copydoc resolve_id */
-[[deprecated("use entt::resolve_id instead")]]
-inline meta_type resolve(const id_type id) ENTT_NOEXCEPT {
-    return resolve_id(id);
-}
-
-
-/**
- * @brief Iterates all the reflected types.
- * @tparam Op Type of the function object to invoke.
- * @param op A valid function object.
- */
-template<typename Op>
-inline std::enable_if_t<std::is_invocable_v<Op, meta_type>, void>
-resolve(Op op) {
-    internal::visit<meta_type>(op, *internal::meta_context::global);
-}
-
-
 }
 
 

+ 69 - 0
src/entt/meta/resolve.hpp

@@ -0,0 +1,69 @@
+#ifndef ENTT_META_RESOLVE_HPP
+#define ENTT_META_RESOLVE_HPP
+
+
+#include <type_traits>
+#include "meta.hpp"
+
+
+namespace entt {
+
+
+/**
+ * @brief Returns the meta type associated with a given type.
+ * @tparam Type Type to use to search for a meta type.
+ * @return The meta type associated with the given type, if any.
+ */
+template<typename Type>
+inline meta_type resolve() ENTT_NOEXCEPT {
+    return internal::meta_info<Type>::resolve();
+}
+
+
+/**
+ * @brief Returns the first meta type that satisfies specific criteria, if any.
+ * @tparam Func Type of the unary predicate to use to test the meta types.
+ * @param func Unary predicate which returns ​true for the required element.
+ * @return The first meta type satisfying the condition, if any.
+ */
+template<typename Func>
+inline meta_type resolve_if(Func func) ENTT_NOEXCEPT {
+    return internal::find_if([&func](const auto *curr) {
+        return func(meta_type{curr});
+    }, *internal::meta_context::global);
+}
+
+
+/**
+ * @brief Returns the meta type associated with a given identifier, if any.
+ * @param id Unique identifier.
+ * @return The meta type associated with the given identifier, if any.
+ */
+inline meta_type resolve_id(const id_type id) ENTT_NOEXCEPT {
+    return resolve_if([id](const auto type) { return type.id() == id; });
+}
+
+
+/*! @copydoc resolve_id */
+[[deprecated("use entt::resolve_id instead")]]
+inline meta_type resolve(const id_type id) ENTT_NOEXCEPT {
+    return resolve_id(id);
+}
+
+
+/**
+ * @brief Iterates all the reflected types.
+ * @tparam Op Type of the function object to invoke.
+ * @param op A valid function object.
+ */
+template<typename Op>
+inline std::enable_if_t<std::is_invocable_v<Op, meta_type>, void>
+resolve(Op op) {
+    internal::visit<meta_type>(op, *internal::meta_context::global);
+}
+
+
+}
+
+
+#endif

+ 1 - 0
test/entt/meta/meta.cpp

@@ -7,6 +7,7 @@
 #include <entt/core/utility.hpp>
 #include <entt/meta/factory.hpp>
 #include <entt/meta/meta.hpp>
+#include <entt/meta/resolve.hpp>
 
 template<typename Type>
 void set(Type &prop, Type value) {

+ 1 - 0
test/lib/meta/main.cpp

@@ -2,6 +2,7 @@
 #include <entt/core/attribute.h>
 #include <entt/meta/factory.hpp>
 #include <entt/meta/meta.hpp>
+#include <entt/meta/resolve.hpp>
 #include "types.h"
 
 ENTT_API void set_up();

+ 1 - 0
test/lib/meta_plugin/main.cpp

@@ -4,6 +4,7 @@
 #include <gtest/gtest.h>
 #include <entt/meta/factory.hpp>
 #include <entt/meta/meta.hpp>
+#include <entt/meta/resolve.hpp>
 #include "types.h"
 
 TEST(Lib, Meta) {

+ 1 - 0
test/lib/meta_plugin_std/main.cpp

@@ -4,6 +4,7 @@
 #include <gtest/gtest.h>
 #include <entt/meta/factory.hpp>
 #include <entt/meta/meta.hpp>
+#include <entt/meta/resolve.hpp>
 #include "types.h"
 
 TEST(Lib, Meta) {