diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp new file mode 100644 index 000000000..cd8fb4d00 --- /dev/null +++ b/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp @@ -0,0 +1,45 @@ +/****************************************************************************** +* SofaPython3 plugin * +* (c) 2021 CNRS, University of Lille, INRIA * +* * +* This program 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 2.1 of the License, or (at * +* your option) any later version. * +* * +* This program 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 Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this program. If not, see . * +******************************************************************************* +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#include +#include + +namespace py { using namespace pybind11; } + +void sofapython3::moduleAddMessageDispatcher(pybind11::module &m) +{ + py::module messageDispatcherModule = m.def_submodule("MessageDispatcher"); + + messageDispatcherModule.doc() = R"doc( + MessageDispatcher + ----------------------- + + Configuration of the message dispatcher. + )doc"; + + messageDispatcherModule.def("clear_handlers", + [](){ + sofa::helper::logging::MessageDispatcher::clearHandlers(); + }, "Removes all registered message handlers."); + + messageDispatcherModule.def("num_handlers", + [](){ + return sofa::helper::logging::MessageDispatcher::getHandlers().size(); + }, "Returns the number of registered message handlers."); +} diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.h b/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.h new file mode 100644 index 000000000..90f219bb4 --- /dev/null +++ b/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.h @@ -0,0 +1,30 @@ +/****************************************************************************** +* SofaPython3 plugin * +* (c) 2021 CNRS, University of Lille, INRIA * +* * +* This program 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 2.1 of the License, or (at * +* your option) any later version. * +* * +* This program 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 Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this program. If not, see . * +******************************************************************************* +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#pragma once + +#include + +namespace sofapython3 +{ + +void moduleAddMessageDispatcher(pybind11::module &m); + +} /// namespace sofapython3 + diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt index b65f18044..f51d2a634 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt @@ -1,20 +1,22 @@ project(Bindings.Sofa.Helper) set(HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/Binding_MessageDispatcher.h + ${CMAKE_CURRENT_SOURCE_DIR}/Binding_MessageHandler.h ${CMAKE_CURRENT_SOURCE_DIR}/Binding_Utils.h ${CMAKE_CURRENT_SOURCE_DIR}/Binding_Vector.h - ${CMAKE_CURRENT_SOURCE_DIR}/System/Submodule_System.h - ${CMAKE_CURRENT_SOURCE_DIR}/Binding_MessageHandler.h ${CMAKE_CURRENT_SOURCE_DIR}/System/Binding_FileRepository.h + ${CMAKE_CURRENT_SOURCE_DIR}/System/Submodule_System.h ) set(SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/Submodule_Helper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Binding_MessageDispatcher.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_MessageHandler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_Utils.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_Vector.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/System/Submodule_System.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Submodule_Helper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/System/Binding_FileRepository.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/System/Submodule_System.cpp ) sofa_find_package(Sofa.Core REQUIRED)