Singleton Pattern For Plugins


#1

Hi all,

I’m really loving developing with JUCE! It’s an incredibly well-planned framework. However, I’m stuck with a design dilemma that maybe someone else has already solved…

I’d like to use the singleton pattern so that each instance of my plugin gets a single instance of a particular class. Right now, it looks like my singleton class is shared among all instances of my plugin. I can certainly compose my singleton classes inside of my filter, but I wondered if there was an easier way.

For example, I’ve implemented a parameter manager that keeps track of all of the filter parameters. It is a singleton, which makes it easy for my GUI classes to register themselves as ChangeListeners. But, when I open another instance of my plugin, all of the parameter changes get copied to both instances.

Any ideas? Is there a good way to implement a filter-wide singleton pattern? Is this is a bad design decision?

Thanks! :slight_smile:

Matt Sonic


#2

Erm… what you’re talking about is a member variable, not a singleton!


#3

LOL. I’ll just reorganize my objects then. That answers my question.

Thanks again for JUCE, it’s the best!

Matt Sonic