qxLib
property.h
Go to the documentation of this file.
1 /**
2 
3  @file property.h
4  @author Khrapov
5  @date 7.08.2022
6  @copyright © Nick Khrapov, 2022. All right reserved.
7 
8 **/
9 #pragma once
10 
11 /**
12  @def QX_GETTER
13  @brief Fast C#-like getter
14  @param type - value type
15  @param name - value name
16 **/
17 #define QX_GETTER(type, name) \
18  const type& Get##name() const \
19  { \
20  return m_##name; \
21  }
22 
23 /**
24  @def QX_GETTER_REF
25  @brief Fast C#-like ref getter
26  @param type - value type
27  @param name - value name
28 **/
29 #define QX_GETTER_REF(type, name) \
30  type& Get##name() \
31  { \
32  return m_##name; \
33  }
34 //-V:QX_GETTER_REF:1003
35 
36 /**
37  @def QX_SETTER
38  @brief Fast C#-like setter
39  @param type - value type
40  @param name - value name
41 **/
42 #define QX_SETTER(type, name) \
43  void Set##name(const type& val) \
44  { \
45  m_##name = val; \
46  }
47 
48 /**
49  @def QX_PROPERTY
50  @brief A set of data member, getter and setter
51  @param type - data type
52  @param name - data name
53  @param ... - data default value
54 **/
55 #define QX_PROPERTY(type, name, ...) \
56 public: \
57  QX_GETTER(type, name); \
58  QX_SETTER(type, name); \
59  \
60 private: \
61  type m_##name = type(__VA_ARGS__)