Skip to content

Commit 423ba9e

Browse files
committed
Add binding for BaseClass
It should be completed if ones want more feature than just class declaration
1 parent abd221b commit 423ba9e

3 files changed

Lines changed: 111 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2021 INRIA, USTL, UJF, CNRS, MGH *
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: contact@sofa-framework.org *
19+
******************************************************************************/
20+
21+
#include <SofaPython3/Sofa/Core/Binding_BaseClass.h>
22+
#include <SofaPython3/Sofa/Core/Binding_BaseClass_doc.h>
23+
#include <sofa/core/objectmodel/BaseClass.h>
24+
25+
namespace sofapython3
26+
{
27+
using namespace sofa::core::objectmodel;
28+
29+
/// Makes an alias for the pybind11 namespace to increase readability.
30+
namespace py { using namespace pybind11; }
31+
32+
auto getBaseClassBinding(py::module& m)
33+
{
34+
static py::class_<BaseClass, std::unique_ptr<BaseClass, py::nodelete>> base(m, "BaseClass", doc::baseclass::classdocstring);
35+
return base;
36+
}
37+
38+
void moduleForwardAddBaseClass(py::module& m)
39+
{
40+
getBaseClassBinding(m);
41+
}
42+
43+
void moduleAddBaseClass(py::module &m)
44+
{
45+
// adds here the BaseClass's binded function (if any).
46+
}
47+
48+
} /// namespace sofapython3
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2021 INRIA, USTL, UJF, CNRS, MGH *
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: contact@sofa-framework.org *
19+
******************************************************************************/
20+
21+
#pragma once
22+
23+
#include <pybind11/pybind11.h>
24+
25+
namespace sofapython3 {
26+
27+
/// Forward declaration in pybind11.
28+
/// more details in: https://github.com/sofa-framework/SofaPython3/pull/457
29+
void moduleForwardAddBaseClass(pybind11::module& m);
30+
void moduleAddBaseClass(pybind11::module& m);
31+
32+
} /// namespace sofapython3
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2021 INRIA, USTL, UJF, CNRS, MGH *
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: contact@sofa-framework.org *
19+
******************************************************************************/
20+
21+
#pragma once
22+
23+
namespace sofapython3::doc::baseclass {
24+
25+
static auto classdocstring =
26+
R"(Class hierarchy reflection base class
27+
This class provides information on the class and parent classes of components.
28+
It is created by using the SOFA_CLASS macro on each new class declaration.
29+
All classes deriving from Base should use the SOFA_CLASS macro within their declaration.)";
30+
31+
}

0 commit comments

Comments
 (0)