IMP  2.1.0
The Integrative Modeling Platform
base/deprecation_macros.h
Go to the documentation of this file.
1 /**
2  * \file IMP/base/deprecation_macros.h
3  * \brief Control display of deprecation information.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPBASE_DEPRECATION_MACROS_H
10 #define IMPBASE_DEPRECATION_MACROS_H
11 
12 #include <IMP/base/base_config.h>
13 #include "deprecation.h"
14 
15 /** Used to implement deprecation support. See the
16  [IMP deprecation policy](https://github.com/salilab/imp/wiki/Deprecation).*/
17 #define IMP_DEPRECATED_MACRO(version, help_message) \
18  IMP_PRAGMA(message("This macro is deprecated as of IMP " #version \
19  ": " help_message))
20 
21 /** Used to implement deprecation support. See the
22  [IMP deprecation policy](https://github.com/salilab/imp/wiki/Deprecation).*/
23 #define IMP_DEPRECATED_OBJECT_RUNTIME_WARNING(version, help_message) \
24  { \
25  std::ostringstream oss; \
26  oss << "Object " << get_module_name() << "::" << get_type_name() \
27  << " is deprecated. " << help_message << std::endl; \
28  IMP::base::handle_use_deprecated(oss.str()); \
29  }
30 
31 /** Used to implement deprecation support. See the
32  [IMP deprecation policy](https://github.com/salilab/imp/wiki/Deprecation).*/
33 #define IMP_DEPRECATED_VALUE_RUNTIME_WARNING(version, help_message) \
34  { \
35  std::ostringstream oss; \
36  oss << "Class " << get_module_name() << "::" << IMP_CURRENT_FUNCTION \
37  << " is deprecated. " << help_message << std::endl; \
38  IMP::base::handle_use_deprecated(oss.str()); \
39  }
40 
41 /** Used to implement deprecation support. See the
42  [IMP deprecation policy](https://github.com/salilab/imp/wiki/Deprecation).*/
43 #define IMP_DEPRECATED_FUNCTION_RUNTIME_WARNING(version, help_message) \
44  { \
45  std::ostringstream oss; \
46  oss << "Function " << IMP_CURRENT_PRETTY_FUNCTION << " is deprecated. " \
47  << help_message << std::endl; \
48  IMP::base::handle_use_deprecated(oss.str()); \
49  }
50 
51 /** Used to implement deprecation support. See the
52  [IMP deprecation policy](https://github.com/salilab/imp/wiki/Deprecation).*/
53 #define IMP_DEPRECATED_METHOD_RUNTIME_WARNING(version, help_message) \
54  { \
55  std::ostringstream oss; \
56  oss << "Method " << IMP_CURRENT_PRETTY_FUNCTION << " is deprecated. " \
57  << "WARNING: " << help_message << std::endl; \
58  IMP::base::handle_use_deprecated(oss.str()); \
59  }
60 
61 /** \deprecated_at{2.1} Deprecated as of IMP 2.1. Use
62  IMPMODULE_DEPRECATED_CLASS_DEF().
63  */
64 #define IMP_DEPRECATED_OBJECT(replacement_classname) \
65  IMP_DEPRECATED_MACRO( \
66  2.1, \
67  "Use IMP@MODULE@_DEPRECATED_OBJECT_DECL()") \
68  if (::IMP::base::internal:: \
69  get_print_deprecation_message( \
70  get_name())) { \
71  IMP_WARN(get_name() << " is deprecated " \
72  << "and should not be used.\nUse " \
73  << #replacement_classname << " instead." \
74  << std::endl); \
75  ::IMP::base::internal::set_printed_deprecation_message(get_name(), true); \
76  }
77 /** \deprecated_at{2.1} As of IMP 2.1. Use IMPMODULE_DEPRECATED_CLASS_DEF()
78  instead
79  */
80 #define IMP_DEPRECATED_CLASS(classname, replacement_classname) \
81  IMP_DEPRECATED_MACRO( \
82  2.1, \
83  "Use IMP@MODULE@_DEPRECATED_VALUE_DEF " \
84  "instead") if (::IMP::base::internal:: \
85  get_print_deprecation_message(#classname)) { \
86  IMP_WARN(#classname << " is deprecated " \
87  << "and should not be used.\nUse " \
88  << #replacement_classname << " instead." \
89  << std::endl); \
90  ::IMP::base::internal::set_printed_deprecation_message(#classname, true); \
91  }
92 /** \deprecated_at{2.1} As of IMP 2.1. Use IMPMODULE_DEPRECATED_FUNCTION_DEF()
93  instead
94  */
95 #define IMP_DEPRECATED_FUNCTION(replacement) \
96  IMP_DEPRECATED_MACRO( \
97  2.1, "Use IMP@MODULE@_DEPRECATED_FUNCTION_DECL/DEF instead"); \
98  if (::IMP::base::internal::get_print_deprecation_message( \
99  IMP_CURRENT_FUNCTION)) { \
100  IMP_WARN(IMP_CURRENT_FUNCTION << " is deprecated " \
101  << "and should not be used.\nUse " \
102  << #replacement << " instead." \
103  << std::endl); \
104  ::IMP::base::internal::set_printed_deprecation_message( \
105  IMP_CURRENT_FUNCTION, true); \
106  }
107 
108 #if !defined(IMP_SWIG_WRAPPER) && (defined(__GNUC__) || defined(__clang__))
109 #define IMP_DEPRECATED_WARN \
110  IMP_DEPRECATED_MACRO(2.1, "Use IMPMODULE_DEPRECATED_FUNCTION_DEF") \
111  __attribute__((deprecated))
112 #else
113 /** Produce compiler warnings when the function is called.
114 
115  \deprecated_at{2.1} As of IMP 2.1. Use IMPMODULE_DEPRECATED_FUNCTION_DEF()
116  instead.
117 */
118 #define IMP_DEPRECATED_WARN
119 #endif
120 
121 #define IMP_DEPRECATED_FUNCTION_DEF(version, message)
122 
123 #endif /* IMPBASE_DEPRECATION_MACROS_H */
Control display of deprecation information.