vtkLegacy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLegacy.h.in
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 #ifndef vtkLegacy_h
17 #define vtkLegacy_h
18 
19 //----------------------------------------------------------------------------
20 // _ _ ___ _____ ___ _ _ ___ _____ ___
21 // | \| | / _ \ |_ _|| __| | \| | / _ \ |_ _|| __|
22 // | . || (_) | | | | _| | . || (_) | | | | _|
23 // |_|\_| \___/ |_| |___| |_|\_| \___/ |_| |___|
24 //
25 // The mechanisms present in this file should no longer be used. Instead, the
26 // mechanisms present in `vtkDeprecation.h` should be preferred. The benefits:
27 //
28 // - documentation of *when* the method was removed
29 // - support for ignoring warnings if an older VTK is also expected to work
30 // - no VTK build will magically take methods away from clients
31 //
32 // When these must be used (though it is no excuse; just pick a new name):
33 //
34 // - changing the signature of a method (e.g., the return type)
35 // - adding non-optional arguments in a way that doesn't support overloading
36 //----------------------------------------------------------------------------
37 
38 /* Compatibility settings. */
39 /* #undef VTK_LEGACY_REMOVE */
40 /* #undef VTK_LEGACY_SILENT */
41 
42 //----------------------------------------------------------------------------
43 // Setup legacy code policy.
44 
45 // Define VTK_LEGACY macro to mark legacy methods where they are
46 // declared in their class. Example usage:
47 //
48 // // @deprecated Replaced by MyOtherMethod() as of VTK 5.0.
49 // VTK_LEGACY(void MyMethod());
50 #if defined(VTK_LEGACY_REMOVE)
51 // Remove legacy methods completely. Put a bogus declaration in
52 // place to avoid stray semicolons because this is an error for some
53 // compilers. Using a class forward declaration allows any number
54 // of repeats in any context without generating unique names.
55 
56 #define VTK_LEGACY(method) VTK_LEGACY__0(method, __LINE__)
57 #define VTK_LEGACY__0(method, line) VTK_LEGACY__1(method, line)
58 #define VTK_LEGACY__1(method, line) class vtkLegacyMethodRemoved##line
59 
60 #elif defined(VTK_LEGACY_SILENT) || defined(VTK_WRAPPING_CXX)
61 // Provide legacy methods with no warnings.
62 #define VTK_LEGACY(method) method
63 #else
64 // Setup compile-time warnings for uses of deprecated methods if
65 // possible on this compiler.
66 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
67 #define VTK_LEGACY(method) method __attribute__((deprecated))
68 #elif defined(_MSC_VER)
69 #define VTK_LEGACY(method) __declspec(deprecated) method
70 #else
71 #define VTK_LEGACY(method) method
72 #endif
73 #endif
74 
75 // Macros to create runtime deprecation warning messages in function
76 // bodies. Example usage:
77 //
78 // #if !defined(VTK_LEGACY_REMOVE)
79 // void vtkMyClass::MyOldMethod()
80 // {
81 // VTK_LEGACY_BODY(vtkMyClass::MyOldMethod, "VTK 5.0");
82 // }
83 // #endif
84 //
85 // #if !defined(VTK_LEGACY_REMOVE)
86 // void vtkMyClass::MyMethod()
87 // {
88 // VTK_LEGACY_REPLACED_BODY(vtkMyClass::MyMethod, "VTK 5.0",
89 // vtkMyClass::MyOtherMethod);
90 // }
91 // #endif
92 #if defined(VTK_LEGACY_REMOVE) || defined(VTK_LEGACY_SILENT)
93 #define VTK_LEGACY_BODY(method, version)
94 #define VTK_LEGACY_REPLACED_BODY(method, version, replace)
95 #else
96 #define VTK_LEGACY_BODY(method, version) \
97  vtkGenericWarningMacro( \
98  #method " was deprecated for " version " and will be removed in a future version.")
99 #define VTK_LEGACY_REPLACED_BODY(method, version, replace) \
100  vtkGenericWarningMacro( \
101  #method " was deprecated for " version \
102  " and will be removed in a future version. Use " #replace " instead.")
103 #endif
104 
105 #endif