Reference to parent regardless of type

Hi everyone, just after some advice.

I have a standalone application, that I’m also implementing in a vst format. I’m currently passing a reference to the PluginProcessor into my MainContentComponent (so that it can pass up a list of its parameters), but in the case of the standalone I’d like to just be able to pass in a null pointer.

However, this got me thinking… what’s the best way of passing a reference to a component’s parent, and being able to call functions in the parent, but regardless of the parent’s type? This way, an application main content component can be used modularly, in standalones, vst’s etc

Let me know if this is a silly question! Welcome your thoughts

I don’t know if I understand your problem, but you can always use dynamic_cast to get a pointer of a certain type. If it is not derived from the requested type, it returns a nullptr:

if (Slider* slider = dynamic_cast<Slider*> (parent)) {
    slider->setValue (0.7);

Thanks for the prompt reply.

Basically I’m trying to use the same source for both applications, and in the vst I need my main component to have a reference to the pluginProcessor, passed in when the processor creates it (n.b. a reference to main component is passed to PluginEditor to be displayed)

However in the standalone, I don’t need a reference because it is the top level component. My problem is that in the standalone the parent is the JuceApp, but in the vst the parent is an AudioProcessor derivative class.

In C i’m used to using a void *, and something like that is what I need here.

I will experiment with dynamic_cast, thanks!