1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_VERSION_HH
4 #define DUNE_VERSION_HH
5 
6 /** \file
7  * \brief Various macros to work with %Dune module version numbers
8  */
9 
10 /** \brief Constructs the preprocessor name used in config.h to hold version numbers
11  *
12  * For the DUNE core modules you need to use the following module names:
13  *  - DUNE_COMMON for dune-common
14  *  - DUNE_GRID for dune-grid
15  *  - DUNE_GEOMETRY for dune-geometry
16  *  - DUNE_ISTL for dune-istl
17  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
18  *
19  * For external DUNE modules, you should capitalize the name and
20  * replace '-' by underscores. For example for the module foo-bar you
21  * need to use FOO_BAR as module name in the context of this macro.
22  *
23  * \param module The name of the Dune module
24  * \param type The version number type, one of MAJOR, MINOR, or REVISION
25  */
26 #define DUNE_VERSION_JOIN(module,type) module ## _VERSION_ ## type
27 
28 /**
29  * \brief True if 'module' has the version major.minor
30  *
31  * For the DUNE core modules you need to use the following module names:
32  *  - DUNE_COMMON for dune-common
33  *  - DUNE_GRID for dune-grid
34  *  - DUNE_GEOMETRY for dune-geometry
35  *  - DUNE_ISTL for dune-istl
36  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
37  *
38  * For external DUNE modules, you should capitalize the name and
39  * replace '-' by underscores. For example for the module foo-bar you
40  * need to use FOO_BAR as module name in the context of this macro.
41  */
42 #define DUNE_VERSION_EQUAL(module,major,minor) \
43   ((DUNE_VERSION_JOIN(module,MAJOR) == major) && \
44    (DUNE_VERSION_JOIN(module,MINOR) == minor))
45 
46 /**
47  * \brief True if 'module' has the version major.minor.revision
48  *
49  * For the DUNE core modules you need to use the following module names:
50  *  - DUNE_COMMON for dune-common
51  *  - DUNE_GRID for dune-grid
52  *  - DUNE_GEOMETRY for dune-geometry
53  *  - DUNE_ISTL for dune-istl
54  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
55  *
56  * For external DUNE modules, you should capitalize the name and
57  * replace '-' by underscores. For example for the module foo-bar you
58  * need to use FOO_BAR as module name in the context of this macro.
59  */
60 #define DUNE_VERSION_EQUAL_REV(module,major,minor,revision) \
61   ( DUNE_VERSION_EQUAL(module,major,minor) && \
62     (DUNE_VERSION_JOIN(module,REVISION) == revision))
63 
64 /**
65  * \brief True if 'module' has the version major.minor or greater
66  *
67  * For the DUNE core modules you need to use the following module names:
68  *  - DUNE_COMMON for dune-common
69  *  - DUNE_GRID for dune-grid
70  *  - DUNE_GEOMETRY for dune-geometry
71  *  - DUNE_ISTL for dune-istl
72  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
73  *
74  * For external DUNE modules, you should capitalize the name and
75  * replace '-' by underscores. For example for the module foo-bar you
76  * need to use FOO_BAR as module name in the context of this macro.
77  */
78 #define DUNE_VERSION_GTE(module,major,minor) \
79   ((DUNE_VERSION_JOIN(module,MAJOR) > major) \
80    || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) >= minor)))
81 
82 /**
83  * \brief True if 'module' has a version less than major.minor
84  *
85  * For the DUNE core modules you need to use the following module names:
86  *  - DUNE_COMMON for dune-common
87  *  - DUNE_GRID for dune-grid
88  *  - DUNE_GEOMETRY for dune-geometry
89  *  - DUNE_ISTL for dune-istl
90  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
91  *
92  * For external DUNE modules, you should capitalize the name and
93  * replace '-' by underscores. For example for the module foo-bar you
94  * need to use FOO_BAR as module name in the context of this macro.
95  */
96 #define DUNE_VERSION_LT(module,major,minor) \
97   ! DUNE_VERSION_GTE(module,major,minor)
98 
99 /**
100  * \brief True if 'module' has the version major.minor or newer
101  * \note Deprecated, use DUNE_VERSION_GTE instead.
102  *
103  * For the DUNE core modules you need to use the following module names:
104  *  - DUNE_COMMON for dune-common
105  *  - DUNE_GRID for dune-grid
106  *  - DUNE_GEOMETRY for dune-geometry
107  *  - DUNE_ISTL for dune-istl
108  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
109  *
110  * For external DUNE modules, you should capitalize the name and
111  * replace '-' by underscores. For example for the module foo-bar you
112  * need to use FOO_BAR as module name in the context of this macro.
113  */
114 #define DUNE_VERSION_NEWER(module,major,minor) \
115   DUNE_VERSION_GTE(module,major,minor)
116 
117 /**
118  * \brief True if 'module' has a version greater than major.minor
119  *
120  * For the DUNE core modules you need to use the following module names:
121  *  - DUNE_COMMON for dune-common
122  *  - DUNE_GRID for dune-grid
123  *  - DUNE_GEOMETRY for dune-geometry
124  *  - DUNE_ISTL for dune-istl
125  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
126  *
127  * For external DUNE modules, you should capitalize the name and
128  * replace '-' by underscores. For example for the module foo-bar you
129  * need to use FOO_BAR as module name in the context of this macro.
130  */
131 #define DUNE_VERSION_GT(module,major,minor) \
132   ((DUNE_VERSION_JOIN(module,MAJOR) > major) \
133    || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) > minor)))
134 
135 /**
136  * \brief True if 'module' has a version less than or equal to major.minor
137  *
138  * For the DUNE core modules you need to use the following module names:
139  *  - DUNE_COMMON for dune-common
140  *  - DUNE_GRID for dune-grid
141  *  - DUNE_GEOMETRY for dune-geometry
142  *  - DUNE_ISTL for dune-istl
143  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
144  *
145  * For external DUNE modules, you should capitalize the name and
146  * replace '-' by underscores. For example for the module foo-bar you
147  * need to use FOO_BAR as module name in the context of this macro.
148  */
149 #define DUNE_VERSION_LTE(module,major,minor) \
150   ! DUNE_VERSION_GT(module,major,minor)
151 
152 /**
153  * \brief True if 'module' has the version major.minor.revision or greater
154  *
155  * For the DUNE core modules you need to use the following module names:
156  *  - DUNE_COMMON for dune-common
157  *  - DUNE_GRID for dune-grid
158  *  - DUNE_GEOMETRY for dune-geometry
159  *  - DUNE_ISTL for dune-istl
160  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
161  *
162  * For external DUNE modules, you should capitalize the name and
163  * replace '-' by underscores. For example for the module foo-bar you
164  * need to use FOO_BAR as module name in the context of this macro.
165  */
166 #define DUNE_VERSION_GTE_REV(module,major,minor,revision) \
167   ((DUNE_VERSION_JOIN(module,MAJOR) > major) \
168    || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) > minor)) \
169    || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) == minor) \
170        && (DUNE_VERSION_JOIN(module,REVISION) >= revision)))
171 
172 /**
173  * \brief True if 'module' has a version lower than major.minor.revision
174  *
175  * For the DUNE core modules you need to use the following module names:
176  *  - DUNE_COMMON for dune-common
177  *  - DUNE_GRID for dune-grid
178  *  - DUNE_GEOMETRY for dune-geometry
179  *  - DUNE_ISTL for dune-istl
180  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
181  *
182  * For external DUNE modules, you should capitalize the name and
183  * replace '-' by underscores. For example for the module foo-bar you
184  * need to use FOO_BAR as module name in the context of this macro.
185  */
186 #define DUNE_VERSION_LT_REV(module,major,minor,revision) \
187   ! DUNE_VERSION_GTE_REV(module,major,minor,revision)
188 
189 /**
190  * \brief True if 'module' has the version major.minor.revision or newer
191  * \note Deprecated, use DUNE_VERSION_GTE_REV instead.
192  *
193  * For the DUNE core modules you need to use the following module names:
194  *  - DUNE_COMMON for dune-common
195  *  - DUNE_GRID for dune-grid
196  *  - DUNE_GEOMETRY for dune-geometry
197  *  - DUNE_ISTL for dune-istl
198  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
199  *
200  * For external DUNE modules, you should capitalize the name and
201  * replace '-' by underscores. For example for the module foo-bar you
202  * need to use FOO_BAR as module name in the context of this macro.
203  */
204 #define DUNE_VERSION_NEWER_REV(module,major,minor,revision) \
205   DUNE_VERSION_GTE_REV(module,major,minor,revision)
206 
207 /**
208  * \brief True if 'module' has a greater version than major.minor.revision
209  *
210  * For the DUNE core modules you need to use the following module names:
211  *  - DUNE_COMMON for dune-common
212  *  - DUNE_GRID for dune-grid
213  *  - DUNE_GEOMETRY for dune-geometry
214  *  - DUNE_ISTL for dune-istl
215  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
216  *
217  * For external DUNE modules, you should capitalize the name and
218  * replace '-' by underscores. For example for the module foo-bar you
219  * need to use FOO_BAR as module name in the context of this macro.
220  */
221 #define DUNE_VERSION_GT_REV(module,major,minor,revision) \
222   ((DUNE_VERSION_JOIN(module,MAJOR) > major) \
223    || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) > minor)) \
224    || ((DUNE_VERSION_JOIN(module,MAJOR) == major) && (DUNE_VERSION_JOIN(module,MINOR) == minor) \
225        && (DUNE_VERSION_JOIN(module,REVISION) > revision)))
226 
227 /**
228  * \brief True if 'module' has a version lower or equal to major.minor.revision
229  *
230  * For the DUNE core modules you need to use the following module names:
231  *  - DUNE_COMMON for dune-common
232  *  - DUNE_GRID for dune-grid
233  *  - DUNE_GEOMETRY for dune-geometry
234  *  - DUNE_ISTL for dune-istl
235  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
236  *
237  * For external DUNE modules, you should capitalize the name and
238  * replace '-' by underscores. For example for the module foo-bar you
239  * need to use FOO_BAR as module name in the context of this macro.
240  */
241 #define DUNE_VERSION_LTE_REV(module,major,minor,revision) \
242   ! DUNE_VERSION_GT_REV(module,major,minor,revision)
243 
244 /**
245  * \brief Compute a unique uint id from the major, minor, and revision numbers
246  *
247  * For the DUNE core modules you need to use the following module names:
248  *  - DUNE_COMMON for dune-common
249  *  - DUNE_GRID for dune-grid
250  *  - DUNE_GEOMETRY for dune-geometry
251  *  - DUNE_ISTL for dune-istl
252  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
253  *
254  * For external DUNE modules, you should capitalize the name and
255  * replace '-' by underscores. For example for the module foo-bar you
256  * need to use FOO_BAR as module name in the context of this macro.
257  */
258 #define DUNE_VERSION_ID(major,minor,revision) \
259   ((unsigned int)((major << 24) + (minor << 16) + revision))
260 
261 /**
262  * \brief Compute a unique uint id for the given module
263  *
264  * For the DUNE core modules you need to use the following module names:
265  *  - DUNE_COMMON for dune-common
266  *  - DUNE_GRID for dune-grid
267  *  - DUNE_GEOMETRY for dune-geometry
268  *  - DUNE_ISTL for dune-istl
269  *  - DUNE_LOCALFUNCTIONS for dune-localfunctions
270  *
271  * For external DUNE modules, you should capitalize the name and
272  * replace '-' by underscores. For example for the module foo-bar you
273  * need to use FOO_BAR as module name in the context of this macro.
274  */
275 #define DUNE_MODULE_VERSION_ID(module) \
276   DUNE_VERSION_ID( DUNE_VERSION_JOIN(module,MAJOR), DUNE_VERSION_JOIN(module,MINOR), DUNE_VERSION_JOIN(module,REVISION) )
277 
278 #endif
279