forked from ethz-asl/kalibr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unique_register_ptr_to_python method to get rid of python runtime…
… warnings.
- Loading branch information
Showing
4 changed files
with
39 additions
and
9 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
Schweizer-Messer/sm_python/include/sm/python/unique_register_ptr_to_python.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef SM_PYTHON_UNIQUE_REGISTER_PTR_TO_PYTHON | ||
#define SM_PYTHON_UNIQUE_REGISTER_PTR_TO_PYTHON | ||
|
||
#include <boost/python/register_ptr_to_python.hpp> | ||
#include <boost/python/type_id.hpp> | ||
|
||
namespace sm { | ||
namespace python { | ||
|
||
// Calls register_ptr_to_python<D>() in case the class has not already been | ||
// registered. Related to | ||
// https://stackoverflow.com/questions/9888289/checking-whether-a-converter-has-already-been-registered# | ||
template <typename D> | ||
void unique_register_ptr_to_python() { | ||
boost::python::type_info info = boost::python::type_id<D>(); | ||
const boost::python::converter::registration* reg = boost::python::converter::registry::query(info); | ||
if (reg == NULL || reg->m_to_python == NULL) { | ||
boost::python::register_ptr_to_python<D>(); | ||
} | ||
} | ||
|
||
} // namespace python | ||
} // namespace sm | ||
|
||
#endif // SM_PYTHON_UNIQUE_REGISTER_PTR_TO_PYTHON | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters