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

Method AddModuleChain

Source/Push2Control.cpp:2165–2203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2163}
2164
2165void Push2Control::AddModuleChain(IDrawableModule* module, std::vector<IDrawableModule*>& modules, std::vector<IDrawableModule*>& output, int depth)
2166{
2167 if (depth > 100) //avoid infinite recursion if there's a patching loop
2168 return;
2169
2170 if (!VectorContains(module, output))
2171 {
2172 //look for parents
2173 for (int i = 0; i < modules.size(); ++i)
2174 {
2175 IClickable* target = nullptr;
2176 if (modules[i]->GetPatchCableSource() != nullptr)
2177 target = modules[i]->GetPatchCableSource()->GetTarget();
2178 if (target != nullptr &&
2179 target == dynamic_cast<IClickable*>(module))
2180 {
2181 AddModuleChain(modules[i], modules, output, depth + 1);
2182 }
2183 }
2184
2185 if (VectorContains(module, output)) //got added above
2186 return;
2187
2188 output.push_back(module);
2189
2190 //look for children
2191 for (int i = 0; i < modules.size(); ++i)
2192 {
2193 IClickable* target = nullptr;
2194 if (module->GetPatchCableSource() != nullptr)
2195 target = module->GetPatchCableSource()->GetTarget();
2196 if (target != nullptr &&
2197 target == dynamic_cast<IClickable*>(modules[i]))
2198 {
2199 AddModuleChain(modules[i], modules, output, depth + 1);
2200 }
2201 }
2202 }
2203}

Callers

nothing calls this directly

Calls 4

VectorContainsFunction · 0.85
sizeMethod · 0.80
GetPatchCableSourceMethod · 0.45
GetTargetMethod · 0.45

Tested by

no test coverage detected