cmvr-es/dependency/arm/third_party/eigenpy/v3.0.0/include/eigenpy/registration.hpp

56 lines
1.4 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright 2014-2019, CNRS
* Copyright 2018-2019, INRIA
*/
#ifndef __eigenpy_registration_hpp__
#define __eigenpy_registration_hpp__
#include "eigenpy/fwd.hpp"
namespace eigenpy {
///
/// \brief Check at runtime the registration of the type T inside the boost
/// python registry.
///
/// \tparam T The type to check the registration.
///
/// \returns true if the type T is already registered.
///
template <typename T>
inline bool check_registration() {
const bp::type_info info = bp::type_id<T>();
const bp::converter::registration* reg = bp::converter::registry::query(info);
if (reg == NULL)
return false;
else if ((*reg).m_to_python == NULL)
return false;
return true;
}
///
/// \brief Symlink to the current scope the already registered class T.
///
///  \returns true if the type T is effectively symlinked.
///
/// \tparam T The type to symlink.
///
template <typename T>
inline bool register_symbolic_link_to_registered_type() {
if (eigenpy::check_registration<T>()) {
const bp::type_info info = bp::type_id<T>();
const bp::converter::registration* reg =
bp::converter::registry::query(info);
bp::handle<> class_obj(reg->get_class_object());
bp::scope().attr(reg->get_class_object()->tp_name) = bp::object(class_obj);
return true;
}
return false;
}
} // namespace eigenpy
#endif // ifndef __eigenpy_registration_hpp__