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


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:57