Browse Source

Add Model pointer to Module.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
43dd52f9fe
2 changed files with 20 additions and 9 deletions
  1. +9
    -0
      include/engine/Module.hpp
  2. +11
    -9
      include/helpers.hpp

+ 9
- 0
include/engine/Module.hpp View File

@@ -1,6 +1,7 @@
#pragma once
#include "common.hpp"
#include "string.hpp"
#include "plugin/Model.hpp"
#include "engine/Param.hpp"
#include "engine/Port.hpp"
#include "engine/Light.hpp"
@@ -9,10 +10,18 @@


namespace rack {


namespace plugin {
struct Model;
}


namespace engine {


struct Module {
plugin::Model *model = NULL;
/** Automatically generated by the engine. */
int id = -1;
std::vector<Param> params;


+ 11
- 9
include/helpers.hpp View File

@@ -20,19 +20,21 @@ template <class TModule, class TModuleWidget, typename... Tags>
plugin::Model *createModel(std::string slug) {
struct TModel : plugin::Model {
engine::Module *createModule() override {
TModule *o = new TModule;
return o;
TModule *m = new TModule;
m->model = this;
return m;
}
app::ModuleWidget *createModuleWidget() override {
TModule *module = new TModule;
TModuleWidget *o = new TModuleWidget(module);
o->model = this;
return o;
TModule *m = new TModule;
m->model = this;
TModuleWidget *mw = new TModuleWidget(m);
mw->model = this;
return mw;
}
app::ModuleWidget *createModuleWidgetNull() override {
TModuleWidget *o = new TModuleWidget(NULL);
o->model = this;
return o;
TModuleWidget *mw = new TModuleWidget(NULL);
mw->model = this;
return mw;
}
};



Loading…
Cancel
Save