From 316c1944b6c35d71162acc73f9e67da2e119c715 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 26 Feb 2026 21:29:48 +0100 Subject: [PATCH 1/4] sort files in CMakeLists.txt --- .../SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp | 0 .../SofaPython3/Sofa/Helper/Binding_MessageDispatcher.h | 0 bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt | 8 ++++---- 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp create mode 100644 bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.h 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..e69de29bb 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..e69de29bb diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt index 1283bc540..8500ca905 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt @@ -1,22 +1,22 @@ project(Bindings.Sofa.Helper) set(HEADER_FILES + ${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}/Binding_Version.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_MessageHandler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_Utils.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_Vector.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_Version.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) From fd46c8c21df58510611556ddc4449320f9ca7533 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 26 Feb 2026 21:46:41 +0100 Subject: [PATCH 2/4] Introduce bindings for MessageDispatcher --- .../Sofa/Helper/Binding_MessageDispatcher.cpp | 40 +++++++++++++++++++ .../Sofa/Helper/Binding_MessageDispatcher.h | 30 ++++++++++++++ .../SofaPython3/Sofa/Helper/CMakeLists.txt | 2 + 3 files changed, 72 insertions(+) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp index e69de29bb..9af91f48d 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp @@ -0,0 +1,40 @@ +/****************************************************************************** +* 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("clearHandlers", + [](){ + sofa::helper::logging::MessageDispatcher::clearHandlers(); + }, "Removes all 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 index e69de29bb..90f219bb4 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.h +++ 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 8500ca905..fc3a4272b 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt @@ -1,6 +1,7 @@ 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 @@ -10,6 +11,7 @@ set(HEADER_FILES ) set(SOURCE_FILES + ${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 From 97d119dbf49c4d9559eeae4b5e348d49ba3bb773 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 26 Feb 2026 21:54:03 +0100 Subject: [PATCH 3/4] Add `num_handlers` binding to MessageDispatcher and rename `clearHandlers` to `clear_handlers` --- .../SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp index 9af91f48d..cd8fb4d00 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp @@ -33,8 +33,13 @@ void sofapython3::moduleAddMessageDispatcher(pybind11::module &m) Configuration of the message dispatcher. )doc"; - messageDispatcherModule.def("clearHandlers", + 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."); } From 14ed08492f130b0fa1792248ca742bcf7c9b68e5 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Tue, 10 Mar 2026 14:10:54 +0100 Subject: [PATCH 4/4] change naming convention --- .../src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp index cd8fb4d00..4a9bec51d 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Helper/Binding_MessageDispatcher.cpp @@ -33,12 +33,12 @@ void sofapython3::moduleAddMessageDispatcher(pybind11::module &m) Configuration of the message dispatcher. )doc"; - messageDispatcherModule.def("clear_handlers", + messageDispatcherModule.def("clearHandlers", [](){ sofa::helper::logging::MessageDispatcher::clearHandlers(); }, "Removes all registered message handlers."); - messageDispatcherModule.def("num_handlers", + messageDispatcherModule.def("numHandlers", [](){ return sofa::helper::logging::MessageDispatcher::getHandlers().size(); }, "Returns the number of registered message handlers.");