GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: python/deprecation.hh Lines: 4 7 57.1 %
Date: 2024-02-09 12:57:42 Branches: 0 0 - %

Line Branch Exec Source
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
20
  deprecated_warning_policy(const std::string& warning_message = "")
19
20
      : 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>
35
struct deprecated_member : deprecated_warning_policy<Policy> {
36
10
  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
10
      : deprecated_warning_policy<Policy>(warning_message) {}
40
};
41
42
template <class Policy = boost::python::default_call_policies>
43
struct deprecated_function : deprecated_warning_policy<Policy> {
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