diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp index 8d43e578f4..48d7254f1d 100644 --- a/apps/opencs/model/tools/pathgridcheck.hpp +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -14,10 +14,8 @@ namespace CSMDoc namespace CSMWorld { struct Pathgrid; - template + template class SubCellCollection; - template - struct IdAccessor; } namespace CSMTools @@ -35,12 +33,11 @@ namespace CSMTools class PathgridCheckStage : public CSMDoc::Stage { - const CSMWorld::SubCellCollection>& mPathgrids; + const CSMWorld::SubCellCollection& mPathgrids; bool mIgnoreBaseRecords; public: - PathgridCheckStage( - const CSMWorld::SubCellCollection>& pathgrids); + explicit PathgridCheckStage(const CSMWorld::SubCellCollection& pathgrids); int setup() override; diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index fd39950bba..6e6751823d 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -24,38 +24,34 @@ namespace CSMWorld { - /// \brief Access to ID field in records - template - struct IdAccessor - { - void setId(ESXRecordT& record, const ESM::RefId& id) const; - const ESM::RefId getId(const ESXRecordT& record) const; - }; - - template - void IdAccessor::setId(ESXRecordT& record, const ESM::RefId& id) const + template + void setRecordId(const decltype(T::mId)& id, T& record) { record.mId = id; } - template - const ESM::RefId IdAccessor::getId(const ESXRecordT& record) const + template + auto getRecordId(const T& record) { return record.mId; } - template <> - inline void IdAccessor::setId(Land& record, const ESM::RefId& id) const + inline void setRecordId(const ESM::RefId& id, Land& record) { - int x = 0, y = 0; + int x = 0; + int y = 0; Land::parseUniqueRecordId(id.getRefIdString(), x, y); record.mX = x; record.mY = y; } - template <> - inline void IdAccessor::setId(LandTexture& record, const ESM::RefId& id) const + inline ESM::RefId getRecordId(const Land& record) + { + return ESM::RefId::stringRefId(Land::createUniqueRecordId(record.mX, record.mY)); + } + + inline void setRecordId(LandTexture& record, const ESM::RefId& id) { int plugin = 0; int index = 0; @@ -65,20 +61,13 @@ namespace CSMWorld record.mIndex = index; } - template <> - inline const ESM::RefId IdAccessor::getId(const Land& record) const - { - return ESM::RefId::stringRefId(Land::createUniqueRecordId(record.mX, record.mY)); - } - - template <> - inline const ESM::RefId IdAccessor::getId(const LandTexture& record) const + inline ESM::RefId getRecordId(const LandTexture& record) { return ESM::RefId::stringRefId(LandTexture::createUniqueRecordId(record.mPluginIndex, record.mIndex)); } /// \brief Single-type record collection - template > + template class Collection : public CollectionBase { public: @@ -196,14 +185,14 @@ namespace CSMWorld NestableColumn* getNestableColumn(int column) const; }; - template - const std::vector>>& Collection::getRecords() const + template + const std::vector>>& Collection::getRecords() const { return mRecords; } - template - bool Collection::reorderRowsImp(int baseIndex, const std::vector& newOrder) + template + bool Collection::reorderRowsImp(int baseIndex, const std::vector& newOrder) { if (!newOrder.empty()) { @@ -236,14 +225,14 @@ namespace CSMWorld return true; } - template - int Collection::cloneRecordImp( + template + int Collection::cloneRecordImp( const std::string& origin, const std::string& destination, UniversalId::Type type) { auto copy = std::make_unique>(); copy->mModified = getRecord(ESM::RefId::stringRefId(origin)).get(); copy->mState = RecordBase::State_ModifiedOnly; - IdAccessorT().setId(copy->get(), ESM::RefId::stringRefId(destination)); + setRecordId(ESM::RefId::stringRefId(destination), copy->get()); if (type == UniversalId::Type_Reference) { @@ -257,8 +246,8 @@ namespace CSMWorld return index; } - template - int Collection::touchRecordImp(const std::string& id) + template + int Collection::touchRecordImp(const std::string& id) { int index = getIndex(ESM::RefId::stringRefId(id)); Record& record = *mRecords.at(index); @@ -276,29 +265,29 @@ namespace CSMWorld return -1; } - template - void Collection::cloneRecord( + template + void Collection::cloneRecord( const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type) { cloneRecordImp(origin.getRefIdString(), destination.getRefIdString(), type); } template <> - inline void Collection>::cloneRecord( + inline void Collection::cloneRecord( const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type) { int index = cloneRecordImp(origin.getRefIdString(), destination.getRefIdString(), type); mRecords.at(index)->get().setPlugin(0); } - template - bool Collection::touchRecord(const ESM::RefId& id) + template + bool Collection::touchRecord(const ESM::RefId& id) { return touchRecordImp(id.getRefIdString()) != -1; } template <> - inline bool Collection>::touchRecord(const ESM::RefId& id) + inline bool Collection::touchRecord(const ESM::RefId& id) { int index = touchRecordImp(id.getRefIdString()); if (index >= 0) @@ -310,22 +299,22 @@ namespace CSMWorld return false; } - template - Collection::Collection() + template + Collection::Collection() { } - template - Collection::~Collection() + template + Collection::~Collection() { for (typename std::vector*>::iterator iter(mColumns.begin()); iter != mColumns.end(); ++iter) delete *iter; } - template - void Collection::add(const ESXRecordT& record) + template + void Collection::add(const ESXRecordT& record) { - const ESM::RefId id = IdAccessorT().getId(record); + const ESM::RefId id = getRecordId(record); auto iter = mIndex.find(id); @@ -343,20 +332,20 @@ namespace CSMWorld } } - template - int Collection::getSize() const + template + int Collection::getSize() const { return mRecords.size(); } - template - ESM::RefId Collection::getId(int index) const + template + ESM::RefId Collection::getId(int index) const { - return IdAccessorT().getId(mRecords.at(index)->get()); + return getRecordId(mRecords.at(index)->get()); } - template - int Collection::getIndex(const ESM::RefId& id) const + template + int Collection::getIndex(const ESM::RefId& id) const { int index = searchId(id); @@ -366,32 +355,32 @@ namespace CSMWorld return index; } - template - int Collection::getColumns() const + template + int Collection::getColumns() const { return mColumns.size(); } - template - QVariant Collection::getData(int index, int column) const + template + QVariant Collection::getData(int index, int column) const { return mColumns.at(column)->get(*mRecords.at(index)); } - template - void Collection::setData(int index, int column, const QVariant& data) + template + void Collection::setData(int index, int column, const QVariant& data) { return mColumns.at(column)->set(*mRecords.at(index), data); } - template - const ColumnBase& Collection::getColumn(int column) const + template + const ColumnBase& Collection::getColumn(int column) const { return *mColumns.at(column); } - template - NestableColumn* Collection::getNestableColumn(int column) const + template + NestableColumn* Collection::getNestableColumn(int column) const { if (column < 0 || column >= static_cast(mColumns.size())) throw std::runtime_error("column index out of range"); @@ -399,14 +388,14 @@ namespace CSMWorld return mColumns.at(column); } - template - void Collection::addColumn(Column* column) + template + void Collection::addColumn(Column* column) { mColumns.push_back(column); } - template - void Collection::merge() + template + void Collection::merge() { for (typename std::vector>>::iterator iter(mRecords.begin()); iter != mRecords.end(); ++iter) @@ -415,8 +404,8 @@ namespace CSMWorld purge(); } - template - void Collection::purge() + template + void Collection::purge() { int i = 0; @@ -429,8 +418,8 @@ namespace CSMWorld } } - template - void Collection::removeRows(int index, int count) + template + void Collection::removeRows(int index, int count) { mRecords.erase(mRecords.begin() + index, mRecords.begin() + index + count); @@ -455,11 +444,11 @@ namespace CSMWorld } } - template - void Collection::appendBlankRecord(const ESM::RefId& id, UniversalId::Type type) + template + void Collection::appendBlankRecord(const ESM::RefId& id, UniversalId::Type type) { ESXRecordT record; - IdAccessorT().setId(record, id); + setRecordId(id, record); record.blank(); auto record2 = std::make_unique>(); @@ -469,8 +458,8 @@ namespace CSMWorld insertRecord(std::move(record2), getAppendIndex(id, type), type); } - template - int Collection::searchId(const ESM::RefId& id) const + template + int Collection::searchId(const ESM::RefId& id) const { const auto iter = mIndex.find(id); @@ -480,63 +469,62 @@ namespace CSMWorld return iter->second; } - template - void Collection::replace(int index, std::unique_ptr record) + template + void Collection::replace(int index, std::unique_ptr record) { std::unique_ptr> tmp(static_cast*>(record.release())); mRecords.at(index) = std::move(tmp); } - template - void Collection::appendRecord(std::unique_ptr record, UniversalId::Type type) + template + void Collection::appendRecord(std::unique_ptr record, UniversalId::Type type) { - int index = getAppendIndex(IdAccessorT().getId(static_cast*>(record.get())->get()), type); + int index = getAppendIndex(getRecordId(static_cast*>(record.get())->get()), type); insertRecord(std::move(record), index, type); } - template - int Collection::getAppendIndex(const ESM::RefId& id, UniversalId::Type type) const + template + int Collection::getAppendIndex(const ESM::RefId& id, UniversalId::Type type) const { return static_cast(mRecords.size()); } - template - std::vector Collection::getIds(bool listDeleted) const + template + std::vector Collection::getIds(bool listDeleted) const { std::vector ids; for (auto iter = mIndex.begin(); iter != mIndex.end(); ++iter) { if (listDeleted || !mRecords[iter->second]->isDeleted()) - ids.push_back(IdAccessorT().getId(mRecords[iter->second]->get())); + ids.push_back(getRecordId(mRecords[iter->second]->get())); } return ids; } - template - const Record& Collection::getRecord(const ESM::RefId& id) const + template + const Record& Collection::getRecord(const ESM::RefId& id) const { int index = getIndex(id); return *mRecords.at(index); } - template - const Record& Collection::getRecord(int index) const + template + const Record& Collection::getRecord(int index) const { return *mRecords.at(index); } - template - void Collection::insertRecord( - std::unique_ptr record, int index, UniversalId::Type type) + template + void Collection::insertRecord(std::unique_ptr record, int index, UniversalId::Type type) { int size = static_cast(mRecords.size()); if (index < 0 || index > size) throw std::runtime_error("index out of range"); std::unique_ptr> record2(static_cast*>(record.release())); - ESM::RefId id = IdAccessorT().getId(record2->get()); + ESM::RefId id = getRecordId(record2->get()); if (index == size) mRecords.push_back(std::move(record2)); @@ -555,17 +543,17 @@ namespace CSMWorld mIndex.insert(std::make_pair(id, index)); } - template - void Collection::setRecord(int index, std::unique_ptr> record) + template + void Collection::setRecord(int index, std::unique_ptr> record) { - if (IdAccessorT().getId(mRecords.at(index)->get()) != IdAccessorT().getId(record->get())) + if (getRecordId(mRecords.at(index)->get()) != getRecordId(record->get())) throw std::runtime_error("attempt to change the ID of a record"); mRecords.at(index) = std::move(record); } - template - bool Collection::reorderRows(int baseIndex, const std::vector& newOrder) + template + bool Collection::reorderRows(int baseIndex, const std::vector& newOrder) { return false; } diff --git a/apps/opencs/model/world/idcollection.cpp b/apps/opencs/model/world/idcollection.cpp index 7459b016d3..faab5a20cb 100644 --- a/apps/opencs/model/world/idcollection.cpp +++ b/apps/opencs/model/world/idcollection.cpp @@ -18,14 +18,14 @@ namespace ESM namespace CSMWorld { template <> - int IdCollection>::load(ESM::ESMReader& reader, bool base) + int IdCollection::load(ESM::ESMReader& reader, bool base) { Pathgrid record; bool isDeleted = false; loadRecord(record, reader, isDeleted); - auto id = IdAccessor().getId(record); + const ESM::RefId id = getRecordId(record); int index = this->searchId(id); if (record.mPoints.empty() || record.mEdges.empty()) diff --git a/apps/opencs/model/world/idcollection.hpp b/apps/opencs/model/world/idcollection.hpp index 2382ff3274..67b886c3f8 100644 --- a/apps/opencs/model/world/idcollection.hpp +++ b/apps/opencs/model/world/idcollection.hpp @@ -24,8 +24,8 @@ namespace CSMWorld struct Pathgrid; /// \brief Single type collection of top level records - template > - class IdCollection : public Collection + template + class IdCollection : public Collection { virtual void loadRecord(ESXRecordT& record, ESM::ESMReader& reader, bool& isDeleted); @@ -46,14 +46,14 @@ namespace CSMWorld /// \return Has the ID been deleted? }; - template - void IdCollection::loadRecord(ESXRecordT& record, ESM::ESMReader& reader, bool& isDeleted) + template + void IdCollection::loadRecord(ESXRecordT& record, ESM::ESMReader& reader, bool& isDeleted) { record.load(reader, isDeleted); } template <> - inline void IdCollection>::loadRecord(Land& record, ESM::ESMReader& reader, bool& isDeleted) + inline void IdCollection::loadRecord(Land& record, ESM::ESMReader& reader, bool& isDeleted) { record.load(reader, isDeleted); @@ -66,15 +66,15 @@ namespace CSMWorld record.mContext.filename.clear(); } - template - int IdCollection::load(ESM::ESMReader& reader, bool base) + template + int IdCollection::load(ESM::ESMReader& reader, bool base) { ESXRecordT record; bool isDeleted = false; loadRecord(record, reader, isDeleted); - ESM::RefId id = IdAccessorT().getId(record); + ESM::RefId id = getRecordId(record); int index = this->searchId(id); if (isDeleted) @@ -102,11 +102,11 @@ namespace CSMWorld return load(record, base, index); } - template - int IdCollection::load(const ESXRecordT& record, bool base, int index) + template + int IdCollection::load(const ESXRecordT& record, bool base, int index) { if (index == -2) // index unknown - index = this->searchId(IdAccessorT().getId(record)); + index = this->searchId(getRecordId(record)); if (index == -1) { @@ -121,7 +121,7 @@ namespace CSMWorld else { // old record - auto record2 = std::make_unique>(Collection::getRecord(index)); + auto record2 = std::make_unique>(Collection::getRecord(index)); if (base) record2->mBase = record; @@ -134,26 +134,26 @@ namespace CSMWorld return index; } - template - bool IdCollection::tryDelete(const ESM::RefId& id) + template + bool IdCollection::tryDelete(const ESM::RefId& id) { int index = this->searchId(id); if (index == -1) return false; - const Record& record = Collection::getRecord(index); + const Record& record = Collection::getRecord(index); if (record.isDeleted()) return false; if (record.mState == RecordBase::State_ModifiedOnly) { - Collection::removeRows(index, 1); + Collection::removeRows(index, 1); } else { - auto record2 = std::make_unique>(Collection::getRecord(index)); + auto record2 = std::make_unique>(Collection::getRecord(index)); record2->mState = RecordBase::State_Deleted; this->setRecord(index, std::move(record2)); } @@ -162,7 +162,7 @@ namespace CSMWorld } template <> - int IdCollection>::load(ESM::ESMReader& reader, bool base); + int IdCollection::load(ESM::ESMReader& reader, bool base); } #endif diff --git a/apps/opencs/model/world/infocollection.hpp b/apps/opencs/model/world/infocollection.hpp index 2ae69fd0ac..696b032440 100644 --- a/apps/opencs/model/world/infocollection.hpp +++ b/apps/opencs/model/world/infocollection.hpp @@ -19,7 +19,7 @@ namespace CSMWorld using InfosByTopic = std::unordered_map>; using InfosRecordPtrByTopic = std::unordered_map*>>; - class InfoCollection : public Collection> + class InfoCollection : public Collection { private: bool load(const Info& record, bool base); diff --git a/apps/opencs/model/world/nestedidcollection.hpp b/apps/opencs/model/world/nestedidcollection.hpp index 0f334a3015..2e15f9b583 100644 --- a/apps/opencs/model/world/nestedidcollection.hpp +++ b/apps/opencs/model/world/nestedidcollection.hpp @@ -21,16 +21,13 @@ namespace CSMWorld struct ColumnBase; template - struct IdAccessor; - - template class IdCollection; template class NestedColumnAdapter; - template > - class NestedIdCollection : public IdCollection, public NestedCollection + template + class NestedIdCollection : public IdCollection, public NestedCollection { std::map*> mAdapters; @@ -62,13 +59,13 @@ namespace CSMWorld void addAdapter(std::pair*> adapter); }; - template - NestedIdCollection::NestedIdCollection() + template + NestedIdCollection::NestedIdCollection() { } - template - NestedIdCollection::~NestedIdCollection() + template + NestedIdCollection::~NestedIdCollection() { for (typename std::map*>::iterator iter(mAdapters.begin()); iter != mAdapters.end(); ++iter) @@ -77,16 +74,15 @@ namespace CSMWorld } } - template - void NestedIdCollection::addAdapter( + template + void NestedIdCollection::addAdapter( std::pair*> adapter) { mAdapters.insert(adapter); } - template - const NestedColumnAdapter& NestedIdCollection::getAdapter( - const ColumnBase& column) const + template + const NestedColumnAdapter& NestedIdCollection::getAdapter(const ColumnBase& column) const { typename std::map*>::const_iterator iter = mAdapters.find(&column); @@ -97,83 +93,80 @@ namespace CSMWorld return *iter->second; } - template - void NestedIdCollection::addNestedRow(int row, int column, int position) + template + void NestedIdCollection::addNestedRow(int row, int column, int position) { auto record = std::make_unique>(); - record->assign(Collection::getRecord(row)); + record->assign(Collection::getRecord(row)); - getAdapter(Collection::getColumn(column)).addRow(*record, position); + getAdapter(Collection::getColumn(column)).addRow(*record, position); - Collection::setRecord(row, std::move(record)); + Collection::setRecord(row, std::move(record)); } - template - void NestedIdCollection::removeNestedRows(int row, int column, int subRow) + template + void NestedIdCollection::removeNestedRows(int row, int column, int subRow) { auto record = std::make_unique>(); - record->assign(Collection::getRecord(row)); + record->assign(Collection::getRecord(row)); - getAdapter(Collection::getColumn(column)).removeRow(*record, subRow); + getAdapter(Collection::getColumn(column)).removeRow(*record, subRow); - Collection::setRecord(row, std::move(record)); + Collection::setRecord(row, std::move(record)); } - template - QVariant NestedIdCollection::getNestedData( - int row, int column, int subRow, int subColumn) const + template + QVariant NestedIdCollection::getNestedData(int row, int column, int subRow, int subColumn) const { - return getAdapter(Collection::getColumn(column)) - .getData(Collection::getRecord(row), subRow, subColumn); + return getAdapter(Collection::getColumn(column)) + .getData(Collection::getRecord(row), subRow, subColumn); } - template - void NestedIdCollection::setNestedData( + template + void NestedIdCollection::setNestedData( int row, int column, const QVariant& data, int subRow, int subColumn) { auto record = std::make_unique>(); - record->assign(Collection::getRecord(row)); + record->assign(Collection::getRecord(row)); - getAdapter(Collection::getColumn(column)).setData(*record, data, subRow, subColumn); + getAdapter(Collection::getColumn(column)).setData(*record, data, subRow, subColumn); - Collection::setRecord(row, std::move(record)); + Collection::setRecord(row, std::move(record)); } - template - CSMWorld::NestedTableWrapperBase* NestedIdCollection::nestedTable( - int row, int column) const + template + CSMWorld::NestedTableWrapperBase* NestedIdCollection::nestedTable(int row, int column) const { - return getAdapter(Collection::getColumn(column)) - .table(Collection::getRecord(row)); + return getAdapter(Collection::getColumn(column)).table(Collection::getRecord(row)); } - template - void NestedIdCollection::setNestedTable( + template + void NestedIdCollection::setNestedTable( int row, int column, const CSMWorld::NestedTableWrapperBase& nestedTable) { auto record = std::make_unique>(); - record->assign(Collection::getRecord(row)); + record->assign(Collection::getRecord(row)); - getAdapter(Collection::getColumn(column)).setTable(*record, nestedTable); + getAdapter(Collection::getColumn(column)).setTable(*record, nestedTable); - Collection::setRecord(row, std::move(record)); + Collection::setRecord(row, std::move(record)); } - template - int NestedIdCollection::getNestedRowsCount(int row, int column) const + template + int NestedIdCollection::getNestedRowsCount(int row, int column) const { - return getAdapter(Collection::getColumn(column)) - .getRowsCount(Collection::getRecord(row)); + return getAdapter(Collection::getColumn(column)) + .getRowsCount(Collection::getRecord(row)); } - template - int NestedIdCollection::getNestedColumnsCount(int row, int column) const + template + int NestedIdCollection::getNestedColumnsCount(int row, int column) const { - const ColumnBase& nestedColumn = Collection::getColumn(column); - int numRecords = Collection::getSize(); + const ColumnBase& nestedColumn = Collection::getColumn(column); + int numRecords = Collection::getSize(); if (row >= 0 && row < numRecords) { - const Record& record = Collection::getRecord(row); + const Record& record = Collection::getRecord(row); return getAdapter(nestedColumn).getColumnsCount(record); } else @@ -184,10 +177,10 @@ namespace CSMWorld } } - template - CSMWorld::NestableColumn* NestedIdCollection::getNestableColumn(int column) + template + CSMWorld::NestableColumn* NestedIdCollection::getNestableColumn(int column) { - return Collection::getNestableColumn(column); + return Collection::getNestableColumn(column); } } diff --git a/apps/opencs/model/world/nestedinfocollection.cpp b/apps/opencs/model/world/nestedinfocollection.cpp index dbcf7f6c81..d28df2e010 100644 --- a/apps/opencs/model/world/nestedinfocollection.cpp +++ b/apps/opencs/model/world/nestedinfocollection.cpp @@ -46,69 +46,66 @@ namespace CSMWorld void NestedInfoCollection::addNestedRow(int row, int column, int position) { auto record = std::make_unique>(); - record->assign(Collection>::getRecord(row)); + record->assign(Collection::getRecord(row)); - getAdapter(Collection>::getColumn(column)).addRow(*record, position); + getAdapter(Collection::getColumn(column)).addRow(*record, position); - Collection>::setRecord(row, std::move(record)); + Collection::setRecord(row, std::move(record)); } void NestedInfoCollection::removeNestedRows(int row, int column, int subRow) { auto record = std::make_unique>(); - record->assign(Collection>::getRecord(row)); + record->assign(Collection::getRecord(row)); - getAdapter(Collection>::getColumn(column)).removeRow(*record, subRow); + getAdapter(Collection::getColumn(column)).removeRow(*record, subRow); - Collection>::setRecord(row, std::move(record)); + Collection::setRecord(row, std::move(record)); } QVariant NestedInfoCollection::getNestedData(int row, int column, int subRow, int subColumn) const { - return getAdapter(Collection>::getColumn(column)) - .getData(Collection>::getRecord(row), subRow, subColumn); + return getAdapter(Collection::getColumn(column)) + .getData(Collection::getRecord(row), subRow, subColumn); } void NestedInfoCollection::setNestedData(int row, int column, const QVariant& data, int subRow, int subColumn) { auto record = std::make_unique>(); - record->assign(Collection>::getRecord(row)); + record->assign(Collection::getRecord(row)); - getAdapter(Collection>::getColumn(column)).setData(*record, data, subRow, subColumn); + getAdapter(Collection::getColumn(column)).setData(*record, data, subRow, subColumn); - Collection>::setRecord(row, std::move(record)); + Collection::setRecord(row, std::move(record)); } CSMWorld::NestedTableWrapperBase* NestedInfoCollection::nestedTable(int row, int column) const { - return getAdapter(Collection>::getColumn(column)) - .table(Collection>::getRecord(row)); + return getAdapter(Collection::getColumn(column)).table(Collection::getRecord(row)); } void NestedInfoCollection::setNestedTable(int row, int column, const CSMWorld::NestedTableWrapperBase& nestedTable) { auto record = std::make_unique>(); - record->assign(Collection>::getRecord(row)); + record->assign(Collection::getRecord(row)); - getAdapter(Collection>::getColumn(column)).setTable(*record, nestedTable); + getAdapter(Collection::getColumn(column)).setTable(*record, nestedTable); - Collection>::setRecord(row, std::move(record)); + Collection::setRecord(row, std::move(record)); } int NestedInfoCollection::getNestedRowsCount(int row, int column) const { - return getAdapter(Collection>::getColumn(column)) - .getRowsCount(Collection>::getRecord(row)); + return getAdapter(Collection::getColumn(column)).getRowsCount(Collection::getRecord(row)); } int NestedInfoCollection::getNestedColumnsCount(int row, int column) const { - return getAdapter(Collection>::getColumn(column)) - .getColumnsCount(Collection>::getRecord(row)); + return getAdapter(Collection::getColumn(column)).getColumnsCount(Collection::getRecord(row)); } CSMWorld::NestableColumn* NestedInfoCollection::getNestableColumn(int column) { - return Collection>::getNestableColumn(column); + return Collection::getNestableColumn(column); } } diff --git a/apps/opencs/model/world/nestedinfocollection.hpp b/apps/opencs/model/world/nestedinfocollection.hpp index 333f19bc85..9d26af56e6 100644 --- a/apps/opencs/model/world/nestedinfocollection.hpp +++ b/apps/opencs/model/world/nestedinfocollection.hpp @@ -45,7 +45,7 @@ namespace CSMWorld int getNestedColumnsCount(int row, int column) const override; - // this method is inherited from NestedCollection, not from Collection > + // this method is inherited from NestedCollection, not from Collection NestableColumn* getNestableColumn(int column) override; void addAdapter(std::pair*> adapter); diff --git a/apps/opencs/model/world/pathgrid.hpp b/apps/opencs/model/world/pathgrid.hpp index 02ddeca97c..a727e571a3 100644 --- a/apps/opencs/model/world/pathgrid.hpp +++ b/apps/opencs/model/world/pathgrid.hpp @@ -14,12 +14,9 @@ namespace ESM namespace CSMWorld { struct Cell; - template + template class IdCollection; - template - struct IdAccessor; - /// \brief Wrapper for Pathgrid record /// /// \attention The mData.mX and mData.mY fields of the ESM::Pathgrid struct are not used. @@ -28,7 +25,7 @@ namespace CSMWorld { ESM::RefId mId; - void load(ESM::ESMReader& esm, bool& isDeleted, const IdCollection>& cells); + void load(ESM::ESMReader& esm, bool& isDeleted, const IdCollection& cells); void load(ESM::ESMReader& esm, bool& isDeleted); }; } diff --git a/apps/opencs/model/world/refcollection.cpp b/apps/opencs/model/world/refcollection.cpp index 5b0080a388..fbe002080c 100644 --- a/apps/opencs/model/world/refcollection.cpp +++ b/apps/opencs/model/world/refcollection.cpp @@ -20,7 +20,7 @@ namespace CSMWorld { template <> - void Collection>::removeRows(int index, int count) + void Collection::removeRows(int index, int count) { mRecords.erase(mRecords.begin() + index, mRecords.begin() + index + count); @@ -28,8 +28,7 @@ namespace CSMWorld } template <> - void Collection>::insertRecord( - std::unique_ptr record, int index, UniversalId::Type type) + void Collection::insertRecord(std::unique_ptr record, int index, UniversalId::Type type) { int size = static_cast(mRecords.size()); if (index < 0 || index > size) @@ -257,7 +256,7 @@ int CSMWorld::RefCollection::searchId(unsigned int id) const void CSMWorld::RefCollection::removeRows(int index, int count) { - Collection>::removeRows(index, count); // erase records only + Collection::removeRows(index, count); // erase records only std::map::iterator iter = mRefIndex.begin(); while (iter != mRefIndex.end()) @@ -287,7 +286,7 @@ void CSMWorld::RefCollection::appendBlankRecord(const std::string& id, Universal record->get().mId = ESM::RefId::stringRefId(id); record->get().mIdNum = extractIdNum(id); - Collection>::appendRecord(std::move(record)); + Collection::appendRecord(std::move(record)); } void CSMWorld::RefCollection::appendBlankRecord(const ESM::RefId& id, UniversalId::Type type) @@ -300,7 +299,7 @@ void CSMWorld::RefCollection::appendBlankRecord(const ESM::RefId& id, UniversalI record->get().mId = id; record->get().mIdNum = extractIdNum(id.getRefIdString()); - Collection>::appendRecord(std::move(record)); + Collection::appendRecord(std::move(record)); } void CSMWorld::RefCollection::cloneRecord( @@ -333,7 +332,7 @@ void CSMWorld::RefCollection::appendRecord(std::unique_ptr record, U mRefIndex.insert(std::make_pair(static_cast*>(record.get())->get().mIdNum, index)); - Collection>::insertRecord(std::move(record), index, type); // add records only + Collection::insertRecord(std::move(record), index, type); // add records only } void CSMWorld::RefCollection::insertRecord(std::unique_ptr record, int index, UniversalId::Type type) @@ -341,7 +340,7 @@ void CSMWorld::RefCollection::insertRecord(std::unique_ptr record, i int size = getAppendIndex(/*id*/ ESM::RefId(), type); // for CellRef records id is ignored unsigned int idNum = static_cast*>(record.get())->get().mIdNum; - Collection>::insertRecord(std::move(record), index, type); // add records only + Collection::insertRecord(std::move(record), index, type); // add records only if (index < size - 1) { diff --git a/apps/opencs/model/world/refcollection.hpp b/apps/opencs/model/world/refcollection.hpp index 1140e50255..066e5ec3d9 100644 --- a/apps/opencs/model/world/refcollection.hpp +++ b/apps/opencs/model/world/refcollection.hpp @@ -28,11 +28,10 @@ namespace CSMWorld struct Cell; template <> - void Collection>::removeRows(int index, int count); + void Collection::removeRows(int index, int count); template <> - void Collection>::insertRecord( - std::unique_ptr record, int index, UniversalId::Type type); + void Collection::insertRecord(std::unique_ptr record, int index, UniversalId::Type type); /// \brief References in cells class RefCollection : public Collection diff --git a/apps/opencs/model/world/subcellcollection.hpp b/apps/opencs/model/world/subcellcollection.hpp index 6f9d1eda8f..88df21b4d4 100644 --- a/apps/opencs/model/world/subcellcollection.hpp +++ b/apps/opencs/model/world/subcellcollection.hpp @@ -13,26 +13,25 @@ namespace CSMWorld struct Cell; /// \brief Single type collection of top level records that are associated with cells - template > - class SubCellCollection : public NestedIdCollection + template + class SubCellCollection : public NestedIdCollection { - const IdCollection>& mCells; + const IdCollection& mCells; void loadRecord(ESXRecordT& record, ESM::ESMReader& reader, bool& isDeleted) override; public: - SubCellCollection(const IdCollection>& cells); + SubCellCollection(const IdCollection& cells); }; - template - void SubCellCollection::loadRecord( - ESXRecordT& record, ESM::ESMReader& reader, bool& isDeleted) + template + void SubCellCollection::loadRecord(ESXRecordT& record, ESM::ESMReader& reader, bool& isDeleted) { record.load(reader, isDeleted, mCells); } - template - SubCellCollection::SubCellCollection(const IdCollection>& cells) + template + SubCellCollection::SubCellCollection(const IdCollection& cells) : mCells(cells) { }