HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
version.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
29 ///////////////////////////////////////////////////////////////////////////
30 
31 /// @file version.h
32 /// @brief Library and file format version numbers
33 ///
34 /// @details
35 /// When the library is built with the latest ABI, its namespace has the form
36 /// <B>openvdb::vX_Y</B>, where @e X and @e Y are the major and minor version numbers.
37 ///
38 /// The library can be built using an older ABI by changing the value of the
39 /// @b OPENVDB_ABI_VERSION_NUMBER macro (e.g., via <TT>-DOPENVDB_ABI_VERSION_NUMBER=<I>N</I></TT>).
40 /// In that case, the namespace has the form <B>openvdb::vX_YabiN</B>,
41 /// where N is the ABI version number.
42 /// The ABI version must be set consistently when building code that depends on OpenVDB.
43 ///
44 /// The ABI version number defaults to the library major version number,
45 /// which gets incremented whenever changes are made to the ABI of the
46 /// Grid class or related classes (Tree, Transform, Metadata, etc.).
47 /// Setting the ABI version number to an earlier library version number
48 /// disables grid ABI changes made since that library version.
49 /// The OpenVDB 1.x ABI is no longer supported, and support for other old ABIs
50 /// might also eventually be dropped.
51 ///
52 /// The library minor version number gets incremented whenever a change is made
53 /// to any aspect of the public API (not just the grid API) that necessitates
54 /// changes to client code. Changes to APIs in private or internal namespaces
55 /// do not trigger a minor version number increment; such APIs should not be used
56 /// in client code.
57 ///
58 /// A patch version number increment indicates a change&mdash;usually a new feature
59 /// or a bug fix&mdash;that does not necessitate changes to client code but rather
60 /// only recompilation of that code (because the library namespace incorporates
61 /// the version number).
62 ///
63 /// The file format version number gets incremented when it becomes possible
64 /// to write files that cannot safely be read with older versions of the library.
65 /// Not all files written in a newer format are incompatible with older libraries, however.
66 /// And in general, files containing grids of unknown type can be read safely,
67 /// although the unknown grids will not be accessible.
68 
69 #ifndef OPENVDB_VERSION_HAS_BEEN_INCLUDED
70 #define OPENVDB_VERSION_HAS_BEEN_INCLUDED
71 
72 #include "Platform.h"
73 
74 /// @name Utilities
75 /// @{
76 /// @cond OPENVDB_VERSION_INTERNAL
77 #define OPENVDB_PREPROC_STRINGIFY_(x) #x
78 /// @endcond
79 /// @brief Return @a x as a string literal. If @a x is a macro,
80 /// return its value as a string literal.
81 /// @hideinitializer
82 #define OPENVDB_PREPROC_STRINGIFY(x) OPENVDB_PREPROC_STRINGIFY_(x)
83 
84 /// @cond OPENVDB_VERSION_INTERNAL
85 #define OPENVDB_PREPROC_CONCAT_(x, y) x ## y
86 /// @endcond
87 /// @brief Form a new token by concatenating two existing tokens.
88 /// If either token is a macro, concatenate its value.
89 /// @hideinitializer
90 #define OPENVDB_PREPROC_CONCAT(x, y) OPENVDB_PREPROC_CONCAT_(x, y)
91 /// @}
92 
93 // Library major, minor and patch version numbers
94 #define OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER 6
95 #define OPENVDB_LIBRARY_MINOR_VERSION_NUMBER 2
96 #define OPENVDB_LIBRARY_PATCH_VERSION_NUMBER 1
97 
98 // If OPENVDB_ABI_VERSION_NUMBER is already defined (e.g., via -DOPENVDB_ABI_VERSION_NUMBER=N)
99 // use that ABI version. Otherwise, use this library version's default ABI.
100 #ifdef OPENVDB_ABI_VERSION_NUMBER
101  #if OPENVDB_ABI_VERSION_NUMBER > OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER
102  #error expected OPENVDB_ABI_VERSION_NUMBER <= OPENVDB_LIBRARY_MAJOR VERSION_NUMBER
103  #endif
104 #else
105  // Older versions of the library used the macros OPENVDB_2_ABI_COMPATIBLE
106  // and OPENVDB_3_ABI_COMPATIBLE. For now, continue to support them.
107  #if defined OPENVDB_2_ABI_COMPATIBLE ///< @todo deprecated
108  #define OPENVDB_ABI_VERSION_NUMBER 2
109  #elif defined OPENVDB_3_ABI_COMPATIBLE ///< @todo deprecated
110  #define OPENVDB_ABI_VERSION_NUMBER 3
111  #else
112  #define OPENVDB_ABI_VERSION_NUMBER OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER
113  #endif
114 #endif
115 
116 // If using an OPENVDB_ABI_VERSION_NUMBER that has been deprecated, issue a message
117 // directive. Note that an error is also set in openvdb.cc which enforces stricter
118 // behavior during compilation of the library. Both can be optionally suppressed
119 // by defining OPENVDB_USE_DEPRECATED_ABI.
120 #ifndef OPENVDB_USE_DEPRECATED_ABI
121  #if OPENVDB_ABI_VERSION_NUMBER <= 3
122  PRAGMA(message("NOTE: ABI <= 3 is deprecated, define OPENVDB_USE_DEPRECATED_ABI "
123  "to suppress this message"))
124  #endif
125 #endif
126 
127 #if OPENVDB_ABI_VERSION_NUMBER == OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER
128  /// @brief The version namespace name for this library version
129  /// @hideinitializer
130  ///
131  /// When the ABI version number matches the library major version number,
132  /// symbols are named as in the following examples:
133  /// - @b openvdb::vX_Y::Vec3i
134  /// - @b openvdb::vX_Y::io::File
135  /// - @b openvdb::vX_Y::tree::Tree
136  ///
137  /// where X and Y are the major and minor version numbers.
138  ///
139  /// When the ABI version number does not match the library major version number,
140  /// symbol names include the ABI version:
141  /// - @b openvdb::vX_YabiN::Vec3i
142  /// - @b openvdb::vX_YabiN::io::File
143  /// - @b openvdb::vX_YabiN::tree::Tree
144  ///
145  /// where X, Y and N are the major, minor and ABI version numbers, respectively.
146  #define OPENVDB_VERSION_NAME \
147  OPENVDB_PREPROC_CONCAT(v, \
148  OPENVDB_PREPROC_CONCAT(OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER, \
149  OPENVDB_PREPROC_CONCAT(_, \
150  OPENVDB_PREPROC_CONCAT(OPENVDB_LIBRARY_MINOR_VERSION_NUMBER, _sesi))))
151 #else
152  // This duplication of code is necessary to avoid issues with recursive macro expansion.
153  #define OPENVDB_VERSION_NAME \
154  OPENVDB_PREPROC_CONCAT(v, \
155  OPENVDB_PREPROC_CONCAT(OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER, \
156  OPENVDB_PREPROC_CONCAT(_, \
157  OPENVDB_PREPROC_CONCAT(OPENVDB_LIBRARY_MINOR_VERSION_NUMBER, \
158  OPENVDB_PREPROC_CONCAT(_sesi_, \
159  OPENVDB_PREPROC_CONCAT(abi, OPENVDB_ABI_VERSION_NUMBER))))))
160 #endif
161 
162 /// @brief Library version number string of the form "<major>.<minor>.<patch>"
163 /// @details This is a macro rather than a static constant because we typically
164 /// want the compile-time version number, not the runtime version number
165 /// (although the two are usually the same).
166 /// @hideinitializer
167 #define OPENVDB_LIBRARY_VERSION_STRING \
168  OPENVDB_PREPROC_STRINGIFY(OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER) "." \
169  OPENVDB_PREPROC_STRINGIFY(OPENVDB_LIBRARY_MINOR_VERSION_NUMBER) "." \
170  OPENVDB_PREPROC_STRINGIFY(OPENVDB_LIBRARY_PATCH_VERSION_NUMBER)
171 
172 /// @brief Library version number string of the form "<major>.<minor>.<patch>abi<abi>"
173 /// @details This is a macro rather than a static constant because we typically
174 /// want the compile-time version number, not the runtime version number
175 /// (although the two are usually the same).
176 /// @hideinitializer
177 #define OPENVDB_LIBRARY_ABI_VERSION_STRING \
178  OPENVDB_LIBRARY_VERSION_STRING "abi" OPENVDB_PREPROC_STRINGIFY(OPENVDB_ABI_VERSION_NUMBER)
179 
180 /// Library version number as a packed integer ("%02x%02x%04x", major, minor, patch)
181 #define OPENVDB_LIBRARY_VERSION_NUMBER \
182  ((OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER << 24) | \
183  ((OPENVDB_LIBRARY_MINOR_VERSION_NUMBER & 0xFF) << 16) | \
184  (OPENVDB_LIBRARY_PATCH_VERSION_NUMBER & 0xFFFF))
185 
186 
187 /// By default, the @b OPENVDB_REQUIRE_VERSION_NAME macro is undefined, and
188 /// symbols from the version namespace are promoted to the top-level namespace
189 /// so that, for example, @b openvdb::v5_0::io::File can be referred to
190 /// simply as @b openvdb::io::File.
191 ///
192 /// When @b OPENVDB_REQUIRE_VERSION_NAME is defined, symbols must be
193 /// fully namespace-qualified.
194 /// @hideinitializer
195 #ifdef OPENVDB_REQUIRE_VERSION_NAME
196 #define OPENVDB_USE_VERSION_NAMESPACE
197 #else
198 // The empty namespace clause below ensures that OPENVDB_VERSION_NAME
199 // is recognized as a namespace name.
200 #define OPENVDB_USE_VERSION_NAMESPACE \
201  namespace OPENVDB_VERSION_NAME {} \
202  using namespace OPENVDB_VERSION_NAME;
203 #endif
204 
205 
206 namespace openvdb {
208 namespace OPENVDB_VERSION_NAME {
209 
210 /// @brief The magic number is stored in the first four bytes of every VDB file.
211 /// @details This can be used to quickly test whether we have a valid file or not.
212 const int32_t OPENVDB_MAGIC = 0x56444220;
213 
214 // Library major, minor and patch version numbers
215 const uint32_t
219 /// Library version number as a packed integer ("%02x%02x%04x", major, minor, patch)
221 // ABI version number
223 
224 /// @brief The current version number of the VDB file format
225 /// @details This can be used to enable various backwards compatibility switches
226 /// or to reject files that cannot be read.
227 const uint32_t OPENVDB_FILE_VERSION = 224;
228 
229 /// Notable file format version numbers
230 enum {
245 };
246 
247 
248 /// Return a library version number string of the form "<major>.<minor>.<patch>".
249 inline constexpr const char* getLibraryVersionString() { return OPENVDB_LIBRARY_VERSION_STRING; }
250 /// Return a library version number string of the form "<major>.<minor>.<patch>abi<abi>".
251 inline constexpr const char* getLibraryAbiVersionString() {
253 }
254 
255 
256 struct VersionId {
257  uint32_t first, second;
258  VersionId(): first(0), second(0) {}
259  VersionId(uint32_t major, uint32_t minor): first(major), second(minor) {}
260 };
261 
262 } // namespace OPENVDB_VERSION_NAME
263 } // namespace openvdb
264 
265 #endif // OPENVDB_VERSION_HAS_BEEN_INCLUDED
266 
267 // Copyright (c) DreamWorks Animation LLC
268 // All rights reserved. This software is distributed under the
269 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
#define OPENVDB_LIBRARY_MINOR_VERSION_NUMBER
Definition: version.h:95
constexpr const char * getLibraryAbiVersionString()
Return a library version number string of the form "<major>.<minor>.<patch>abi<abi>".
Definition: version.h:251
const int32_t OPENVDB_MAGIC
The magic number is stored in the first four bytes of every VDB file.
Definition: version.h:212
#define PRAGMA(x)
Definition: Platform.h:38
const uint32_t OPENVDB_LIBRARY_PATCH_VERSION
Definition: version.h:218
#define OPENVDB_LIBRARY_PATCH_VERSION_NUMBER
Definition: version.h:96
#define OPENVDB_LIBRARY_VERSION_STRING
Library version number string of the form "<major>.<minor>.<patch>".
Definition: version.h:167
const GLint * first
Definition: glew.h:1528
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:200
#define OPENVDB_ABI_VERSION_NUMBER
<
Definition: version.h:112
#define OPENVDB_LIBRARY_VERSION_NUMBER
Library version number as a packed integer ("%02x%02x%04x", major, minor, patch)
Definition: version.h:181
const uint32_t OPENVDB_LIBRARY_VERSION
Library version number as a packed integer ("%02x%02x%04x", major, minor, patch)
Definition: version.h:220
GLsizei GLenum GLuint GLuint GLsizei GLchar * message
Definition: glew.h:2581
VersionId(uint32_t major, uint32_t minor)
Definition: version.h:259
const uint32_t OPENVDB_LIBRARY_MAJOR_VERSION
Definition: version.h:216
#define OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER
Definition: version.h:94
#define OPENVDB_LIBRARY_ABI_VERSION_STRING
Library version number string of the form "<major>.<minor>.<patch>abi<abi>".
Definition: version.h:177
const uint32_t OPENVDB_LIBRARY_MINOR_VERSION
Definition: version.h:217
const uint32_t OPENVDB_ABI_VERSION
Definition: version.h:222
constexpr const char * getLibraryVersionString()
Return a library version number string of the form "<major>.<minor>.<patch>".
Definition: version.h:249
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:146
const uint32_t OPENVDB_FILE_VERSION
The current version number of the VDB file format.
Definition: version.h:227