Thank you very much Daniel,
actually as I have a chain of components, so in my case just passing a pointer to the owner was enough.
Still I wonder what the concept is here. In my case (I am still working on a simple step sequncer to learn Juce) I have a component hierarchy (not really important what they do the names suggest it though):
- StepIndicator - is owned by a step
- Step - is owned by a pattern
- Pattern - is owned by a sequence
- Sequence - is owned by the editor.
So if I change a step, I want the processor to have the data. At the moment I use a timer in the editor class which only when the sequncer is not plaing updates the processor. Works fine, but no realtime changes.
In the actual Step class I react on a mousedown to toggle the step on and off. What I want to do is at that point change the processors step data, so the step is on or off in playback.
I could pass down the owner from level to level and work my way back upwards:
In Step call an function in owner Pattern which - when called- calls a function in the owning sequence, which then calls a function in the editor.
or i could something like
owner.owner.owner.owner.processor.updateStep()
and have each level have a pointer to its parent so I can access the processor directly.
OR
I could change the timer callback to not only during playback check for changes in the patterns.
Which one is the way to go ? I am looking for best practice here, maybe someone from Juce can drop an “offical” word on it.
The timer will work fine, but as I am using LinkedLists for the elements of the pattern even though it might not be more than 8 times 8 notes in the whole sequence I would like to avoid calling
LinkedListPointer.size() as it says that that might get slow and as it would have to happen in the timer callback. And even if I was using pre allocated arrays, the problem would still be passing the infro up from the bottom level element.
ok, enough talk, hope its understandable
Jens