I have a DLP kit which I need to control via MATLAB using a C++ API.
Say, I have functions/methods using C/C++ for {load_data, load_settings,display_data}
Alternative design, cleaner for the use case here, is to define a singleton class with init, fcnA, fcnB, fcnC, ... methods ... etc, with corresponding lightweight wrappers.. and then invoke the wrappers from the MEX.
e.g.
class A {
public:
A getInstance() {
if ( !instance )
instance = new A(...);
return instance;
}
void fcnA(T1 a1, T2 a2) {
//yada yada
}
private:
static A* instance;
};
A::instance = NULL;
//begin wrappers for marshalling to class method
A* getInstance( ) {
return A::getInstance();
}
void fcnA(T1 a1, T2 a2) {
getInstance()->fcnA(a1,a2);
}
//ad nauseum