deprecation.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020-2021 INRIA
3 //
4 
5 #ifndef HPP_FCL_PYTHON_UTILS_DEPRECATION_H
6 #define HPP_FCL_PYTHON_UTILS_DEPRECATION_H
7 
8 #include <Python.h>
9 #include <boost/python.hpp>
10 #include <string>
11 
12 namespace hpp {
13 namespace fcl {
14 namespace python {
15 
16 template <class Policy = boost::python::default_call_policies>
17 struct deprecated_warning_policy : Policy {
18  deprecated_warning_policy(const std::string& warning_message = "")
19  : Policy(), m_warning_message(warning_message) {}
20 
21  template <class ArgumentPackage>
22  bool precall(ArgumentPackage const& args) const {
23  PyErr_WarnEx(PyExc_DeprecationWarning, m_warning_message.c_str(), 1);
24  return static_cast<const Policy*>(this)->precall(args);
25  }
26 
27  typedef typename Policy::result_converter result_converter;
28  typedef typename Policy::argument_package argument_package;
29 
30  protected:
31  const std::string m_warning_message;
32 };
33 
34 template <class Policy = boost::python::default_call_policies>
36  deprecated_member(const std::string& warning_message =
37  "This class member has been marked as deprecated and "
38  "will be removed in a future release.")
39  : deprecated_warning_policy<Policy>(warning_message) {}
40 };
41 
42 template <class Policy = boost::python::default_call_policies>
44  deprecated_function(const std::string& warning_message =
45  "This function has been marked as deprecated and "
46  "will be removed in a future release.")
47  : deprecated_warning_policy<Policy>(warning_message) {}
48 };
49 
50 } // namespace python
51 } // namespace fcl
52 } // namespace hpp
53 
54 #endif // ifndef HPP_FCL_PYTHON_UTILS_DEPRECATION_H
Policy::result_converter result_converter
Definition: deprecation.hh:27
Main namespace.
deprecated_warning_policy(const std::string &warning_message="")
Definition: deprecation.hh:18
Policy::argument_package argument_package
Definition: deprecation.hh:28
bool precall(ArgumentPackage const &args) const
Definition: deprecation.hh:22
deprecated_function(const std::string &warning_message="This function has been marked as deprecated and " "will be removed in a future release.")
Definition: deprecation.hh:44
deprecated_member(const std::string &warning_message="This class member has been marked as deprecated and " "will be removed in a future release.")
Definition: deprecation.hh:36


hpp-fcl
Author(s):
autogenerated on Fri Jun 2 2023 02:39:00