1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00
OpenMW/apps/openmw/mwworld/customdata.hpp

55 lines
1.7 KiB
C++
Raw Normal View History

#ifndef GAME_MWWORLD_CUSTOMDATA_H
#define GAME_MWWORLD_CUSTOMDATA_H
#include <memory>
namespace MWClass
{
class CreatureCustomData;
2023-08-02 00:55:16 +02:00
class ESM4NpcCustomData;
class NpcCustomData;
class ContainerCustomData;
class DoorCustomData;
class CreatureLevListCustomData;
}
namespace MWWorld
{
/// \brief Base class for the MW-class-specific part of RefData
class CustomData
{
2022-09-22 21:26:05 +03:00
public:
virtual ~CustomData() {}
2022-09-22 21:26:05 +03:00
virtual std::unique_ptr<CustomData> clone() const = 0;
2022-09-22 21:26:05 +03:00
// Fast version of dynamic_cast<X&>. Needs to be overridden in the respective class.
2022-09-22 21:26:05 +03:00
virtual MWClass::CreatureCustomData& asCreatureCustomData();
virtual const MWClass::CreatureCustomData& asCreatureCustomData() const;
2022-09-22 21:26:05 +03:00
virtual MWClass::NpcCustomData& asNpcCustomData();
virtual const MWClass::NpcCustomData& asNpcCustomData() const;
2022-09-22 21:26:05 +03:00
virtual MWClass::ContainerCustomData& asContainerCustomData();
virtual const MWClass::ContainerCustomData& asContainerCustomData() const;
2022-09-22 21:26:05 +03:00
virtual MWClass::DoorCustomData& asDoorCustomData();
virtual const MWClass::DoorCustomData& asDoorCustomData() const;
2022-09-22 21:26:05 +03:00
virtual MWClass::CreatureLevListCustomData& asCreatureLevListCustomData();
virtual const MWClass::CreatureLevListCustomData& asCreatureLevListCustomData() const;
2023-08-02 00:55:16 +02:00
virtual MWClass::ESM4NpcCustomData& asESM4NpcCustomData();
virtual const MWClass::ESM4NpcCustomData& asESM4NpcCustomData() const;
};
template <class T>
struct TypedCustomData : CustomData
{
2022-09-22 21:26:05 +03:00
std::unique_ptr<CustomData> clone() const final { return std::make_unique<T>(*static_cast<const T*>(this)); }
};
}
#endif