mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-05 06:40:09 +00:00
Merge branch 'esmstore-round-2' into 'master'
More ESMStore cleanup See merge request OpenMW/openmw!2383
This commit is contained in:
commit
95ad1d91df
@ -316,13 +316,6 @@ void ESMStore::setIdType(const std::string& id, ESM::RecNameInts type)
|
|||||||
mStoreImp->mIds[id] = type;
|
mStoreImp->mIds[id] = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::size_t sTypeIndexCounter = 0;
|
|
||||||
|
|
||||||
std::size_t ESMStore::geNextTypeIndex()
|
|
||||||
{
|
|
||||||
return sTypeIndexCounter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESM::LuaScriptsCfg ESMStore::getLuaScriptsCfg() const
|
ESM::LuaScriptsCfg ESMStore::getLuaScriptsCfg() const
|
||||||
{
|
{
|
||||||
ESM::LuaScriptsCfg cfg;
|
ESM::LuaScriptsCfg cfg;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <components/esm/luascripts.hpp>
|
#include <components/esm/luascripts.hpp>
|
||||||
#include <components/esm3/loadgmst.hpp>
|
#include <components/esm3/loadgmst.hpp>
|
||||||
|
#include <components/misc/tuplemeta.hpp>
|
||||||
|
|
||||||
#include "store.hpp"
|
#include "store.hpp"
|
||||||
|
|
||||||
@ -125,22 +126,11 @@ namespace MWWorld
|
|||||||
// Special entry which is hardcoded and not loaded from an ESM
|
// Special entry which is hardcoded and not loaded from an ESM
|
||||||
Store<ESM::Attribute >>;
|
Store<ESM::Attribute >>;
|
||||||
|
|
||||||
template <class T, class Tuple>
|
|
||||||
struct HasMember;
|
|
||||||
|
|
||||||
template <class T, class ... Args>
|
|
||||||
struct HasMember<T, std::tuple<Store<Args> ...>> {
|
|
||||||
static constexpr bool value = (std::is_same_v<T, Args> || ...);
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::size_t geNextTypeIndex();
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::size_t getTypeIndex()
|
static constexpr std::size_t getTypeIndex()
|
||||||
{
|
{
|
||||||
static_assert(HasMember<T, StoreTuple>::value);
|
static_assert(Misc::TupleHasType<Store<T>, StoreTuple>::value);
|
||||||
static std::size_t sIndex = geNextTypeIndex();
|
return Misc::TupleTypeIndex<Store<T>, StoreTuple>::value;
|
||||||
return sIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ESMStoreImp> mStoreImp;
|
std::unique_ptr<ESMStoreImp> mStoreImp;
|
||||||
|
35
components/misc/tuplemeta.hpp
Normal file
35
components/misc/tuplemeta.hpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef OPENMW_COMPONENTS_MISC_META_H
|
||||||
|
#define OPENMW_COMPONENTS_MISC_META_H
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <tuple>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace Misc
|
||||||
|
{
|
||||||
|
template <class T, class Tuple>
|
||||||
|
struct TupleHasType;
|
||||||
|
|
||||||
|
template <class T, class... Args>
|
||||||
|
struct TupleHasType<T, std::tuple<Args...>>
|
||||||
|
{
|
||||||
|
static constexpr bool value = (std::is_same_v<T, Args> || ...);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class Tuple>
|
||||||
|
struct TupleTypeIndex;
|
||||||
|
|
||||||
|
template <class T, class... Types>
|
||||||
|
struct TupleTypeIndex<T, std::tuple<T, Types...>>
|
||||||
|
{
|
||||||
|
static constexpr std::size_t value = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class U, class... Types>
|
||||||
|
struct TupleTypeIndex<T, std::tuple<U, Types...>>
|
||||||
|
{
|
||||||
|
static constexpr std::size_t value = 1 + TupleTypeIndex<T, std::tuple<Types...>>::value;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user