Tue, 07 Jan 2014 11:56:26 +0200
- some cleanup
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
600
209e3f1f7b2c
- updated copyright year. Best wishes for 2014!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
583
diff
changeset
|
3 | * Copyright (C) 2013, 2014 Santeri Piippo |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #ifndef LDFORGE_PROPERTY_H |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #define LDFORGE_PROPERTY_H |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | |
603 | 22 | #define PROPERTY( ACCESS, TYPE, NAME, OPS, WRITETYPE ) \ |
23 | private: \ | |
24 | TYPE m_##NAME; \ | |
25 | \ | |
26 | public: \ | |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | inline TYPE const& GET_READ_METHOD( NAME, OPS ) const \ |
603 | 28 | { \ |
29 | return m_##NAME; \ | |
30 | } \ | |
31 | \ | |
32 | ACCESS: \ | |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | DEFINE_WRITE_METHOD_##WRITETYPE( TYPE, NAME ) \ |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | DEFINE_PROPERTY_##OPS( TYPE, NAME ) |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | #define GET_READ_METHOD( NAME, OPS ) \ |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | GET_READ_METHOD_##OPS( NAME ) |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | #define GET_READ_METHOD_BOOL_OPS( NAME ) is##NAME() |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | #define GET_READ_METHOD_NO_OPS( NAME ) get##NAME() |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | #define GET_READ_METHOD_STR_OPS( NAME ) get##NAME() |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | #define GET_READ_METHOD_NUM_OPS( NAME ) get##NAME() |
549
715d9a7f6598
Cleaned up download.cpp/.h, used PROPERTY. Added LIST_OPS to PROPERTY
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
43 | #define GET_READ_METHOD_LIST_OPS( NAME ) get##NAME() |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | #define DEFINE_WRITE_METHOD_STOCK_WRITE( TYPE, NAME ) \ |
603 | 46 | inline void set##NAME( TYPE const& NAME##_ ) \ |
47 | { \ | |
48 | m_##NAME = NAME##_; \ | |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | } |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | #define DEFINE_WRITE_METHOD_CUSTOM_WRITE( TYPE, NAME ) \ |
603 | 52 | void set##NAME( TYPE const& NAME##_ ); \ |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | #define DEFINE_WITH_CB( NAME ) void NAME##Changed(); |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | #define DEFINE_NO_CB( NAME ) |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | #define DEFINE_PROPERTY_NO_OPS( TYPE, NAME ) |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | |
603 | 59 | #define DEFINE_PROPERTY_STR_OPS( TYPE, NAME ) \ |
604 | 60 | void appendTo##NAME( TYPE a ) \ |
603 | 61 | { \ |
62 | TYPE tmp( m_##NAME ); \ | |
604 | 63 | tmp.append( a ); \ |
603 | 64 | set##NAME( tmp ); \ |
65 | } \ | |
66 | \ | |
604 | 67 | void prependTo##NAME( TYPE a ) \ |
603 | 68 | { \ |
69 | TYPE tmp( m_##NAME ); \ | |
70 | tmp.prepend( a ); \ | |
71 | set##NAME( tmp ); \ | |
72 | } \ | |
73 | \ | |
74 | void replaceIn##NAME( TYPE a, TYPE b ) \ | |
75 | { \ | |
76 | TYPE tmp( m_##NAME ); \ | |
77 | tmp.replace( a, b ); \ | |
78 | set##NAME( tmp ); \ | |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | } |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | |
603 | 81 | #define DEFINE_PROPERTY_NUM_OPS( TYPE, NAME ) \ |
82 | inline void increase##NAME( TYPE a = 1 ) \ | |
83 | { \ | |
84 | set##NAME( m_##NAME + a ); \ | |
85 | } \ | |
86 | \ | |
87 | inline void decrease##NAME( TYPE a = 1 ) \ | |
88 | { \ | |
89 | set##NAME( m_##NAME - a ); \ | |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | } |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | |
603 | 92 | #define DEFINE_PROPERTY_BOOL_OPS( TYPE, NAME ) \ |
93 | inline void toggle##NAME() \ | |
94 | { \ | |
95 | set##NAME( !m_##NAME ); \ | |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | } |
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | |
549
715d9a7f6598
Cleaned up download.cpp/.h, used PROPERTY. Added LIST_OPS to PROPERTY
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
98 | #define DEFINE_PROPERTY_LIST_OPS( TYPE, NAME ) \ |
715d9a7f6598
Cleaned up download.cpp/.h, used PROPERTY. Added LIST_OPS to PROPERTY
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
99 | void pushTo##NAME( const TYPE::value_type& a ) \ |
603 | 100 | { \ |
101 | TYPE tmp( m_##NAME ); \ | |
102 | tmp.push_back( a ); \ | |
103 | set##NAME( tmp ); \ | |
104 | } \ | |
105 | \ | |
583
4906c5c1670f
- documents are now refcounted. This should seriously stabilize (and speed up!) the pruning of unused files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
549
diff
changeset
|
106 | void removeFrom##NAME( const TYPE::value_type& a ) \ |
603 | 107 | { \ |
108 | TYPE tmp( m_##NAME ); \ | |
109 | tmp.removeOne( a ); \ | |
110 | set##NAME( tmp ); \ | |
111 | } \ | |
112 | \ | |
113 | inline void clear##NAME() \ | |
114 | { \ | |
115 | set##NAME( TYPE() ); \ | |
549
715d9a7f6598
Cleaned up download.cpp/.h, used PROPERTY. Added LIST_OPS to PROPERTY
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
116 | } |
715d9a7f6598
Cleaned up download.cpp/.h, used PROPERTY. Added LIST_OPS to PROPERTY
Santeri Piippo <crimsondusk64@gmail.com>
parents:
541
diff
changeset
|
117 | |
541
0e38beeb050a
- Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | #endif // LDFORGE_PROPERTY_H |