SWIG:从另一个模块返回对象的函数
SWIG: function returning an object from another module
我想知道是否可以使用SWIG混合来自两个模块的对象,例如,模块a的函数是否可以返回模块B的对象?
我的用例如下:
class_a.hpp:
class ClassA
{
public:
const OGRPolygon& get_geom() const;
void set_geom(OGRPolygon* geom);
protected:
OGRPolygon* _footprint;
};
class_a.cpp:
const OGRPolygon& ForCity::SPreC_cpp::ClassA::get_geom() const
{
return *(this->_footprint);
}
void ForCity::SPreC_cpp::ClassA::set_geom(OGRPolygon* geom)
{
this->_footprint = geom;
}
测试.i:
%module test
%include "class_A.hpp"
然后在Python中,我希望能够做一些类似的事情:
A = test.ClassA()
G = ogr.Geometry(ogr.wkbLinearRing)
# filling the geometry...
A.set_geom(G) # set the geometry of A
A.get_geom().GetArea() # use the geometry of A as a usual OGR geometry
有可能吗?请怎么做?
这可以通过在.i
文件中包含%import ClassB
指令来实现。此指令读取类型信息,但不生成绑定。
相关文章:
- 如何创建对象函数指针C++映射?
- 为什么我可以改变常量对象中的成员变量,这是返回常量对象函数的结果?
- 如何将对象函数的实例传递给另一个函数
- 调用模板函数的问题"No matching function for call"参数:迭代器、对象函数
- makefile对我的名称空间对象/函数/构造函数的不确定引用
- 将对象函数转换为函数指针
- 非对象函数/类函数C++
- 线程对象函数 C++
- C 将成员对象函数分配给类成员功能
- 使用基本指针调用派生对象函数
- 可以(通过编译器)使用多少个线程来初始化全局对象(函数main之前)
- C++类对象函数
- 对对象::函数的未定义引用
- 无法弄清楚将多个对象函数作为单独的线程调用的语法
- 在提升作用域出口中调用对象函数
- 使用基指针来使用派生对象函数
- 在for_each lambda 中调用对象函数
- C++:: 模板函数 - 从对象函数获取对象的地址
- Qt5 未解析的外部静态元对象函数
- 通过变量使用对象和对象函数