2525
2626#include " patchcore/module/factory/ModuleFactory.hpp"
2727#include " patchcore/module/Module.hpp"
28- #include " patchcore/module/Router.hpp"
28+ #include " patchcore/module/router/Router.hpp"
29+ #include " patchcore/module/router/GraphRouter.hpp"
2930#include " patchcore/module/output/ProxyModuleOutput.hpp"
3031#include " patchcore/module/input/ProxyModuleInput.hpp"
3132#include " patchcore/module/input/ProxyModuleUserInput.hpp"
3233
3334#include < string>
3435#include < vector>
3536
36- // PatchModule can be used to create subModule with multiple modules inside, connections between them and inputs/outputs
37- // outward facing inputs/outputs should be exposed manually by calling addInput/addOutput
38- // userInputs are available througth getModule("module_name")->getUserInput("input_name") or
39- // exposed by addUserInput
40- // the main usecase is to create a module dynamically
37+ /*
38+ * PatchModule can be used to create subModule with multiple modules inside, connections between them and inputs/outputs
39+ * outward facing inputs/outputs should be exposed manually by calling addInput/addOutput
40+ * userInputs are available througth getModule("module_name")->getUserInput("input_name") or
41+ * exposed by addUserInput
42+ * the main usecase is to create a module dynamically
43+ */
4144
4245class PatchModule : public Module {
4346public:
4447 PatchModule (ModuleFactory *factory, std::string name, int sampleRate);
45- PatchModule (const PatchModule &other);
48+ PatchModule (const PatchModule &other); // copy constructor for clone
49+ public:
4650 std::unique_ptr<Module> clone () const override ;
4751 virtual ~PatchModule () override ;
48-
52+ protected:
53+ PatchModule ();
4954 // Module interface
5055public:
5156 void onStartBuffer (int size) override ;
5257 void envelope () override ;
53- protected:
54- void envelopeModules ();
55-
5658 // PatchModule specific
5759 // creates a new input/output from existing ModuleInput/ModuleOutput
5860public:
61+ // TODO rename to createProxyInput/Output/UserInput
5962 virtual ProxyModuleInput* addInput (ModuleInput* input, const std::string& withName);
6063 virtual ProxyModuleOutput* addOutput (ModuleOutput* output, const std::string& withName);
6164 virtual UserInput* addUserInput (UserInput* input, const std::string& withName);
@@ -66,9 +69,6 @@ class PatchModule : public Module {
6669private:
6770 ModuleInput* findInputByClone (const ModuleInput &input) const ;
6871 ModuleOutput* findOutputByClone (const ModuleOutput &output) const ;
69- protected:
70- void addModuleToEnvelope (Module* module );
71- void clearModulesToEnvelope ();
7272
7373 // PatchModule specific
7474public:
@@ -85,34 +85,26 @@ class PatchModule : public Module {
8585
8686 // PatchModule Router specific
8787public:
88- virtual void addPatch (ModuleOutput* output, ModuleInput* input);
89- // TODO add method to remove a single patch
9088 virtual void resetPatch ();
89+ virtual void addPatch (ModuleOutput* output, ModuleInput* input);
90+ virtual void removePatch (ModuleOutput* output, ModuleInput* input);
9191private:
92- void clonePatches (const Router &router);
92+ void clonePatches (const AbstractRouter &router);
9393
9494 // Module copy and poly module creation
9595public:
9696 virtual std::unique_ptr<PolyProxyModule> createPolyModuleProxy (PolyModule* polyModule) const override ;
9797
98- private :
98+ protected :
9999 std::mutex _mutex;
100+ private:
100101 ModuleFactory* _factory;
101102
102103 std::mutex routerMutex;
103- Router _router = Router();
104+ // Router _router = Router(this);
105+ GraphRouter _router = GraphRouter(this );
104106
105107 std::vector<std::unique_ptr<Module>> _modules = std::vector<std::unique_ptr<Module>>();
106- // all FloatUserInputs of all modules in this PatchModule
107- std::vector<FloatUserInput *> _inputs = std::vector<FloatUserInput *>();
108-
109- // TODO make a better name for this
110- // this is used to envelope modules that are not connected to the router
111- std::vector<Module *> _modulesToAlwaysEnvelope = std::vector<Module *>();
112- std::vector<Module *> _modulesToEnvelope = std::vector<Module *>();
113-
114- std::vector<FloatUserInput *> _interpolatedInputsToAlwaysEnvelope = std::vector<FloatUserInput *>();
115- std::vector<FloatUserInput *> _interpolatedInputsToEnvelope = std::vector<FloatUserInput *>();
116108
117109 std::vector<ProxyModuleOutput *> _proxyModuleOutputs;
118110 std::vector<ProxyModuleInput *> _proxyModuleInputs;
0 commit comments