rename StoreBase =>DynamicStore, and create new class Storebase

all stores inherit from base class StoreBase.Storebase is just an empty interface class
crashfix_debugdraw
florent.teppe 2 years ago
parent 0d84b32d46
commit 16482243fa

@ -215,8 +215,8 @@ namespace MWWorld
Store<ESM::Skill> mSkills; Store<ESM::Skill> mSkills;
Store<ESM::Attribute> mAttributes; Store<ESM::Attribute> mAttributes;
std::map<ESM::RecNameInts, StoreBase*> mRecNameToStore; std::map<ESM::RecNameInts, DynamicStore*> mRecNameToStore;
std::unordered_map<const StoreBase*, ESM::RecNameInts> mStoreToRecName; std::unordered_map<const DynamicStore*, ESM::RecNameInts> mStoreToRecName;
// Lookup of all IDs. Makes looking up references faster. Just // Lookup of all IDs. Makes looking up references faster. Just
// maps the id name to the record type. // maps the id name to the record type.
@ -291,7 +291,7 @@ namespace MWWorld
template<typename T> template<typename T>
static void createStore(ESMStore& stores) static void createStore(ESMStore& stores)
{ {
if constexpr (std::is_convertible<Store<T>*, StoreBase*>::value) if constexpr (std::is_convertible<Store<T>*, DynamicStore*>::value)
{ {
int storeIndex = SRecordType<T>::sStoreIndex; int storeIndex = SRecordType<T>::sStoreIndex;
stores.mStores[storeIndex] = std::make_unique<Store<T>>(); stores.mStores[storeIndex] = std::make_unique<Store<T>>();
@ -307,7 +307,7 @@ namespace MWWorld
{ {
for (const auto& recordStorePair : mRecNameToStore) for (const auto& recordStorePair : mRecNameToStore)
{ {
const StoreBase* storePtr = recordStorePair.second; const DynamicStore* storePtr = recordStorePair.second;
mStoreToRecName[storePtr] = recordStorePair.first; mStoreToRecName[storePtr] = recordStorePair.first;
} }
} }
@ -481,7 +481,7 @@ void ESMStore::setUp()
{ {
mStoreImp->mIds.clear(); mStoreImp->mIds.clear();
std::map<ESM::RecNameInts, StoreBase*>::iterator storeIt = mStoreImp->mRecNameToStore.begin(); std::map<ESM::RecNameInts, DynamicStore*>::iterator storeIt = mStoreImp->mRecNameToStore.begin();
for (; storeIt != mStoreImp->mRecNameToStore.end(); ++storeIt) { for (; storeIt != mStoreImp->mRecNameToStore.end(); ++storeIt) {
storeIt->second->setUp(); storeIt->second->setUp();

@ -38,7 +38,7 @@ namespace MWWorld
std::unordered_map<std::string, int> mRefCount; std::unordered_map<std::string, int> mRefCount;
std::vector<std::unique_ptr< StoreBase >> mStores; std::vector<std::unique_ptr< DynamicStore >> mStores;
unsigned int mDynamicCount; unsigned int mDynamicCount;
@ -65,7 +65,7 @@ namespace MWWorld
ESM::LuaScriptsCfg getLuaScriptsCfg() const; ESM::LuaScriptsCfg getLuaScriptsCfg() const;
/// \todo replace with SharedIterator<StoreBase> /// \todo replace with SharedIterator<StoreBase>
typedef std::vector<std::unique_ptr< StoreBase>>::const_iterator iterator; typedef std::vector<std::unique_ptr< DynamicStore>>::const_iterator iterator;
iterator begin() const { iterator begin() const {
return mStores.begin(); return mStores.begin();
@ -130,7 +130,7 @@ namespace MWWorld
std::pair<std::shared_ptr<MWMechanics::SpellList>, bool> getSpellList(const std::string& id) const; std::pair<std::shared_ptr<MWMechanics::SpellList>, bool> getSpellList(const std::string& id) const;
}; };
//Special cases these aren't StoreBase, but IndexedStore //Special cases these aren't DynamicStore, but IndexedStore
template <> const Store<ESM::MagicEffect>& ESMStore::get<ESM::MagicEffect>() const; template <> const Store<ESM::MagicEffect>& ESMStore::get<ESM::MagicEffect>() const;
template <> Store<ESM::MagicEffect>& ESMStore::getWritable<ESM::MagicEffect>(); template <> Store<ESM::MagicEffect>& ESMStore::getWritable<ESM::MagicEffect>();

@ -43,10 +43,12 @@ namespace MWWorld
RecordId(const std::string &id = {}, bool isDeleted = false); RecordId(const std::string &id = {}, bool isDeleted = false);
}; };
class StoreBase class StoreBase {}; //Empty interface to be parent of all store types
class DynamicStore : StoreBase
{ {
public: public:
virtual ~StoreBase() {} virtual ~DynamicStore() {}
virtual void setUp() {} virtual void setUp() {}
@ -67,7 +69,7 @@ namespace MWWorld
}; };
template <class T> template <class T>
class IndexedStore class IndexedStore : StoreBase
{ {
protected: protected:
typedef typename std::map<int, T> Static; typedef typename std::map<int, T> Static;
@ -161,7 +163,7 @@ namespace MWWorld
class ESMStore; class ESMStore;
template <class T> template <class T>
class Store : public StoreBase class Store : public DynamicStore
{ {
typedef std::unordered_map<std::string, T, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual> Static; typedef std::unordered_map<std::string, T, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual> Static;
Static mStatic; Static mStatic;
@ -220,7 +222,7 @@ namespace MWWorld
}; };
template <> template <>
class Store<ESM::LandTexture> : public StoreBase class Store<ESM::LandTexture> : public DynamicStore
{ {
// For multiple ESM/ESP files we need one list per file. // For multiple ESM/ESP files we need one list per file.
typedef std::vector<ESM::LandTexture> LandTextureList; typedef std::vector<ESM::LandTexture> LandTextureList;
@ -248,7 +250,7 @@ namespace MWWorld
}; };
template <> template <>
class Store<ESM::Land> : public StoreBase class Store<ESM::Land> : public DynamicStore
{ {
struct SpatialComparator struct SpatialComparator
{ {
@ -291,7 +293,7 @@ namespace MWWorld
}; };
template <> template <>
class Store<ESM::Cell> : public StoreBase class Store<ESM::Cell> : public DynamicStore
{ {
struct DynamicExtCmp struct DynamicExtCmp
{ {
@ -366,7 +368,7 @@ namespace MWWorld
}; };
template <> template <>
class Store<ESM::Pathgrid> : public StoreBase class Store<ESM::Pathgrid> : public DynamicStore
{ {
private: private:
typedef std::unordered_map<std::string, ESM::Pathgrid, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual> Interior; typedef std::unordered_map<std::string, ESM::Pathgrid, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual> Interior;
@ -433,7 +435,7 @@ namespace MWWorld
}; };
template <> template <>
class Store<ESM::WeaponType> : public StoreBase class Store<ESM::WeaponType> : public DynamicStore
{ {
std::map<int, ESM::WeaponType> mStatic; std::map<int, ESM::WeaponType> mStatic;
@ -459,7 +461,7 @@ namespace MWWorld
}; };
template <> template <>
class Store<ESM::Dialogue> : public StoreBase class Store<ESM::Dialogue> : public DynamicStore
{ {
typedef std::unordered_map<std::string, ESM::Dialogue, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual> Static; typedef std::unordered_map<std::string, ESM::Dialogue, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual> Static;
Static mStatic; Static mStatic;

Loading…
Cancel
Save