Scarab
v2.2.1
Project 8 C++ Utility Library
Main Page
Namespaces
Classes
Files
File List
File Members
library
utility
_member_variables.hh
Go to the documentation of this file.
1
/*
2
* _member_variables.hh
3
*
4
* Created on: Jan 6, 2016
5
* Author: nsoblath
6
*/
7
8
#include "
macros.hh
"
9
44
#define get_fcn( x_variable ) PASTE( get_prefix, x_variable )
45
#define set_fcn( x_variable ) PASTE( set_prefix, x_variable )
46
#define var_name( x_variable ) PASTE( var_prefix, x_variable )
47
#define static_var_name( x_variable ) PASTE( static_prefix, x_variable )
48
49
//**********
50
// normal
51
//**********
52
53
#define mv_accessible_noset( x_type, x_variable )\
54
public:\
55
x_type get_fcn( x_variable )() const\
56
{\
57
return var_name( x_variable );\
58
}\
59
protected:\
60
x_type var_name( x_variable );
61
62
#define mv_accessible( x_type, x_variable )\
63
public:\
64
void set_fcn( x_variable )( x_type p_variable )\
65
{\
66
var_name( x_variable ) = p_variable;\
67
return;\
68
}\
69
mv_accessible_noset( x_type, x_variable )
70
71
#define mv_accessible_static_noset( x_type, x_variable )\
72
public:\
73
static x_type get_fcn( x_variable )()\
74
{\
75
return static_var_name( x_variable );\
76
}\
77
protected:\
78
static x_type static_var_name( x_variable );
79
80
#define mv_accessible_static( x_type, x_variable )\
81
public:\
82
static void set_fcn( x_variable )( x_type p_variable )\
83
{\
84
static_var_name( x_variable ) = p_variable;\
85
return;\
86
}\
87
mv_accessible_static_noset( x_type, x_variable )
88
89
#define mv_accessible_mutable_noset( x_type, x_variable )\
90
public:\
91
x_type get_fcn( x_variable )() const\
92
{\
93
return var_name( x_variable );\
94
}\
95
protected:\
96
mutable x_type var_name( x_variable );
97
98
#define mv_accessible_mutable( x_type, x_variable )\
99
public:\
100
void set_fcn( x_variable )( x_type p_variable ) const\
101
{\
102
var_name( x_variable ) = p_variable;\
103
return;\
104
}\
105
mv_accessible_mutable_noset( x_type, x_variable )
106
107
108
//**************
109
// referrable
110
//**************
111
112
#define mv_referrable_const( x_type, x_variable )\
113
public:\
114
const x_type& x_variable() const\
115
{\
116
return var_name( x_variable );\
117
}\
118
protected:\
119
x_type var_name( x_variable );
120
121
#define mv_referrable( x_type, x_variable )\
122
public:\
123
x_type& x_variable()\
124
{\
125
return var_name( x_variable );\
126
}\
127
mv_referrable_const( x_type, x_variable )
128
129
#define mv_referrable_static( x_type, x_variable )\
130
public:\
131
static x_type& x_variable()\
132
{\
133
return static_var_name( x_variable );\
134
}\
135
protected:\
136
static x_type static_var_name( x_variable );
137
138
#define mv_referrable_mutable( x_type, x_variable )\
139
public:\
140
x_type& x_variable() const\
141
{\
142
return var_name( x_variable );\
143
}\
144
protected:\
145
mutable x_type var_name( x_variable );
146
147
148
//***********
149
// pointer
150
//***********
151
152
#define mv_assignable_noset( x_type, x_variable )\
153
public:\
154
x_type* get_fcn( x_variable )() const\
155
{\
156
return var_name( x_variable );\
157
}\
158
protected:\
159
x_type* var_name( x_variable );
160
161
#define mv_assignable( x_type, x_variable )\
162
public:\
163
void set_fcn( x_variable )( x_type* p_variable )\
164
{\
165
delete var_name( x_variable );\
166
var_name( x_variable ) = p_variable;\
167
return;\
168
}\
169
mv_assignable_noset( x_type, x_variable )
170
171
#define mv_assignable_static_noset( x_type, x_variable )\
172
public:\
173
static x_type* get_fcn( x_variable )()\
174
{\
175
return static_var_name( x_variable );\
176
}\
177
protected:\
178
static x_type* static_var_name( x_variable );
179
180
#define mv_assignable_static( x_type, x_variable )\
181
public:\
182
static void set_fcn( x_variable )( x_type* p_variable )\
183
{\
184
delete static_var_name( x_variable );\
185
static_var_name( x_variable ) = p_variable;\
186
return;\
187
}\
188
mv_assignable_static_noset( x_type, x_variable )
189
190
#define mv_assignable_mutable_noset( x_type, x_variable )\
191
public:\
192
x_type* get_fcn( x_variable )() const\
193
{\
194
return var_name( x_variable );\
195
}\
196
protected:\
197
mutable x_type* var_name( x_variable );
198
199
#define mv_assignable_mutable( x_type, x_variable )\
200
public:\
201
void set_fcn( x_variable )( x_type* p_variable ) const\
202
{\
203
delete var_name( x_variable );\
204
var_name( x_variable ) = p_variable;\
205
return;\
206
}\
207
mv_assignable_mutable_noset( x_type, x_variable )
208
209
210
//**************
211
// shared_ptr
212
//**************
213
214
#define mv_shared_ptr_const( x_type, x_variable )\
215
public:\
216
const std::shared_ptr< x_type > x_variable() const\
217
{\
218
return var_name( x_variable );\
219
}\
220
protected:\
221
std::shared_ptr< x_type > var_name( x_variable );
222
223
#define mv_shared_ptr( x_type, x_variable )\
224
public:\
225
std::shared_ptr< x_type > x_variable()\
226
{\
227
return var_name( x_variable );\
228
}\
229
mv_shared_ptr_const( x_type, x_variable )
230
231
#define mv_shared_ptr_static( x_type, x_variable )\
232
public:\
233
static std::shared_ptr< x_type > x_variable()\
234
{\
235
return static_var_name( x_variable );\
236
}\
237
protected:\
238
static std::shared_ptr< x_type > static_var_name( x_variable );
239
240
#define mv_shared_ptr_mutable( x_type, x_variable )\
241
public:\
242
std::shared_ptr< x_type > x_variable() const\
243
{\
244
return var_name( x_variable );\
245
}\
246
protected:\
247
mutable std::shared_ptr< x_type > var_name( x_variable );
248
249
250
//**********
251
// atomic
252
//**********
253
254
#define mv_atomic_noset( x_type, x_variable )\
255
public:\
256
x_type get_fcn( x_variable )() const\
257
{\
258
return var_name( x_variable ).load();\
259
}\
260
protected:\
261
std::atomic< x_type > var_name( x_variable );
262
263
#define mv_atomic( x_type, x_variable )\
264
public:\
265
void set_fcn( x_variable )( x_type p_variable )\
266
{\
267
var_name( x_variable ).store( p_variable );\
268
return;\
269
}\
270
mv_atomic_noset( x_type, x_variable )
271
272
#define mv_atomic_static_noset( x_type, x_variable )\
273
public:\
274
static x_type get_fcn( x_variable )()\
275
{\
276
return static_var_name( x_variable ).load();\
277
}\
278
protected:\
279
static std::atomic< x_type > static_var_name( x_variable );
280
281
#define mv_atomic_static( x_type, x_variable )\
282
public:\
283
static void set_fcn( x_variable )( x_type p_variable )\
284
{\
285
static_var_name( x_variable ).store( p_variable );\
286
return;\
287
}\
288
mv_atomic_static_noset( x_type, x_variable )
289
290
#define mv_atomic_mutable_noset( x_type, x_variable )\
291
public:\
292
x_type get_fcn( x_variable )() const\
293
{\
294
return var_name( x_variable ).load();\
295
}\
296
protected:\
297
mutable std::atomic< x_type > var_name( x_variable );
298
299
#define mv_atomic_mutable( x_type, x_variable )\
300
public:\
301
void set_fcn( x_variable )( x_type p_variable ) const\
302
{\
303
var_name( x_variable ).store( p_variable );\
304
return;\
305
}\
306
mv_atomic_mutable_noset( x_type, x_variable )
307
macros.hh
Generated by
1.8.11