|
| 1 | +/* |
| 2 | + * Copyright 2016, Justin Carpentier, LAAS-CNRS |
| 3 | + * |
| 4 | + * This file is part of eigenpy. |
| 5 | + * eigenpy is free software: you can redistribute it and/or |
| 6 | + * modify it under the terms of the GNU Lesser General Public License |
| 7 | + * as published by the Free Software Foundation, either version 3 of |
| 8 | + * the License, or (at your option) any later version. |
| 9 | + * eigenpy is distributed in the hope that it will be |
| 10 | + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 11 | + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU Lesser General Public License for more details. You should |
| 13 | + * have received a copy of the GNU Lesser General Public License along |
| 14 | + * with eigenpy. If not, see <http://www.gnu.org/licenses/>. |
| 15 | + */ |
| 16 | + |
| 17 | +#ifndef __eigenpy_registration_hpp__ |
| 18 | +#define __eigenpy_registration_hpp__ |
| 19 | + |
| 20 | +#include <boost/python.hpp> |
| 21 | + |
| 22 | +namespace eigenpy |
| 23 | +{ |
| 24 | + /// |
| 25 | + /// \brief Check at runtime the registration of the type T inside the boost python registry. |
| 26 | + /// |
| 27 | + /// \tparam T The type to check the registration. |
| 28 | + /// |
| 29 | + /// \returns true if the type T is already registered. |
| 30 | + /// |
| 31 | + template<typename T> |
| 32 | + inline bool check_registration() |
| 33 | + { |
| 34 | + namespace bp = boost::python; |
| 35 | + |
| 36 | + const bp::type_info info = bp::type_id<T>(); |
| 37 | + const bp::converter::registration* reg = bp::converter::registry::query(info); |
| 38 | + if (reg == NULL) return false; |
| 39 | + else if ((*reg).m_to_python == NULL) return false; |
| 40 | + |
| 41 | + return true; |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +#endif // ifndef __eigenpy_registration_hpp__ |
0 commit comments