Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
misc/qt/Macros.h
Go to the documentation of this file.
1#pragma once
2// clang-format off
8#define SF_DECL_PROP_GS(Type, Name) \
9[[nodiscard]] Type get##Name() const; \
10void set##Name(Type);
11
17#define SF_DECL_PROP_GRS(Type, Name) \
18[[nodiscard]] Type get##Name() const; \
19void set##Name(const Type&);
20
26#define SF_DECL_PROP_RGRS(Type, Name) \
27[[nodiscard]] const Type& get##Name() const; \
28void set##Name(const Type&);
29
37#define SF_IMPL_PROP_G(Type, Class, Name, Instance) \
38Type Class::get##Name() const \
39{ \
40 return Instance; \
41}
42
50#define SF_IMPL_PROP_RG(Type, Class, Name, Instance) \
51const Type& Class::get##Name() const \
52{ \
53 return Instance; \
54}
55
63#define SF_IMPL_PROP_S(Type, Class, Name, Instance) \
64void Class::set##Name(Type val) \
65{ \
66 Instance = val; \
67}
68
77#define SF_IMPL_PROP_SN(Type, Class, Name, Instance, NotifyFunc) \
78void Class::set##Name(Type val) \
79{ \
80 if (Instance != val) \
81 { \
82 Instance = val; \
83 NotifyFunc(&Instance); \
84 } \
85}
86
94#define SF_IMPL_PROP_RS(Type, Class, Name, Instance) \
95void Class::set##Name(const Type& val) \
96{ \
97 Instance = val; \
98}
99
108#define SF_IMPL_PROP_RSN(Type, Class, Name, Instance, NotifyFunc) \
109void Class::set##Name(const Type& val) \
110{ \
111 if (Instance != val) \
112 { \
113 Instance = val; \
114 NotifyFunc(&Instance); \
115 } \
116}
117
125#define SF_IMPL_PROP_GS(Type, Class, Name, Instance) \
126SF_IMPL_PROP_G(Type, Class, Name, Instance) \
127SF_IMPL_PROP_S(Type, Class, Name, Instance)
128
129
130#define SF_IMPL_PROP_GRS(Type, Class, Name, Instance) \
131SF_IMPL_PROP_G(Type, Class, Name, Instance) \
132SF_IMPL_PROP_RS(Type, Class, Name, Instance)
133
134
143#define SF_IMPL_PROP_GSN(Type, Class, Name, Instance, NotifyFunc) \
144SF_IMPL_PROP_G(Type, Class, Name, Instance) \
145SF_IMPL_PROP_SN(Type, Class, Name, Instance, NotifyFunc)
146
155#define SF_IMPL_PROP_GRSN(Type, Class, Name, Instance, NotifyFunc) \
156SF_IMPL_PROP_G(Type, Class, Name, Instance) \
157SF_IMPL_PROP_RSN(Type, Class, Name, Instance, NotifyFunc)
158
166#define SF_IMPL_PROP_RGRS(Type, Class, Name, Instance) \
167SF_IMPL_PROP_RG(Type, Class, Name, Instance) \
168SF_IMPL_PROP_RS(Type, Class, Name, Instance)
169
178#define SF_IMPL_PROP_RGRSN(Type, Class, Name, Instance, NotifyFunc) \
179SF_IMPL_PROP_RG(Type, Class, Name, Instance) \
180SF_IMPL_PROP_RSN(Type, Class, Name, Instance, NotifyFunc)
181
190#define SF_IMPL_PROP_GSP(Type, Class, Name, Instance, Property) \
191Type Class::get##Name() const \
192{ \
193 return Instance->property(#Property).value<Type>(); \
194} \
195void Class::set##Name(Type val) \
196{ \
197 Instance->setProperty(#Property, QVariant::fromValue<Type>(val)); \
198}
199// clang-format on