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>
|
2021-09-04 16:07:23 +00:00
|
|
|
#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"
|
2022-09-22 18:26:05 +00:00
|
|
|
#include "ref.hpp"
|
2013-07-06 15:03:18 +00:00
|
|
|
|
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;
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
template <>
|
|
|
|
void Collection<CellRef, IdAccessor<CellRef>>::removeRows(int index, int count);
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
template <>
|
|
|
|
void Collection<CellRef, IdAccessor<CellRef>>::insertRecord(
|
|
|
|
std::unique_ptr<RecordBase> record, int index, UniversalId::Type type);
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2013-07-06 15:03:18 +00:00
|
|
|
/// \brief References in cells
|
|
|
|
class RefCollection : public Collection<CellRef>
|
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
Collection<Cell>& mCells;
|
|
|
|
std::map<unsigned int, int> mRefIndex; // CellRef index keyed by CSMWorld::CellRef::mIdNum
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
int mNextId;
|
2013-07-06 15:03:18 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
unsigned int extractIdNum(std::string_view id) const;
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
int getIntIndex(unsigned int id) const;
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
int searchId(unsigned int id) const;
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
public:
|
|
|
|
// MSVC needs the constructor for a class inheriting a template to be defined in header
|
|
|
|
RefCollection(Collection<Cell>& cells)
|
|
|
|
: mCells(cells)
|
|
|
|
, mNextId(0)
|
|
|
|
{
|
|
|
|
}
|
2013-07-06 15:03:18 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void load(ESM::ESMReader& reader, int cellIndex, bool base, std::map<unsigned int, unsigned int>& cache,
|
|
|
|
CSMDoc::Messages& messages);
|
|
|
|
///< Load a sequence of references.
|
2013-07-30 10:53:03 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
std::string getNewId();
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
virtual void removeRows(int index, int count);
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
virtual void appendBlankRecord(const std::string& id, UniversalId::Type type = UniversalId::Type_None);
|
2022-10-06 17:39:46 +00:00
|
|
|
virtual void appendBlankRecord(const ESM::RefId& id, UniversalId::Type type = UniversalId::Type_None);
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-10-18 07:26:55 +00:00
|
|
|
virtual void cloneRecord(const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type);
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
virtual int searchId(std::string_view id) const;
|
2022-10-06 17:39:46 +00:00
|
|
|
virtual int searchId(const ESM::RefId& id) const;
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
virtual void appendRecord(std::unique_ptr<RecordBase> record, UniversalId::Type type = UniversalId::Type_None);
|
2021-07-23 09:07:56 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
virtual void insertRecord(
|
|
|
|
std::unique_ptr<RecordBase> record, int index, UniversalId::Type type = UniversalId::Type_None);
|
2013-07-06 15:03:18 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|