aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/utility
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/utility')
-rw-r--r--src/openvic-simulation/utility/Getters.hpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/openvic-simulation/utility/Getters.hpp b/src/openvic-simulation/utility/Getters.hpp
index 99c895c..a722071 100644
--- a/src/openvic-simulation/utility/Getters.hpp
+++ b/src/openvic-simulation/utility/Getters.hpp
@@ -36,13 +36,17 @@
constexpr std::string_view get_base_type() const override { \
return ::ovdl::detail::type_name<std::decay_t<decltype(*this)>>(); }
-#define REF_GETTERS(var) \
- constexpr decltype(var)& get_##var() { \
- return var; \
+#define PROPERTY_REF(NAME) PROPERTY_REF_FULL(NAME, private)
+#define PROPERTY_REF_FULL(NAME, ACCESS) \
+ NAME; \
+public: \
+ constexpr decltype(NAME)& get_##NAME() { \
+ return NAME; \
} \
- constexpr decltype(var) const& get_##var() const { \
- return var; \
- }
+ constexpr decltype(NAME) const& get_##NAME() const { \
+ return NAME; \
+ } \
+ACCESS:
namespace OpenVic {
struct ReturnByValueProperty {};
@@ -79,15 +83,16 @@ namespace OpenVic {
* manually specify the accessibility level, if your variable deviates from this norm; use PROPERTY_CUSTOM_NAME when
* you wish to manually specify the getter name; use PROPERTY_FULL if you want to specify everything.
* Examples:
- * int PROPERTY(x); // int x; int get_x() const;
- * const std::string PROPERTY(name); // const std::string name; std::string_view get_name() const;
- * std::vector<int> PROPERTY(sizes); // std::vector<int> sizes; std::vector<int> const& get_sizes() const;
- * uint8_t const* PROPERTY(data); // uint8_t const* data; uint8_t const* get_data() const;
- * colour_t* PROPERTY(pixels); // colour_t* pixels; colour_t const* get_pixels() const;
- * CultureGroup const& PROPERTY(group);// CultureGroup const& group; CultureGroup const& get_group() const;
- * Province& PROPERTY(province); // Province& province; Province const& get_province() const;
+ * int PROPERTY(x); // int x; int get_x() const;
+ * const std::string PROPERTY(name); // const std::string name; std::string_view get_name() const;
+ * std::vector<int> PROPERTY(sizes); // std::vector<int> sizes; std::vector<int> const& get_sizes() const;
+ * uint8_t const* PROPERTY(data); // uint8_t const* data; uint8_t const* get_data() const;
+ * colour_t* PROPERTY(pixels); // colour_t* pixels; colour_t const* get_pixels() const;
+ * CultureGroup const& PROPERTY(group);// CultureGroup const& group; CultureGroup const& get_group() const;
+ * Province& PROPERTY(province); // Province& province; Province const& get_province() const;
*/
#define PROPERTY(NAME) PROPERTY_ACCESS(NAME, private)
+#define PROPERTY_CUSTOM_PREFIX(NAME, PREFIX) PROPERTY_CUSTOM_NAME(NAME, PREFIX##_##NAME)
#define PROPERTY_CUSTOM_NAME(NAME, GETTER_NAME) PROPERTY_FULL(NAME, GETTER_NAME, private)
#define PROPERTY_ACCESS(NAME, ACCESS) PROPERTY_FULL(NAME, get_##NAME, ACCESS)
#define PROPERTY_FULL(NAME, GETTER_NAME, ACCESS) \