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

83 lines
2.3 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"
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);
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);
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
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;
2022-09-22 18:26:05 +00:00
int getIntIndex(unsigned int id) const;
2022-09-22 18:26:05 +00:00
int searchId(unsigned int id) const;
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.
2022-09-22 18:26:05 +00:00
std::string getNewId();
2022-09-22 18:26:05 +00:00
virtual void removeRows(int index, int count);
2022-09-22 18:26:05 +00:00
virtual void appendBlankRecord(const std::string& id, UniversalId::Type type = UniversalId::Type_None);
virtual void appendBlankRecord(const ESM::RefId& id, UniversalId::Type type = UniversalId::Type_None);
virtual void cloneRecord(const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type);
2022-09-22 18:26:05 +00:00
virtual int searchId(std::string_view id) const;
virtual int searchId(const ESM::RefId& id) const;
2022-09-22 18:26:05 +00:00
virtual void appendRecord(std::unique_ptr<RecordBase> record, UniversalId::Type type = UniversalId::Type_None);
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