Skip to content
Snippets Groups Projects
Commit ff0b24d5 authored by jcarpent's avatar jcarpent
Browse files

[Python] Add function to expose constant variables in the current Python scope

parent fd628c9d
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,7 @@ ENDFOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
SET(${PYWRAP}_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/${PROJECT_NAME})
SET(${PROJECT_NAME}_PYTHON_HEADERS
utils/constant.hpp
utils/eigen_container.hpp
utils/handler.hpp
utils/copyable.hpp
......
//
// Copyright (c) 2018 CNRS
//
// This file is part of Pinocchio
// Pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// Pinocchio is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// Pinocchio If not, see
// <http://www.gnu.org/licenses/>.
#ifndef __se3_python_utils_constant_hpp__
#define __se3_python_utils_constant_hpp__
#include <boost/python/scope.hpp>
namespace boost
{
namespace python
{
///
/// \brief Define a constant given its value and a name within the current Boost Python scope.
///
/// \tparam T Type of the constant.
///
/// \param[in] name Name of the constant.
/// \param[in] value Value of the constant.
///
template<typename T>
void def_constant(const char * name, const T & value)
{
namespace bp = boost::python;
bp::scope().attr(name) = value;
}
} // namespace python
} // namespace boost
#endif // ifndef __se3_python_utils_constant_hpp__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment