How to do multiple inheritance for Matlab C++ Mex file?
5 ビュー (過去 30 日間)
古いコメントを表示
Dear all,
I would like to generate multiple Mex-Files that all have a similar structure. They all look somethings like this:
class MexFunction : public matlab::mex::Function {
void operator()(ArgumentList inputs, ArgumentList outputs);
void doSomeThing();
};
The operator function is always the same, but they all differ in the doSomeThing function. My idea was now to declare a base class like this
class MexBaseFunction : public matlab::mex::Function {
void operator()(ArgumentList inputs, ArgumentList outputs);
virtual void doSomeThing() = 0;
};
where I define the common operator() function once and then only change doSomeThing
class MexFunction : public MexBaseFunction {
void doSomeThing() override;
};
This doesn't work, because in order to define the base class, I have to include mexAdapter.hpp where a lot of stuff is going on that need a class called MexFunction.
My second attempt was to use multiple inheritance by defining a class
class MexBaseFunction {
void operator()(ArgumentList inputs, ArgumentList outputs);
virtual void doSomeThing() = 0;
};
that doesn't inherite from matlab::mex::Function. Then my mex-Functions would have the structure
class MexFunction : public matlab::mex::Function, public MexBaseFunction {
void doSomeThing() override;
};
This doesn't work as well, because I need to include various header files in my base class, because there I need ArgumentList, Struct, CellArray etc. In these header files various functions are defined. In my class that defines MexFunction I need to include the same files and, thus, get errors, because some functions are defined multiple times.
Now my question is:
Is there a proper approach to this problem - are forward-declarations a way to go?
Thanks in advance and best regards,
Torsten
3 件のコメント
Diego Leal Gonzalez
2020 年 11 月 19 日
I am having exactly the same problem. Have you found another solution to this?
回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!