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 /* Compatibility settings. */
20 /* #undef VTK_LEGACY_REMOVE */
21 /* #undef VTK_LEGACY_SILENT */
22 
23 //----------------------------------------------------------------------------
24 // Setup legacy code policy.
25 
26 // Define VTK_LEGACY macro to mark legacy methods where they are
27 // declared in their class. Example usage:
28 //
29 // // @deprecated Replaced by MyOtherMethod() as of VTK 5.0.
30 // VTK_LEGACY(void MyMethod());
31 #if defined(VTK_LEGACY_REMOVE)
32 // Remove legacy methods completely. Put a bogus declaration in
33 // place to avoid stray semicolons because this is an error for some
34 // compilers. Using a class forward declaration allows any number
35 // of repeats in any context without generating unique names.
36 
37 #define VTK_LEGACY(method) VTK_LEGACY__0(method, __LINE__)
38 #define VTK_LEGACY__0(method, line) VTK_LEGACY__1(method, line)
39 #define VTK_LEGACY__1(method, line) class vtkLegacyMethodRemoved##line
40 
41 #elif defined(VTK_LEGACY_SILENT) || defined(VTK_WRAPPING_CXX)
42 // Provide legacy methods with no warnings.
43 #define VTK_LEGACY(method) method
44 #else
45 // Setup compile-time warnings for uses of deprecated methods if
46 // possible on this compiler.
47 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
48 #define VTK_LEGACY(method) method __attribute__((deprecated))
49 #elif defined(_MSC_VER)
50 #define VTK_LEGACY(method) __declspec(deprecated) method
51 #else
52 #define VTK_LEGACY(method) method
53 #endif
54 #endif
55 
56 // Macros to create runtime deprecation warning messages in function
57 // bodies. Example usage:
58 //
59 // #if !defined(VTK_LEGACY_REMOVE)
60 // void vtkMyClass::MyOldMethod()
61 // {
62 // VTK_LEGACY_BODY(vtkMyClass::MyOldMethod, "VTK 5.0");
63 // }
64 // #endif
65 //
66 // #if !defined(VTK_LEGACY_REMOVE)
67 // void vtkMyClass::MyMethod()
68 // {
69 // VTK_LEGACY_REPLACED_BODY(vtkMyClass::MyMethod, "VTK 5.0",
70 // vtkMyClass::MyOtherMethod);
71 // }
72 // #endif
73 #if defined(VTK_LEGACY_REMOVE) || defined(VTK_LEGACY_SILENT)
74 #define VTK_LEGACY_BODY(method, version)
75 #define VTK_LEGACY_REPLACED_BODY(method, version, replace)
76 #else
77 #define VTK_LEGACY_BODY(method, version) \
78  vtkGenericWarningMacro( \
79  #method " was deprecated for " version " and will be removed in a future version.")
80 #define VTK_LEGACY_REPLACED_BODY(method, version, replace) \
81  vtkGenericWarningMacro( \
82  #method " was deprecated for " version \
83  " and will be removed in a future version. Use " #replace " instead.")
84 #endif
85 
86 #endif