GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/utils/deprecate.hpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 2 5 40.0%
Branches: 0 0 -%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2020, INRIA, University of Edinburgh
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #ifndef BINDINGS_PYTHON_CROCODDYL_UTILS_DEPRECATE_HPP_
10 #define BINDINGS_PYTHON_CROCODDYL_UTILS_DEPRECATE_HPP_
11
12 #include <Python.h>
13
14 #include <boost/python.hpp>
15 #include <string>
16
17 namespace crocoddyl {
18 namespace python {
19 template <class Policy = boost::python::default_call_policies>
20 struct deprecated : Policy {
21 1220 deprecated(const std::string& warning_message = "")
22 1220 : Policy(), m_warning_message(warning_message) {}
23
24 template <class ArgumentPackage>
25 bool precall(ArgumentPackage const& args) const {
26 PyErr_WarnEx(PyExc_UserWarning, m_warning_message.c_str(), 1);
27 return static_cast<const Policy*>(this)->precall(args);
28 }
29
30 typedef typename Policy::result_converter result_converter;
31 typedef typename Policy::argument_package argument_package;
32
33 protected:
34 const std::string m_warning_message;
35 };
36 } // namespace python
37 } // namespace crocoddyl
38
39 #endif // BINDINGS_PYTHON_CROCODDYL_UTILS_DEPRECATE_HPP_
40