vtkParaViewDeprecation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
4 
5 #ifndef vtkParaViewDeprecation_h
6 #define vtkParaViewDeprecation_h
7 
8 #include "vtkPVVersionQuick.h"
9 
10 //----------------------------------------------------------------------------
11 // These macros may be used to deprecate APIs in ParaView. They act as
12 // attributes on method declarations and do not remove methods from a build
13 // based on build configuration.
14 //
15 // To use:
16 //
17 // In the declaration:
18 //
19 // ```cxx
20 // PARAVIEW_DEPRECATED_IN_X_Y_Z("reason for the deprecation")
21 // void oldApi();
22 // ```
23 //
24 // When selecting which version to deprecate an API in, use the newest macro
25 // available in this header.
26 //
27 // In the implementation:
28 //
29 // ```cxx
30 // // Hide PARAVIEW_DEPRECATED_IN_X_Y_Z() warnings for this class.
31 // #define PARAVIEW_DEPRECATION_LEVEL 0
32 //
33 // #include "vtkLegacy.h"
34 //
35 // void oldApi()
36 // {
37 // // One of:
38 // VTK_LEGACY_BODY(oldApi, "ParaView X.Y.Z");
39 // VTK_LEGACY_REPLACED_BODY(oldApi, "ParaView X.Y.Z", newApi);
40 //
41 // // Remaining implementation.
42 // }
43 // ```
44 //
45 // Please note the `PARAVIEW_DEPRECATED_IN_` version in the
46 // `PARAVIEW_DEPRECATION_LEVEL` comment so that it can be removed when that
47 // version is finally removed.
48 //----------------------------------------------------------------------------
49 
50 // The level at which warnings should be made.
51 #ifndef PARAVIEW_DEPRECATION_LEVEL
52 // ParaView defaults to deprecation of its current version.
53 #ifdef PARAVIEW_VERSION_NUMBER
54 #define PARAVIEW_DEPRECATION_LEVEL PARAVIEW_VERSION_NUMBER
55 #else
56 #define PARAVIEW_DEPRECATION_LEVEL PARAVIEW_VERSION_NUMBER_QUICK
57 #endif
58 #endif
59 
60 // API deprecated before 5.11.0 have already been removed.
61 #define PARAVIEW_MINIMUM_DEPRECATION_LEVEL PARAVIEW_VERSION_CHECK(5, 11, 0)
62 
63 // Force the deprecation level to be at least that of ParaView's build
64 // configuration.
65 #if PARAVIEW_DEPRECATION_LEVEL < PARAVIEW_MINIMUM_DEPRECATION_LEVEL
66 #undef PARAVIEW_DEPRECATION_LEVEL
67 #define PARAVIEW_DEPRECATION_LEVEL PARAVIEW_MINIMUM_DEPRECATION_LEVEL
68 #endif
69 
70 // Deprecation macro support for various compilers.
71 #if 0 && __cplusplus >= 201402L
72 // This is currently hard-disabled because compilers do not mix C++ attributes
73 // and `__attribute__` extensions together well.
74 #define PARAVIEW_DEPRECATION(reason) [[deprecated(reason)]]
75 #elif defined(VTK_WRAPPING_CXX)
76 // Ignore deprecation in wrapper code.
77 #define PARAVIEW_DEPRECATION(reason)
78 #elif defined(__VTK_WRAP__)
79 #define PARAVIEW_DEPRECATION(reason) [[vtk::deprecated(reason)]]
80 #else
81 #if defined(_WIN32) || defined(_WIN64)
82 #define PARAVIEW_DEPRECATION(reason) __declspec(deprecated(reason))
83 #elif defined(__clang__)
84 #if __has_extension(attribute_deprecated_with_message)
85 #define PARAVIEW_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
86 #else
87 #define PARAVIEW_DEPRECATION(reason) __attribute__((__deprecated__))
88 #endif
89 #elif defined(__GNUC__)
90 #if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
91 #define PARAVIEW_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
92 #else
93 #define PARAVIEW_DEPRECATION(reason) __attribute__((__deprecated__))
94 #endif
95 #else
96 #define PARAVIEW_DEPRECATION(reason)
97 #endif
98 #endif
99 
100 // APIs deprecated in the next release.
101 #if defined(__VTK_WRAP__)
102 #define PARAVIEW_DEPRECATED_IN_5_13_0(reason) [[vtk::deprecated(reason, "5.13.0")]]
103 #elif PARAVIEW_DEPRECATION_LEVEL >= PARAVIEW_VERSION_CHECK(5, 12, 20230101)
104 #define PARAVIEW_DEPRECATED_IN_5_13_0(reason) PARAVIEW_DEPRECATION(reason)
105 #else
106 #define PARAVIEW_DEPRECATED_IN_5_13_0(reason)
107 #endif
108 
109 // APIs deprecated in 5.12.0.
110 #if defined(__VTK_WRAP__)
111 #define PARAVIEW_DEPRECATED_IN_5_12_0(reason) [[vtk::deprecated(reason, "5.12.0")]]
112 #elif PARAVIEW_DEPRECATION_LEVEL >= PARAVIEW_VERSION_CHECK(5, 11, 20230101)
113 #define PARAVIEW_DEPRECATED_IN_5_12_0(reason) PARAVIEW_DEPRECATION(reason)
114 #else
115 #define PARAVIEW_DEPRECATED_IN_5_12_0(reason)
116 #endif
117 
118 // APIs deprecated in the older release always warn.
119 #if defined(__VTK_WRAP__)
120 #define PARAVIEW_DEPRECATED_IN_5_11_0(reason) [[vtk::deprecated(reason, "5.11.0")]]
121 #define PARAVIEW_DEPRECATED_IN_5_10_0(reason) [[vtk::deprecated(reason, "5.10.0")]]
122 #else
123 #define PARAVIEW_DEPRECATED_IN_5_11_0(reason) PARAVIEW_DEPRECATION(reason)
124 #define PARAVIEW_DEPRECATED_IN_5_10_0(reason) PARAVIEW_DEPRECATION(reason)
125 #endif
126 
127 #endif
128 
129 // VTK-HeaderTest-Exclude: vtkParaViewDeprecation.h