Lodestone.Level
Loading...
Searching...
No Matches
AbstractProperty.h
Go to the documentation of this file.
1//
2// Created by DexrnZacAttack on 11/14/25 using zPc-i2.
3//
4#ifndef LODESTONE_ABSTRACTPROPERTIES_H
5#define LODESTONE_ABSTRACTPROPERTIES_H
8
11 protected:
12 constexpr AbstractProperty() = default;
13
14 public:
15 constexpr virtual ~AbstractProperty() = default;
16
17 constexpr virtual const lodestone::common::registry::Identifier *
21
22 constexpr virtual size_t hash() const = 0;
23
24 constexpr virtual bool equals(const AbstractProperty *rhs) const {
25 if (rhs == nullptr)
26 return false;
27
28 if (typeid(rhs) != typeid(this))
29 return false;
30
31 return true;
32 }
33
34 template <typename T>
35 requires std::is_base_of_v<AbstractProperty, T>
36 constexpr const T *as() const {
37 return dynamic_cast<const T *>(this);
38 }
39
40 constexpr bool operator==(const AbstractProperty &rhs) const {
41 return this->equals(&rhs);
42 }
43 };
44} // namespace lodestone::level::properties
45
46#endif // LODESTONE_ABSTRACTPROPERTIES_H
virtual constexpr bool equals(const AbstractProperty *rhs) const
Definition AbstractProperty.h:24
constexpr bool operator==(const AbstractProperty &rhs) const
Definition AbstractProperty.h:40
virtual constexpr const lodestone::common::registry::Identifier * getTypeName() const
Definition AbstractProperty.h:18
virtual constexpr size_t hash() const =0
constexpr const T * as() const
Definition AbstractProperty.h:36
virtual constexpr ~AbstractProperty()=default
constexpr common::registry::Identifier ABSTRACT_PROPERTY
Definition Identifiers.h:11
Definition ObjectDefinition.cpp:6