@@ -25,8 +25,21 @@ along with sofaqtquick. If not, see <http://www.gnu.org/licenses/>.
25252626********************************************************************/
2727
28+
29+ #include < sofa/core/objectmodel/BaseLink.h>
30+ using sofa::core::objectmodel::BaseLink;
31+
32+ #include < sofa/core/objectmodel/BaseObject.h>
33+ using sofa::core::objectmodel::BaseObject;
34+
35+ #include < sofa/core/objectmodel/BaseNode.h>
36+ using sofa::core::objectmodel::BaseNode;
37+
38+ #include " Binding_Base.h"
2839#include " Binding_BaseLink.h"
2940#include " Binding_BaseLink_doc.h"
41+ #include < SofaPython3/DataHelper.h>
42+ #include < SofaPython3/PythonFactory.h>
3043
3144namespace sofapython3
3245{
@@ -40,9 +53,21 @@ void setHelp(BaseLink* self, const std::string value)
4053 self->setHelp (S);
4154}
4255
56+ py::object getLinkedBase (BaseLink& self, unsigned index = 0 )
57+ {
58+ if (self.getLinkedBase (index))
59+ return PythonFactory::toPython (self.getLinkedBase (index));
60+ return py::none ();
61+ }
62+
63+ py::object getOwnerBase (BaseLink& self)
64+ {
65+ return PythonFactory::toPython (self.getOwnerBase ());
66+ }
67+
4368void moduleAddBaseLink (py::module & m)
4469{
45- py::class_<BaseLink> link (m, " Link" , sofapython3::doc::baseLink::baseLinkClass);
70+ py::class_<BaseLink, std::unique_ptr<sofa::core::objectmodel::BaseLink, pybind11::nodelete> > link (m, " Link" , sofapython3::doc::baseLink::baseLinkClass);
4671 link.def (" getName" , &BaseLink::getName, sofapython3::doc::baseLink::getName);
4772 link.def (" setName" , &BaseLink::setName, sofapython3::doc::baseLink::setName);
4873 link.def (" isMultiLink" , &BaseLink::isMultiLink, sofapython3::doc::baseLink::isMultiLink);
@@ -58,12 +83,12 @@ void moduleAddBaseLink(py::module& m)
5883 link.def (" setHelp" , setHelp, sofapython3::doc::baseLink::setHelp);
5984
6085 link.def (" getOwnerData" , &BaseLink::getOwnerData, sofapython3::doc::baseLink::getOwnerData);
61- link.def (" getOwnerBase" , &BaseLink:: getOwnerBase, sofapython3::doc::baseLink::getOwnerBase);
86+ link.def (" getOwnerBase" , getOwnerBase, sofapython3::doc::baseLink::getOwnerBase);
6287
6388 link.def (" getLinkedData" , &BaseLink::getLinkedData, sofapython3::doc::baseLink::getLinkedData);
64- link.def (" getLinkedBase" , &BaseLink:: getLinkedBase, sofapython3::doc::baseLink::getLinkedBase);
89+ link.def (" getLinkedBase" , getLinkedBase, " index " _a = 0 , sofapython3::doc::baseLink::getLinkedBase);
6590
66- link.def (" getLinkedPath" , &BaseLink::getLinkedPath, sofapython3::doc::baseLink::getLinkedPath);
91+ link.def (" getLinkedPath" , &BaseLink::getLinkedPath, " index " _a = 0 , sofapython3::doc::baseLink::getLinkedPath);
6792 link.def (" read" , &BaseLink::read, sofapython3::doc::baseLink::read);
6893
6994}
0 commit comments