|
| 1 | +/****************************************************************************** |
| 2 | +* SofaPython3 plugin * |
| 3 | +* (c) 2021 CNRS, University of Lille, INRIA * |
| 4 | +* * |
| 5 | +* This program is free software; you can redistribute it and/or modify it * |
| 6 | +* under the terms of the GNU Lesser General Public License as published by * |
| 7 | +* the Free Software Foundation; either version 2.1 of the License, or (at * |
| 8 | +* your option) any later version. * |
| 9 | +* * |
| 10 | +* This program is distributed in the hope that it will be useful, but WITHOUT * |
| 11 | +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * |
| 12 | +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * |
| 13 | +* for more details. * |
| 14 | +* * |
| 15 | +* You should have received a copy of the GNU Lesser General Public License * |
| 16 | +* along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 17 | +******************************************************************************* |
| 18 | +* Contact information: [email protected] * |
| 19 | +******************************************************************************/ |
| 20 | + |
| 21 | +#include <SofaPython3/Sofa/Core/Binding_ExecParams.h> |
| 22 | +#include <sofa/core/ExecParams.h> |
| 23 | + |
| 24 | +namespace py { using namespace pybind11; } |
| 25 | + |
| 26 | +namespace sofapython3 { |
| 27 | + |
| 28 | +void moduleAddExecParams(py::module& m) { |
| 29 | + using namespace sofa::core; |
| 30 | + py::class_<ExecParams> c (m, "ExecParams", "Class gathering parameters use by most components methods, and transmitted by all visitors"); |
| 31 | + c.def(py::init()); |
| 32 | + |
| 33 | + py::enum_<ExecParams::ExecMode> (c, "ExecMode") |
| 34 | + .value("EXEC_NONE", ExecParams::ExecMode::EXEC_NONE) |
| 35 | + .value("EXEC_DEFAULT", ExecParams::ExecMode::EXEC_DEFAULT) |
| 36 | + .value("EXEC_DEBUG", ExecParams::ExecMode::EXEC_DEBUG) |
| 37 | + .value("EXEC_GPU", ExecParams::ExecMode::EXEC_GPU) |
| 38 | + .value("EXEC_GRAPH", ExecParams::ExecMode::EXEC_GRAPH) |
| 39 | + .export_values() |
| 40 | + ; |
| 41 | + |
| 42 | + // Public properties/methods |
| 43 | + c.def("checkValidStorage", &ExecParams::checkValidStorage); |
| 44 | + c.def("execMode", &ExecParams::execMode, "Mode of execution requested"); |
| 45 | + c.def("threadID", &ExecParams::threadID, "Index of current thread (0 corresponding to the only thread in sequential mode, or first thread in parallel mode)"); |
| 46 | + c.def("nbThreads", &ExecParams::nbThreads, "Number of threads currently known to Sofa"); |
| 47 | + c.def("update", &ExecParams::update, "Make sure this instance is up-to-date relative to the current thread"); |
| 48 | + c.def("setExecMode", &ExecParams::setExecMode, "Request a specific mode of execution"); |
| 49 | + c.def("setThreadID", &ExecParams::setThreadID, "Specify the index of the current thread"); |
| 50 | + |
| 51 | +} |
| 52 | + |
| 53 | +} // namespace sofapython3 |
0 commit comments