Hey there,
For my Plugin, I’m using a class which holds ui-parameters, in order to be used in other processing classes.
After researching a bit I learned about dependency injection and I think I got the basic grip on it.
I have my class “Parameter”
#include IParameter.h
class Parameter : public IParameter
{
public:
Parameter();
~Parameter() override;
private:
std::unique_ptr<IParameter> makeParameter();
};
which inherits from it’s interface “IParameter”
class IDirectivityParameter
{
public:
virtual ~IDirectivityParameter() {};
virtual double doSomething() const = 0;
};
when injecting the dependency as a private member object of the PluginProcessor like this:
PluginProcessor.h:
#include IParameter.h
....
private:
std::shared_ptr<dearvrDir::IParameter> parameter_;
}
PluginProcessor.cpp:
#include "IParameter.h"
MyPluginAudioProcessor::MyPluginAudioProcessor(std::shared_ptr<IParameter> parameter)
{
this->parameter_ = parameter;
}
I run into problems with the generated “createPluginFilter” call at the end of the PluginProcessor.cpp because I can’t access the injected member object which needs to be returned in the constructor of the Audio Processor.
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new MyPluginAudioProcessor();
}
I know the problem occurs because this specific call is not an implementation of the Class and therefore can’t access the member variable.
Does anyone have a solution for this or can suggest another pattern to access objects across classes in JUCE while still maintaining testability?
Any help would be very much appreciated,
cheers,
Simon