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


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:09