ESMStore cleanup
While working on !2272 (closed) I've discovered a couple of things that should be addressed to make the ESMStore a better interface.
- All stores should inherit from
StoreBase
in order to return a generic store instance which can be cast back to its specialized type, this allows to move most code into the cpp file. - The ESMStore currently implements specialized
get
functions per ESM type which can be avoided using a common base type as stated in 1. - Each store should sit in a tuple which allows to visit/iterate each type/storage quite easily and avoids a lot of boilerplate code, using fold expressions we can create efficient code with tuples for queries where the ESM types are provided.
- Each record type must contain a record id even when its not really saved/loaded from anywhere, example being ESM::Attributes, we should simply give this a unique id like
fourCC("ATTR")
or something - Additional static constexpr data can be put into the record types which describes if its cached or saved/loaded, there is code which has this hardcoded and with the tuple store we can query/iterate this more easily and not having to create switches or lookup tables to identify what is what.
- Functions that create dynamic store entries share a common global counter to create a new id and the function throws if the id is already taken, the function should rather guarantee that the id is not taken.
- Dynamic ids only consider a single store and ignores the global id to record mapping, trying to insert a new entry for lets say ESM::NPC it will only look if the id is taken from the ESM::NPC store.
- Not all stores are currently dynamic but I believe the goal is to have them all dynamic.
All of this should lead to being able to easily add new stores by simple adding the type to the tuple list, so essentially one line change for when new stores for lets say ESM4 have to be added.