#ifndef CSM_WORLD_NESTEDADAPTORS_H #define CSM_WORLD_NESTEDADAPTORS_H #include #include "universalid.hpp" #include "nestedtablewrapper.hpp" #include #include "record.hpp" #include "refiddata.hpp" #include "refidadapter.hpp" namespace CSMWorld { template class InventoryHelper { CSMWorld::UniversalId::Type mType; public: InventoryHelper(CSMWorld::UniversalId::Type type) : mType(type) {}; void setNestedTable(const RefIdColumn* column, RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) { getRecord(data, index).get().mInventory.mList = (static_cast >&>(nestedTable)).mNestedTable; } NestedTableWrapperBase* nestedTable(const RefIdColumn* column, const RefIdData& data, int index) const { return new NestedTableWrapper >(getRecord(data, index).get().mInventory.mList); } private: const Record& getRecord(const RefIdData& data, int index) const { return dynamic_cast&> ( data.getRecord (RefIdData::LocalIndex (index, mType))); } Record& getRecord(RefIdData& data, int index) const { return dynamic_cast&> ( data.getRecord (RefIdData::LocalIndex (index, mType))); } }; } #endif