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

75 lines
2.8 KiB
C++
Raw Normal View History

#ifndef CSM_WOLRD_REFIDADAPTER_H
#define CSM_WOLRD_REFIDADAPTER_H
#include <components/esm/refid.hpp>
#include <string>
#include <vector>
2014-07-22 08:27:45 +00:00
2014-07-23 18:33:52 +00:00
/*! \brief
2022-09-22 18:26:05 +00:00
* Adapters acts as indirection layer, abstracting details of the record types (in the wrappers) from the higher levels
* of model. Please notice that nested adaptor uses helper classes for actually performing any actions. Different record
* types require different helpers (needs to be created in the subclass and then fetched via member function).
2015-04-09 09:33:42 +00:00
*
2022-09-22 18:26:05 +00:00
* Important point: don't forget to make sure that getData on the nestedColumn returns true (otherwise code will not
* treat the index pointing to the column as having children!
2014-07-23 18:33:52 +00:00
*/
class QVariant;
namespace CSMWorld
{
class RefIdColumn;
class RefIdData;
2015-03-14 01:42:46 +00:00
struct RecordBase;
2015-04-09 10:53:41 +00:00
struct NestedTableWrapperBase;
class RefIdAdapter
{
2022-09-22 18:26:05 +00:00
public:
RefIdAdapter() = default;
RefIdAdapter(const RefIdAdapter&) = delete;
RefIdAdapter& operator=(const RefIdAdapter&) = delete;
virtual ~RefIdAdapter() = default;
2022-09-22 18:26:05 +00:00
virtual QVariant getData(const RefIdColumn* column, const RefIdData& data, int idnex) const = 0;
///< If called on the nest column, should return QVariant(true).
2022-09-22 18:26:05 +00:00
virtual void setData(const RefIdColumn* column, RefIdData& data, int index, const QVariant& value) const = 0;
///< If the data type does not match an exception is thrown.
virtual ESM::RefId getId(const RecordBase& record) const = 0;
2022-09-22 18:26:05 +00:00
virtual void setId(RecordBase& record, const std::string& id) = 0; // used by RefIdCollection::cloneRecord()
};
2014-06-09 08:35:39 +00:00
2014-07-22 08:27:45 +00:00
class NestedRefIdAdapterBase
2014-06-09 08:35:39 +00:00
{
2022-09-22 18:26:05 +00:00
public:
NestedRefIdAdapterBase() = default;
2014-06-09 08:35:39 +00:00
virtual ~NestedRefIdAdapterBase() = default;
2022-09-22 18:26:05 +00:00
virtual void setNestedData(const RefIdColumn* column, RefIdData& data, int row, const QVariant& value,
int subRowIndex, int subColIndex) const = 0;
2014-06-09 08:35:39 +00:00
2022-09-22 18:26:05 +00:00
virtual QVariant getNestedData(
const RefIdColumn* column, const RefIdData& data, int index, int subRowIndex, int subColIndex) const = 0;
2014-06-09 08:35:39 +00:00
2022-09-22 18:26:05 +00:00
virtual int getNestedColumnsCount(const RefIdColumn* column, const RefIdData& data) const = 0;
2014-05-27 12:01:15 +00:00
2022-09-22 18:26:05 +00:00
virtual int getNestedRowsCount(const RefIdColumn* column, const RefIdData& data, int index) const = 0;
2022-09-22 18:26:05 +00:00
virtual void removeNestedRow(const RefIdColumn* column, RefIdData& data, int index, int rowToRemove) const = 0;
2022-09-22 18:26:05 +00:00
virtual void addNestedRow(const RefIdColumn* column, RefIdData& data, int index, int position) const = 0;
2022-09-22 18:26:05 +00:00
virtual void setNestedTable(
const RefIdColumn* column, RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const = 0;
2022-09-22 18:26:05 +00:00
virtual NestedTableWrapperBase* nestedTable(
const RefIdColumn* column, const RefIdData& data, int index) const = 0;
2014-06-09 08:35:39 +00:00
};
}
2014-06-09 08:35:39 +00:00
#endif