MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / LoadModules

Method LoadModules

Source/ModuleContainer.cpp:501–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501void ModuleContainer::LoadModules(const ofxJSONElement& modules)
502{
503 PerformanceTimer timer;
504 {
505 TimerInstance t("load", timer);
506
507 //two-pass loading for dependencies
508
509 if (mOwner)
510 IClickable::SetLoadContext(mOwner);
511 {
512 TimerInstance t("create", timer);
513 for (int i = 0; i < modules.size(); ++i)
514 {
515 try
516 {
517 TimerInstance t("create " + modules[i]["name"].asString(), timer);
518 IDrawableModule* module = TheSynth->CreateModule(modules[i]);
519 if (module != nullptr)
520 {
521 //ofLog() << "create " << module->Name();
522 AddModule(module);
523 }
524 }
525 catch (LoadingJSONException& e)
526 {
527 TheSynth->LogEvent("Couldn't load json", kLogEventType_Error);
528 }
529 }
530 }
531
532 {
533 TimerInstance t("setup", timer);
534 for (int i = 0; i < modules.size(); ++i)
535 {
536 try
537 {
538 TimerInstance t("setup " + modules[i]["name"].asString(), timer);
539 IDrawableModule* module = FindModule(modules[i]["name"].asString(), true);
540 if (module != nullptr)
541 {
542 //ofLog() << "setup " << module->Name();
543 TheSynth->SetUpModule(module, modules[i]);
544 }
545 }
546 catch (LoadingJSONException& e)
547 {
548 TheSynth->LogEvent("Couldn't set up modules from json", kLogEventType_Error);
549 }
550 catch (UnknownModuleException& e)
551 {
552 TheSynth->LogEvent("Couldn't find module \"" + e.mSearchName + "\"", kLogEventType_Error);
553 }
554 }
555 }
556
557 {
558 TimerInstance t("init", timer);

Callers 4

LoadPrefabMethod · 0.80
LoadLayoutMethod · 0.80
LoadLayoutMethod · 0.80
LoadLayoutMethod · 0.80

Calls 7

sizeMethod · 0.80
CreateModuleMethod · 0.80
LogEventMethod · 0.80
SetUpModuleMethod · 0.80
NameMethod · 0.45
IsSingletonMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected