HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
version.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
4 /// @file version.h
5 /// @brief Library and file format version numbers
6 ///
7 /// @details
8 /// When the library is built with the latest ABI, its namespace has the form
9 /// <B>openvdb::vX_Y</B>, where @e X and @e Y are the major and minor version numbers.
10 ///
11 /// The library can be built using an older ABI by changing the value of the
12 /// @b OPENVDB_ABI_VERSION_NUMBER macro (e.g., via <TT>-DOPENVDB_ABI_VERSION_NUMBER=<I>N</I></TT>).
13 /// In that case, the namespace has the form <B>openvdb::vX_YabiN</B>,
14 /// where N is the ABI version number.
15 /// The ABI version must be set consistently when building code that depends on OpenVDB.
16 ///
17 /// The ABI version number defaults to the library major version number,
18 /// which gets incremented whenever changes are made to the ABI of the
19 /// Grid class or related classes (Tree, Transform, Metadata, etc.).
20 /// Setting the ABI version number to an earlier library version number
21 /// disables grid ABI changes made since that library version.
22 /// The OpenVDB 1.x ABI is no longer supported, and support for other old ABIs
23 /// might also eventually be dropped.
24 ///
25 /// The library minor version number gets incremented whenever a change is made
26 /// to any aspect of the public API (not just the grid API) that necessitates
27 /// changes to client code. Changes to APIs in private or internal namespaces
28 /// do not trigger a minor version number increment; such APIs should not be used
29 /// in client code.
30 ///
31 /// A patch version number increment indicates a change&mdash;usually a new feature
32 /// or a bug fix&mdash;that does not necessitate changes to client code but rather
33 /// only recompilation of that code (because the library namespace incorporates
34 /// the version number).
35 ///
36 /// The file format version number gets incremented when it becomes possible
37 /// to write files that cannot safely be read with older versions of the library.
38 /// Not all files written in a newer format are incompatible with older libraries, however.
39 /// And in general, files containing grids of unknown type can be read safely,
40 /// although the unknown grids will not be accessible.
41 
42 #ifndef OPENVDB_VERSION_HAS_BEEN_INCLUDED
43 #define OPENVDB_VERSION_HAS_BEEN_INCLUDED
44 
45 #include "Platform.h"
46 #include <cstdint> // uint32_t
47 
48 /// @name Utilities
49 /// @{
50 /// @cond OPENVDB_VERSION_INTERNAL
51 #define OPENVDB_PREPROC_STRINGIFY_(x) #x
52 /// @endcond
53 /// @brief Return @a x as a string literal. If @a x is a macro,
54 /// return its value as a string literal.
55 /// @hideinitializer
56 #define OPENVDB_PREPROC_STRINGIFY(x) OPENVDB_PREPROC_STRINGIFY_(x)
57 
58 /// @cond OPENVDB_VERSION_INTERNAL
59 #define OPENVDB_PREPROC_CONCAT_(x, y) x ## y
60 /// @endcond
61 /// @brief Form a new token by concatenating two existing tokens.
62 /// If either token is a macro, concatenate its value.
63 /// @hideinitializer
64 #define OPENVDB_PREPROC_CONCAT(x, y) OPENVDB_PREPROC_CONCAT_(x, y)
65 /// @}
66 
67 // Library major, minor and patch version numbers
68 #define OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER 7
69 #define OPENVDB_LIBRARY_MINOR_VERSION_NUMBER 1
70 #define OPENVDB_LIBRARY_PATCH_VERSION_NUMBER 0
71 
72 // If OPENVDB_ABI_VERSION_NUMBER is already defined (e.g., via -DOPENVDB_ABI_VERSION_NUMBER=N)
73 // use that ABI version. Otherwise, use this library version's default ABI.
74 #ifdef OPENVDB_ABI_VERSION_NUMBER
75  #if OPENVDB_ABI_VERSION_NUMBER > OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER
76  #error expected OPENVDB_ABI_VERSION_NUMBER <= OPENVDB_LIBRARY_MAJOR VERSION_NUMBER
77  #endif
78 #else
79  #define OPENVDB_ABI_VERSION_NUMBER OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER
80 #endif
81 
82 // If using an OPENVDB_ABI_VERSION_NUMBER that has been deprecated, issue a message
83 // directive. Note that an error is also set in openvdb.cc which enforces stricter
84 // behavior during compilation of the library. Both can be optionally suppressed
85 // by defining OPENVDB_USE_DEPRECATED_ABI_<VERSION>.
86 #ifndef OPENVDB_USE_DEPRECATED_ABI_5
87  #if OPENVDB_ABI_VERSION_NUMBER == 5
88  PRAGMA(message("NOTE: ABI = 5 is deprecated, CMake option OPENVDB_USE_DEPRECATED_ABI_5 "
89  "suppresses this message"))
90  #endif
91 #endif
92 
93 #if OPENVDB_ABI_VERSION_NUMBER == OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER
94  /// @brief The version namespace name for this library version
95  /// @hideinitializer
96  ///
97  /// When the ABI version number matches the library major version number,
98  /// symbols are named as in the following examples:
99  /// - @b openvdb::vX_Y::Vec3i
100  /// - @b openvdb::vX_Y::io::File
101  /// - @b openvdb::vX_Y::tree::Tree
102  ///
103  /// where X and Y are the major and minor version numbers.
104  ///
105  /// When the ABI version number does not match the library major version number,
106  /// symbol names include the ABI version:
107  /// - @b openvdb::vX_YabiN::Vec3i
108  /// - @b openvdb::vX_YabiN::io::File
109  /// - @b openvdb::vX_YabiN::tree::Tree
110  ///
111  /// where X, Y and N are the major, minor and ABI version numbers, respectively.
112  #define OPENVDB_VERSION_NAME \
113  OPENVDB_PREPROC_CONCAT(v, \
114  OPENVDB_PREPROC_CONCAT(OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER, \
115  OPENVDB_PREPROC_CONCAT(_, \
116  OPENVDB_PREPROC_CONCAT(OPENVDB_LIBRARY_MINOR_VERSION_NUMBER, _sesi))))
117 #else
118  // This duplication of code is necessary to avoid issues with recursive macro expansion.
119  #define OPENVDB_VERSION_NAME \
120  OPENVDB_PREPROC_CONCAT(v, \
121  OPENVDB_PREPROC_CONCAT(OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER, \
122  OPENVDB_PREPROC_CONCAT(_, \
123  OPENVDB_PREPROC_CONCAT(OPENVDB_LIBRARY_MINOR_VERSION_NUMBER, \
124  OPENVDB_PREPROC_CONCAT(_sesi_, \
125  OPENVDB_PREPROC_CONCAT(abi, OPENVDB_ABI_VERSION_NUMBER))))))
126 #endif
127 
128 /// @brief Library version number string of the form "<major>.<minor>.<patch>"
129 /// @details This is a macro rather than a static constant because we typically
130 /// want the compile-time version number, not the runtime version number
131 /// (although the two are usually the same).
132 /// @hideinitializer
133 #define OPENVDB_LIBRARY_VERSION_STRING \
134  OPENVDB_PREPROC_STRINGIFY(OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER) "." \
135  OPENVDB_PREPROC_STRINGIFY(OPENVDB_LIBRARY_MINOR_VERSION_NUMBER) "." \
136  OPENVDB_PREPROC_STRINGIFY(OPENVDB_LIBRARY_PATCH_VERSION_NUMBER)
137 
138 /// @brief Library version number string of the form "<major>.<minor>.<patch>abi<abi>"
139 /// @details This is a macro rather than a static constant because we typically
140 /// want the compile-time version number, not the runtime version number
141 /// (although the two are usually the same).
142 /// @hideinitializer
143 #define OPENVDB_LIBRARY_ABI_VERSION_STRING \
144  OPENVDB_LIBRARY_VERSION_STRING "abi" OPENVDB_PREPROC_STRINGIFY(OPENVDB_ABI_VERSION_NUMBER)
145 
146 /// Library version number as a packed integer ("%02x%02x%04x", major, minor, patch)
147 #define OPENVDB_LIBRARY_VERSION_NUMBER \
148  ((OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER << 24) | \
149  ((OPENVDB_LIBRARY_MINOR_VERSION_NUMBER & 0xFF) << 16) | \
150  (OPENVDB_LIBRARY_PATCH_VERSION_NUMBER & 0xFFFF))
151 
152 
153 /// By default, the @b OPENVDB_REQUIRE_VERSION_NAME macro is undefined, and
154 /// symbols from the version namespace are promoted to the top-level namespace
155 /// so that, for example, @b openvdb::v5_0::io::File can be referred to
156 /// simply as @b openvdb::io::File.
157 ///
158 /// When @b OPENVDB_REQUIRE_VERSION_NAME is defined, symbols must be
159 /// fully namespace-qualified.
160 /// @hideinitializer
161 #ifdef OPENVDB_REQUIRE_VERSION_NAME
162 #define OPENVDB_USE_VERSION_NAMESPACE
163 #else
164 // The empty namespace clause below ensures that OPENVDB_VERSION_NAME
165 // is recognized as a namespace name.
166 #define OPENVDB_USE_VERSION_NAMESPACE \
167  namespace OPENVDB_VERSION_NAME {} \
168  using namespace OPENVDB_VERSION_NAME;
169 #endif
170 
171 
172 namespace openvdb {
174 namespace OPENVDB_VERSION_NAME {
175 
176 /// @brief The magic number is stored in the first four bytes of every VDB file.
177 /// @details This can be used to quickly test whether we have a valid file or not.
178 const int32_t OPENVDB_MAGIC = 0x56444220;
179 
180 // Library major, minor and patch version numbers
181 const uint32_t
185 /// Library version number as a packed integer ("%02x%02x%04x", major, minor, patch)
187 // ABI version number
189 
190 /// @brief The current version number of the VDB file format
191 /// @details This can be used to enable various backwards compatibility switches
192 /// or to reject files that cannot be read.
193 const uint32_t OPENVDB_FILE_VERSION = 224;
194 
195 /// Notable file format version numbers
196 enum {
211 };
212 
213 
214 /// Return a library version number string of the form "<major>.<minor>.<patch>".
215 inline constexpr const char* getLibraryVersionString() { return OPENVDB_LIBRARY_VERSION_STRING; }
216 /// Return a library version number string of the form "<major>.<minor>.<patch>abi<abi>".
217 inline constexpr const char* getLibraryAbiVersionString() {
219 }
220 
221 
222 struct VersionId {
223  uint32_t first, second;
224  VersionId(): first(0), second(0) {}
225  VersionId(uint32_t major, uint32_t minor): first(major), second(minor) {}
226 };
227 
228 } // namespace OPENVDB_VERSION_NAME
229 } // namespace openvdb
230 
231 #endif // OPENVDB_VERSION_HAS_BEEN_INCLUDED
#define OPENVDB_LIBRARY_MINOR_VERSION_NUMBER
Definition: version.h:69
constexpr const char * getLibraryAbiVersionString()
Return a library version number string of the form "<major>.<minor>.<patch>abi<abi>".
Definition: version.h:217
const int32_t OPENVDB_MAGIC
The magic number is stored in the first four bytes of every VDB file.
Definition: version.h:178
#define PRAGMA(x)
Definition: Platform.h:11
const uint32_t OPENVDB_LIBRARY_PATCH_VERSION
Definition: version.h:184
#define OPENVDB_LIBRARY_PATCH_VERSION_NUMBER
Definition: version.h:70
#define OPENVDB_LIBRARY_VERSION_STRING
Library version number string of the form "<major>.<minor>.<patch>".
Definition: version.h:133
const GLint * first
Definition: glew.h:1528
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:166
#define OPENVDB_ABI_VERSION_NUMBER
Definition: version.h:79
#define OPENVDB_LIBRARY_VERSION_NUMBER
Library version number as a packed integer ("%02x%02x%04x", major, minor, patch)
Definition: version.h:147
const uint32_t OPENVDB_LIBRARY_VERSION
Library version number as a packed integer ("%02x%02x%04x", major, minor, patch)
Definition: version.h:186
GLsizei GLenum GLuint GLuint GLsizei GLchar * message
Definition: glew.h:2581
VersionId(uint32_t major, uint32_t minor)
Definition: version.h:225
const uint32_t OPENVDB_LIBRARY_MAJOR_VERSION
Definition: version.h:182
#define OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER
Definition: version.h:68
#define OPENVDB_LIBRARY_ABI_VERSION_STRING
Library version number string of the form "<major>.<minor>.<patch>abi<abi>".
Definition: version.h:143
const uint32_t OPENVDB_LIBRARY_MINOR_VERSION
Definition: version.h:183
const uint32_t OPENVDB_ABI_VERSION
Definition: version.h:188
constexpr const char * getLibraryVersionString()
Return a library version number string of the form "<major>.<minor>.<patch>".
Definition: version.h:215
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:112
const uint32_t OPENVDB_FILE_VERSION
The current version number of the VDB file format.
Definition: version.h:193