src/PropertyMacro.h

Sun, 23 Feb 2014 18:49:24 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sun, 23 Feb 2014 18:49:24 +0200
changeset 684
8a56b1d4d44d
parent 630
42ec68fcad9e
child 641
425b169a82aa
permissions
-rw-r--r--

- greatly improved the GL compiler, now deals colors and object removal properly

629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013, 2014 Santeri Piippo
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #ifndef LDFORGE_PROPERTY_H
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #define LDFORGE_PROPERTY_H
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
22 // =============================================================================
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
23 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
24 // Identifier names
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
25 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
26 #define PROPERTY_SET_ACCESSOR(NAME) set##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
27 #define PROPERTY_GET_ACCESSOR(NAME) get##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
28 #define PROPERTY_IS_ACCESSOR(NAME) is##NAME // for bool types
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
29 #define PROPERTY_MEMBER_NAME(NAME) m_##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
30
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
31 // Names of operations
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
32 #define PROPERTY_APPEND_OPERATION(NAME) appendTo##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
33 #define PROPERTY_PREPEND_OPERATION(NAME) prependTo##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
34 #define PROPERTY_REPLACE_OPERATION(NAME) replaceIn##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
35 #define PROPERTY_INCREASE_OPERATION(NAME) increase##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
36 #define PROPERTY_DECREASE_OPERATION(NAME) decrease##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
37 #define PROPERTY_TOGGLE_OPERATION(NAME) toggle##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
38 #define PROPERTY_PUSH_OPERATION(NAME) pushTo##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
39 #define PROPERTY_REMOVE_OPERATION(NAME) removeFrom##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
40 #define PROPERTY_CLEAR_OPERATION(NAME) clear##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
41 #define PROPERTY_COUNT_OPERATION(NAME) count##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
42
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
43 // Operation definitions
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
44 // These are the methods of the list type that are called in the operations.
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
45 #define PROPERTY_APPEND_METHOD_NAME append // QString::append
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
46 #define PROPERTY_PREPEND_METHOD_NAME prepend // QString::prepend
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
47 #define PROPERTY_REPLACE_METHOD_NAME replace // QString::replace
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
48 #define PROPERTY_PUSH_METHOD_NAME append // QList<T>::append
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
49 #define PROPERTY_REMOVE_METHOD_NAME removeOne // QList<T>::removeOne
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
50 #define PROPERTY_CLEAR_METHOD_NAME clear // QList<T>::clear
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
52 // =============================================================================
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
53 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
54 // Main PROPERTY macro
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
55 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
56 #define PROPERTY(ACCESS, TYPE, NAME, OPS, WRITETYPE) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
57 private: \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
58 TYPE PROPERTY_MEMBER_NAME(NAME); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
59 \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
60 public: \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
61 inline TYPE const& PROPERTY_GET_READ_METHOD (NAME, OPS) const \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
62 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
63 return PROPERTY_MEMBER_NAME(NAME); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
64 } \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
65 \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
66 ACCESS: \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
67 PROPERTY_MAKE_WRITE (TYPE, NAME, WRITETYPE) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
68 PROPERTY_DEFINE_OPERATIONS (TYPE, NAME, OPS)
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
70 // =============================================================================
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
71 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
72 // PROPERTY_GET_READ_METHOD
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
73 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
74 // This macro uses the OPS argument to construct the name of the actual
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
75 // macro which returns the name of the get accessor. This is so that the
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
76 // bool properties get is<NAME>() accessors while non-bools get get<NAME>()
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
77 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
78 #define PROPERTY_GET_READ_METHOD(NAME, OPS) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
79 PROPERTY_GET_READ_METHOD_##OPS (NAME)
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
80
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
81 #define PROPERTY_GET_READ_METHOD_BOOL_OPS(NAME) PROPERTY_IS_ACCESSOR (NAME)()
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
82 #define PROPERTY_GET_READ_METHOD_NO_OPS(NAME) PROPERTY_GET_ACCESSOR (NAME)()
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
83 #define PROPERTY_GET_READ_METHOD_STR_OPS(NAME) PROPERTY_GET_ACCESSOR (NAME)()
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
84 #define PROPERTY_GET_READ_METHOD_NUM_OPS(NAME) PROPERTY_GET_ACCESSOR (NAME)()
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
85 #define PROPERTY_GET_READ_METHOD_LIST_OPS(NAME) PROPERTY_GET_ACCESSOR (NAME)()
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
87 // =============================================================================
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
88 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
89 // PROPERTY_MAKE_WRITE
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
90 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
91 // This macro uses the WRITETYPE argument to construct the set accessor of the
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
92 // property. If WRITETYPE is STOCK_WRITE, an inline method is defined to just
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
93 // set the new value of the property. If WRITETYPE is CUSTOM_WRITE, the accessor
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
94 // is merely declared and is left for the user to define.
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
95 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
96 #define PROPERTY_MAKE_WRITE(TYPE, NAME, WRITETYPE) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
97 PROPERTY_MAKE_WRITE_##WRITETYPE (TYPE, NAME)
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
98
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
99 #define PROPERTY_MAKE_WRITE_STOCK_WRITE(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
100 inline void set##NAME (TYPE const& new##NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
101 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
102 PROPERTY_MEMBER_NAME(NAME) = new##NAME; \
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
105 #define PROPERTY_MAKE_WRITE_CUSTOM_WRITE(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
106 void set##NAME (TYPE const& new##NAME); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
107
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
108 // =============================================================================
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
109 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
110 // PROPERTY_DEFINE_OPERATIONS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
111 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
112 // This macro may expand into methods defining additional operations for the
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
113 // method.
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
115 #define PROPERTY_DEFINE_OPERATIONS(TYPE, NAME, OPS) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
116 DEFINE_PROPERTY_##OPS (TYPE, NAME)
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
118 // =============================================================================
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
119 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
120 // DEFINE_PROPERTY_NO_OPS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
121 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
122 // Obviously NO_OPS expands into no operations.
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
123 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
124 #define DEFINE_PROPERTY_NO_OPS(TYPE, NAME)
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
126 // =============================================================================
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
127 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
128 // DEFINE_PROPERTY_STR_OPS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
129 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
130 #define DEFINE_PROPERTY_STR_OPS(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
131 void PROPERTY_APPEND_OPERATION(NAME) (const TYPE& a) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
132 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
133 TYPE tmp (PROPERTY_MEMBER_NAME(NAME)); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
134 tmp.PROPERTY_APPEND_METHOD_NAME (a); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
135 set##NAME (tmp); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
136 } \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
137 \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
138 void PROPERTY_PREPEND_OPERATION(NAME) (const TYPE& a) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
139 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
140 TYPE tmp (PROPERTY_MEMBER_NAME(NAME)); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
141 tmp.PROPERTY_PREPEND_METHOD_NAME (a); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
142 set##NAME (tmp); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
143 } \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
144 \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
145 void PROPERTY_REPLACE_OPERATION(NAME) (const TYPE& a, const TYPE& b) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
146 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
147 TYPE tmp (PROPERTY_MEMBER_NAME(NAME)); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
148 tmp.PROPERTY_REPLACE_METHOD_NAME (a, b); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
149 set##NAME (tmp); \
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
152 // =============================================================================
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
153 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
154 // DEFINE_PROPERTY_NUM_OPS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
155 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
156 #define DEFINE_PROPERTY_NUM_OPS(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
157 inline void PROPERTY_INCREASE_OPERATION(NAME) (TYPE a = 1) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
158 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
159 set##NAME (PROPERTY_MEMBER_NAME(NAME) + a); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
160 } \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
161 \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
162 inline void PROPERTY_DECREASE_OPERATION(NAME) (TYPE a = 1) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
163 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
164 set##NAME (PROPERTY_MEMBER_NAME(NAME) - a); \
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
167 // =============================================================================
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
168 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
169 // DEFINE_PROPERTY_BOOL_OPS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
170 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
171 #define DEFINE_PROPERTY_BOOL_OPS(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
172 inline void PROPERTY_TOGGLE_OPERATION(NAME)() \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
173 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
174 set##NAME (!PROPERTY_MEMBER_NAME(NAME)); \
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
177 // =============================================================================
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
178 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
179 // DEFINE_PROPERTY_LIST_OPS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
180 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
181 #define DEFINE_PROPERTY_LIST_OPS(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
182 void PROPERTY_PUSH_OPERATION(NAME) (const TYPE::value_type& a) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
183 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
184 PROPERTY_MEMBER_NAME(NAME).PROPERTY_PUSH_METHOD_NAME (a); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
185 } \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
186 \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
187 void PROPERTY_REMOVE_OPERATION(NAME) (const TYPE::value_type& a) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
188 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
189 PROPERTY_MEMBER_NAME(NAME).PROPERTY_REMOVE_METHOD_NAME (a); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
190 } \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
191 \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
192 inline void PROPERTY_CLEAR_OPERATION(NAME)() \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
193 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
194 PROPERTY_MEMBER_NAME(NAME).PROPERTY_CLEAR_METHOD_NAME(); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
195 } \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
196 \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
197 public: \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
198 inline int PROPERTY_COUNT_OPERATION(NAME)() const \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
199 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
200 return PROPERTY_GET_ACCESSOR (NAME)().size(); \
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 #endif // LDFORGE_PROPERTY_H

mercurial