Lodestone.Level
Loading...
Searching...
No Matches
ReflectiveProperties.h
Go to the documentation of this file.
1//
2// Created by DexrnZacAttack on 11/24/25 using zPc-i2.
3//
4#ifndef LODESTONE_REFLECTIVEPROPERTIES_H
5#define LODESTONE_REFLECTIVEPROPERTIES_H
8
9#include <memory>
10
13
16 public:
17#define ADD_FIELD_PROPERTY(n, f) \
18 case n##_hash: \
19 return (typeid(decltype(f)) == typeid(f)) \
20 ? std::make_unique< \
21 lodestone::level::properties::TemplatedProperty<decltype(f)>>( \
22 f) \
23 : nullptr
24
25 virtual ~ReflectiveProperties() = default;
26
34 virtual std::unique_ptr<AbstractProperty>
35 getProperty(const std::string &name);
36
37 template <typename T>
38 std::unique_ptr<TemplatedProperty<T>> getProperty(const std::string &name) {
40 }
41
42 template <typename T>
43 std::unique_ptr<TemplatedProperty<T>> getPropertyOr(const std::string &name, T value) {
44 std::unique_ptr<TemplatedProperty<T>> prop = common::util::Casts::dynamic_unique_pointer_cast<TemplatedProperty<T>>(getProperty(name));
45 if (prop == nullptr) {
46 return std::make_unique<TemplatedProperty<T>>(value);
47 }
48
49 return std::move(prop);
50 }
51 };
52} // namespace lodestone::level::properties
53
54#endif // LODESTONE_REFLECTIVEPROPERTIES_H
static std::unique_ptr< To > dynamic_unique_pointer_cast(std::unique_ptr< From > ptr)
Definition ReflectiveProperties.h:15
virtual std::unique_ptr< AbstractProperty > getProperty(const std::string &name)
Definition ReflectiveProperties.cpp:6
std::unique_ptr< TemplatedProperty< T > > getPropertyOr(const std::string &name, T value)
Definition ReflectiveProperties.h:43
std::unique_ptr< TemplatedProperty< T > > getProperty(const std::string &name)
Definition ReflectiveProperties.h:38
Definition ObjectDefinition.cpp:6