From c318121dc8b877b061233a1328aabe68182cba5f Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 4 Mar 2016 20:20:56 +0900 Subject: [PATCH] Split Meta.hpp --- src/CMakeLists.txt | 4 ++- src/EC/Meta.hpp | 59 ---------------------------------------- src/EC/Meta/Contains.hpp | 33 ++++++++++++++++++++++ src/EC/Meta/IndexOf.hpp | 33 ++++++++++++++++++++++ src/EC/Meta/Meta.hpp | 5 ++++ src/EC/Meta/TypeList.hpp | 21 ++++++++++++++ src/test/MetaTest.cpp | 2 +- 7 files changed, 96 insertions(+), 61 deletions(-) delete mode 100644 src/EC/Meta.hpp create mode 100644 src/EC/Meta/Contains.hpp create mode 100644 src/EC/Meta/IndexOf.hpp create mode 100644 src/EC/Meta/Meta.hpp create mode 100644 src/EC/Meta/TypeList.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8b8ca51..b32d907 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.0) project(EntityComponentSystem) set(EntityComponentSystem_HEADERS - EC/Meta.hpp) + EC/Meta/TypeList.hpp + EC/Meta/Contains.hpp + EC/Meta/IndexOf.hpp) add_library(EntityComponentSystem INTERFACE) target_include_directories(EntityComponentSystem INTERFACE ${CMAKE_SOURCE_DIR}) diff --git a/src/EC/Meta.hpp b/src/EC/Meta.hpp deleted file mode 100644 index ab62b74..0000000 --- a/src/EC/Meta.hpp +++ /dev/null @@ -1,59 +0,0 @@ - -#ifndef EC_META_HPP -#define EC_META_HPP - -#include - -namespace EC -{ - namespace Meta - { - template - struct TypeList - { - static constexpr std::size_t size{sizeof...(Types)}; - - }; - - template - struct ContainsHelper : - std::false_type - { - }; - - template - struct ContainsHelper > : - std::conditional< - std::is_same::value, - std::true_type, - ContainsHelper > - >::type - { - }; - - template - using Contains = std::integral_constant::value >; - - template - struct IndexOf - { - }; - - template - struct IndexOf > : - std::integral_constant - { - }; - - template - struct IndexOf > : - std::integral_constant >::value - > - { - }; - } -} - -#endif - diff --git a/src/EC/Meta/Contains.hpp b/src/EC/Meta/Contains.hpp new file mode 100644 index 0000000..4dc32c8 --- /dev/null +++ b/src/EC/Meta/Contains.hpp @@ -0,0 +1,33 @@ + +#ifndef EC_META_CONTAINS_HPP +#define EC_META_CONTAINS_HPP + +#include "TypeList.hpp" + +namespace EC +{ + namespace Meta + { + template + struct ContainsHelper : + std::false_type + { + }; + + template + struct ContainsHelper > : + std::conditional< + std::is_same::value, + std::true_type, + ContainsHelper > + >::type + { + }; + + template + using Contains = std::integral_constant::value >; + } +} + +#endif + diff --git a/src/EC/Meta/IndexOf.hpp b/src/EC/Meta/IndexOf.hpp new file mode 100644 index 0000000..8adf44f --- /dev/null +++ b/src/EC/Meta/IndexOf.hpp @@ -0,0 +1,33 @@ + +#ifndef EC_META_INDEX_OF_HPP +#define EC_META_INDEX_OF_HPP + +#include "TypeList.hpp" + +namespace EC +{ + namespace Meta + { + template + struct IndexOf + { + }; + + template + struct IndexOf > : + std::integral_constant + { + }; + + template + struct IndexOf > : + std::integral_constant >::value + > + { + }; + } +} + +#endif + diff --git a/src/EC/Meta/Meta.hpp b/src/EC/Meta/Meta.hpp new file mode 100644 index 0000000..69c2206 --- /dev/null +++ b/src/EC/Meta/Meta.hpp @@ -0,0 +1,5 @@ + +#include "TypeList.hpp" +#include "Contains.hpp" +#include "IndexOf.hpp" + diff --git a/src/EC/Meta/TypeList.hpp b/src/EC/Meta/TypeList.hpp new file mode 100644 index 0000000..560dbe9 --- /dev/null +++ b/src/EC/Meta/TypeList.hpp @@ -0,0 +1,21 @@ + +#ifndef EC_META_TYPE_LIST_HPP +#define EC_META_TYPE_LIST_HPP + +#include + +namespace EC +{ + namespace Meta + { + template + struct TypeList + { + static constexpr std::size_t size{sizeof...(Types)}; + + }; + } +} + +#endif + diff --git a/src/test/MetaTest.cpp b/src/test/MetaTest.cpp index 26c32fa..3bb4ea8 100644 --- a/src/test/MetaTest.cpp +++ b/src/test/MetaTest.cpp @@ -1,7 +1,7 @@ #include -#include +#include struct C0 {}; struct C1 {};