Added EC/Meta/Morph.hpp

Started work on EC/Manager.hpp
This commit is contained in:
Stephen Seo 2016-03-04 22:59:43 +09:00
parent f99e7c69ca
commit 1926a9eabb
5 changed files with 81 additions and 0 deletions

View file

@ -7,6 +7,7 @@ set(EntityComponentSystem_HEADERS
EC/Meta/Contains.hpp
EC/Meta/ContainsAll.hpp
EC/Meta/IndexOf.hpp
EC/Meta/Morph.hpp
EC/Meta/Meta.hpp
EC/Bitset.hpp
EC/EC.hpp)

20
src/EC/Manager.hpp Normal file
View file

@ -0,0 +1,20 @@
#ifndef EC_MANAGER_HPP
#define EC_MANAGER_HPP
namespace EC
{
template <typename ComponentsList, typename TagsList, typename Signatures>
struct Manager
{
public:
using Combined = EC::Meta::Combine<ComponentsList, TagsList>;
private:
using BitsetType = EC::Bitset<ComponentsList, TagsList>;
};
}
#endif

View file

@ -4,4 +4,5 @@
#include "Contains.hpp"
#include "ContainsAll.hpp"
#include "IndexOf.hpp"
#include "Morph.hpp"

28
src/EC/Meta/Morph.hpp Normal file
View file

@ -0,0 +1,28 @@
#ifndef EC_META_MORPH_HPP
#define EC_META_MORPH_HPP
#include "TypeList.hpp"
namespace EC
{
namespace Meta
{
template <typename TypeA, typename TypeB>
struct MorphHelper
{
};
template <template <typename...> class TypeA, template <typename...> class TypeB, typename... TypesA, typename... TypesB>
struct MorphHelper<TypeA<TypesA...>, TypeB<TypesB...> >
{
using type = TypeB<TypesA...>;
};
template <typename TypeA, typename TypeB>
using Morph = typename MorphHelper<TypeA, TypeB>::type;
}
}
#endif

View file

@ -1,6 +1,7 @@
#include <gtest/gtest.h>
#include <tuple>
#include <EC/Meta/Meta.hpp>
#include <EC/EC.hpp>
@ -125,3 +126,33 @@ TEST(Meta, Combine)
EXPECT_EQ(combinedAllTemp, listAllTemp);
}
TEST(Meta, Morph)
{
using TupleAll = std::tuple<C0, C1, C2, C3>;
using MorphedTuple = EC::Meta::Morph<TupleAll, EC::Meta::TypeList<> >;
int morphedTupleTemp = MorphedTuple::size;
int componentsTemp = ListComponentsAll::size;
EXPECT_EQ(morphedTupleTemp, componentsTemp);
morphedTupleTemp = EC::Meta::IndexOf<C0, MorphedTuple>::value;
componentsTemp = EC::Meta::IndexOf<C0, ListComponentsAll>::value;
EXPECT_EQ(morphedTupleTemp, componentsTemp);
morphedTupleTemp = EC::Meta::IndexOf<C1, MorphedTuple>::value;
componentsTemp = EC::Meta::IndexOf<C1, ListComponentsAll>::value;
EXPECT_EQ(morphedTupleTemp, componentsTemp);
morphedTupleTemp = EC::Meta::IndexOf<C2, MorphedTuple>::value;
componentsTemp = EC::Meta::IndexOf<C2, ListComponentsAll>::value;
EXPECT_EQ(morphedTupleTemp, componentsTemp);
morphedTupleTemp = EC::Meta::IndexOf<C3, MorphedTuple>::value;
componentsTemp = EC::Meta::IndexOf<C3, ListComponentsAll>::value;
EXPECT_EQ(morphedTupleTemp, componentsTemp);
using MorphedComponents = EC::Meta::Morph<ListComponentsAll, std::tuple<> >;
bool isSame = std::is_same<MorphedComponents, TupleAll>::value;
EXPECT_TRUE(isSame);
}