src/PropertyMacro.h

Wed, 05 Mar 2014 03:45:49 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 05 Mar 2014 03:45:49 +0200
changeset 641
425b169a82aa
parent 630
42ec68fcad9e
permissions
-rw-r--r--

- changed header guards into #pragma once

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
641
425b169a82aa - changed header guards into #pragma once
Santeri Piippo <crimsondusk64@gmail.com>
parents: 630
diff changeset
19 #pragma once
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
21 // =============================================================================
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 // Identifier names
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
24 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
25 #define PROPERTY_SET_ACCESSOR(NAME) set##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
26 #define PROPERTY_GET_ACCESSOR(NAME) get##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
27 #define PROPERTY_IS_ACCESSOR(NAME) is##NAME // for bool types
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
28 #define PROPERTY_MEMBER_NAME(NAME) m_##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
29
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
30 // Names of operations
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
31 #define PROPERTY_APPEND_OPERATION(NAME) appendTo##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
32 #define PROPERTY_PREPEND_OPERATION(NAME) prependTo##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
33 #define PROPERTY_REPLACE_OPERATION(NAME) replaceIn##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
34 #define PROPERTY_INCREASE_OPERATION(NAME) increase##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
35 #define PROPERTY_DECREASE_OPERATION(NAME) decrease##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
36 #define PROPERTY_TOGGLE_OPERATION(NAME) toggle##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
37 #define PROPERTY_PUSH_OPERATION(NAME) pushTo##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
38 #define PROPERTY_REMOVE_OPERATION(NAME) removeFrom##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
39 #define PROPERTY_CLEAR_OPERATION(NAME) clear##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
40 #define PROPERTY_COUNT_OPERATION(NAME) count##NAME
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
41
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
42 // Operation definitions
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
43 // 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
44 #define PROPERTY_APPEND_METHOD_NAME append // QString::append
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
45 #define PROPERTY_PREPEND_METHOD_NAME prepend // QString::prepend
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
46 #define PROPERTY_REPLACE_METHOD_NAME replace // QString::replace
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
47 #define PROPERTY_PUSH_METHOD_NAME append // QList<T>::append
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
48 #define PROPERTY_REMOVE_METHOD_NAME removeOne // QList<T>::removeOne
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
49 #define PROPERTY_CLEAR_METHOD_NAME clear // QList<T>::clear
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
51 // =============================================================================
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 // Main PROPERTY macro
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
54 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
55 #define PROPERTY(ACCESS, TYPE, NAME, OPS, WRITETYPE) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
56 private: \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
57 TYPE PROPERTY_MEMBER_NAME(NAME); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
58 \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
59 public: \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
60 inline TYPE const& PROPERTY_GET_READ_METHOD (NAME, OPS) const \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
61 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
62 return PROPERTY_MEMBER_NAME(NAME); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
63 } \
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 ACCESS: \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
66 PROPERTY_MAKE_WRITE (TYPE, NAME, WRITETYPE) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
67 PROPERTY_DEFINE_OPERATIONS (TYPE, NAME, OPS)
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
69 // =============================================================================
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 // PROPERTY_GET_READ_METHOD
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
72 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
73 // 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
74 // 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
75 // 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
76 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
77 #define PROPERTY_GET_READ_METHOD(NAME, OPS) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
78 PROPERTY_GET_READ_METHOD_##OPS (NAME)
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
79
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
80 #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
81 #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
82 #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
83 #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
84 #define PROPERTY_GET_READ_METHOD_LIST_OPS(NAME) PROPERTY_GET_ACCESSOR (NAME)()
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
86 // =============================================================================
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 // PROPERTY_MAKE_WRITE
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
89 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
90 // 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
91 // 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
92 // 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
93 // 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
94 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
95 #define PROPERTY_MAKE_WRITE(TYPE, NAME, WRITETYPE) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
96 PROPERTY_MAKE_WRITE_##WRITETYPE (TYPE, NAME)
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
97
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
98 #define PROPERTY_MAKE_WRITE_STOCK_WRITE(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
99 inline void set##NAME (TYPE const& new##NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
100 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
101 PROPERTY_MEMBER_NAME(NAME) = new##NAME; \
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
104 #define PROPERTY_MAKE_WRITE_CUSTOM_WRITE(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
105 void set##NAME (TYPE const& new##NAME); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
106
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 // PROPERTY_DEFINE_OPERATIONS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
110 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
111 // 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
112 // method.
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
114 #define PROPERTY_DEFINE_OPERATIONS(TYPE, NAME, OPS) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
115 DEFINE_PROPERTY_##OPS (TYPE, NAME)
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
117 // =============================================================================
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 // DEFINE_PROPERTY_NO_OPS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
120 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
121 // Obviously NO_OPS expands into no operations.
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
122 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
123 #define DEFINE_PROPERTY_NO_OPS(TYPE, NAME)
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
125 // =============================================================================
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 // DEFINE_PROPERTY_STR_OPS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
128 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
129 #define DEFINE_PROPERTY_STR_OPS(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
130 void PROPERTY_APPEND_OPERATION(NAME) (const TYPE& a) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
131 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
132 TYPE tmp (PROPERTY_MEMBER_NAME(NAME)); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
133 tmp.PROPERTY_APPEND_METHOD_NAME (a); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
134 set##NAME (tmp); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
135 } \
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 void PROPERTY_PREPEND_OPERATION(NAME) (const TYPE& a) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
138 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
139 TYPE tmp (PROPERTY_MEMBER_NAME(NAME)); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
140 tmp.PROPERTY_PREPEND_METHOD_NAME (a); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
141 set##NAME (tmp); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
142 } \
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 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
145 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
146 TYPE tmp (PROPERTY_MEMBER_NAME(NAME)); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
147 tmp.PROPERTY_REPLACE_METHOD_NAME (a, b); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
148 set##NAME (tmp); \
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
151 // =============================================================================
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 // DEFINE_PROPERTY_NUM_OPS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
154 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
155 #define DEFINE_PROPERTY_NUM_OPS(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
156 inline void PROPERTY_INCREASE_OPERATION(NAME) (TYPE a = 1) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
157 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
158 set##NAME (PROPERTY_MEMBER_NAME(NAME) + a); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
159 } \
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 inline void PROPERTY_DECREASE_OPERATION(NAME) (TYPE a = 1) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
162 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
163 set##NAME (PROPERTY_MEMBER_NAME(NAME) - a); \
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
166 // =============================================================================
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 // DEFINE_PROPERTY_BOOL_OPS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
169 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
170 #define DEFINE_PROPERTY_BOOL_OPS(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
171 inline void PROPERTY_TOGGLE_OPERATION(NAME)() \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
172 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
173 set##NAME (!PROPERTY_MEMBER_NAME(NAME)); \
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174 }
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175
630
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
176 // =============================================================================
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 // DEFINE_PROPERTY_LIST_OPS
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
179 //
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
180 #define DEFINE_PROPERTY_LIST_OPS(TYPE, NAME) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
181 void PROPERTY_PUSH_OPERATION(NAME) (const TYPE::value_type& a) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
182 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
183 PROPERTY_MEMBER_NAME(NAME).PROPERTY_PUSH_METHOD_NAME (a); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
184 } \
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 void PROPERTY_REMOVE_OPERATION(NAME) (const TYPE::value_type& a) \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
187 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
188 PROPERTY_MEMBER_NAME(NAME).PROPERTY_REMOVE_METHOD_NAME (a); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
189 } \
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 inline void PROPERTY_CLEAR_OPERATION(NAME)() \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
192 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
193 PROPERTY_MEMBER_NAME(NAME).PROPERTY_CLEAR_METHOD_NAME(); \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
194 } \
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 public: \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
197 inline int PROPERTY_COUNT_OPERATION(NAME)() const \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
198 { \
42ec68fcad9e - updated the PROPERTY macro
Santeri Piippo <crimsondusk64@gmail.com>
parents: 629
diff changeset
199 return PROPERTY_GET_ACCESSOR (NAME)().size(); \
629
b75c6cce02e2 - refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 }

mercurial