1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 16:23:53 +00:00
openmw/apps/opencs/model/world/refcollection.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
2.1 KiB
C++
Raw Normal View History

2013-07-06 15:03:18 +00:00
#ifndef CSM_WOLRD_REFCOLLECTION_H
#define CSM_WOLRD_REFCOLLECTION_H
2014-05-20 07:02:22 +00:00
#include <map>
2022-10-19 17:02:00 +00:00
#include <memory>
#include <string>
#include <string_view>
2022-10-19 17:02:00 +00:00
#include <vector>
#include <apps/opencs/model/world/universalid.hpp>
2014-05-20 07:02:22 +00:00
2013-07-06 15:03:18 +00:00
#include "collection.hpp"
#include "record.hpp"
#include "ref.hpp"
2022-10-19 17:02:00 +00:00
namespace ESM
{
class ESMReader;
}
2022-08-19 17:19:42 +00:00
namespace CSMDoc
{
class Messages;
}
2013-07-06 15:03:18 +00:00
namespace CSMWorld
{
struct Cell;
template <>
void Collection<CellRef>::removeRows(int index, int count);
template <>
void Collection<CellRef>::insertRecord(std::unique_ptr<RecordBase> record, int index, UniversalId::Type type);
2013-07-06 15:03:18 +00:00
/// \brief References in cells
class RefCollection final : public Collection<CellRef>
2013-07-06 15:03:18 +00:00
{
Collection<Cell>& mCells;
std::map<unsigned int, int> mRefIndex; // CellRef index keyed by CSMWorld::CellRef::mIdNum
2013-07-06 15:03:18 +00:00
int mNextId;
unsigned int extractIdNum(std::string_view id) const;
int getIntIndex(unsigned int id) const;
int searchId(unsigned int id) const;
2013-07-06 15:03:18 +00:00
public:
// MSVC needs the constructor for a class inheriting a template to be defined in header
2013-09-04 21:25:47 +00:00
RefCollection(Collection<Cell>& cells)
: mCells(cells)
, mNextId(0)
{
}
2013-07-06 15:03:18 +00:00
2014-05-20 07:02:22 +00:00
void load(ESM::ESMReader& reader, int cellIndex, bool base, std::map<unsigned int, unsigned int>& cache,
CSMDoc::Messages& messages);
2013-07-06 15:03:18 +00:00
///< Load a sequence of references.
std::string getNewId();
void removeRows(int index, int count) override;
void appendBlankRecord(const ESM::RefId& id, UniversalId::Type type = UniversalId::Type_None) override;
void cloneRecord(
const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type) override;
int searchId(const ESM::RefId& id) const override;
void appendRecord(std::unique_ptr<RecordBase> record, UniversalId::Type type = UniversalId::Type_None) override;
void insertRecord(
std::unique_ptr<RecordBase> record, int index, UniversalId::Type type = UniversalId::Type_None) override;
2013-07-06 15:03:18 +00:00
};
}
#endif