MCPcopy Create free account
hub / github.com/VCVRack/Rack / createModel

Function createModel

include/helpers.hpp:24–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22/** Returns a Model that constructs a Module and ModuleWidget subclass. */
23template <class TModule, class TModuleWidget>
24plugin::Model* createModel(std::string slug) {
25 struct TModel : plugin::Model {
26 engine::Module* createModule() override {
27 engine::Module* m = new TModule;
28 m->model = this;
29 return m;
30 }
31 app::ModuleWidget* createModuleWidget(engine::Module* m) override {
32 TModule* tm = NULL;
33 if (m) {
34 assert(m->model == this);
35 tm = dynamic_cast<TModule*>(m);
36 }
37 app::ModuleWidget* mw = new TModuleWidget(tm);
38 assert(mw->module == m);
39 mw->setModel(this);
40 return mw;
41 }
42 };
43
44 plugin::Model* o = new TModel;
45 o->slug = slug;
46 return o;
47}
48
49
50/** Creates a Widget subclass with its top-left at a position. */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected