I keep getting told off for using a Singleton class.
So since this morning*, I've started using
SharedResourcePointer<SharedStuff> c;
For some of what was previously in singletons. Where SharedStuff is one of a few possible classes.
Hopefully I'm doing this right. The way I've gone for it is to have a member variable of my PluginProcessor class own SharedStuff. This means a version of it is called when the plugin is loaded.
Then in other bits of the plugin where the class is called I also have the same SharedResourcePointer<SharedStuff> declared. There is only ever one instance of the SharedStuff class, and when the plugins are all removed from the host it should be deleted.
For a class that is called infrequently I have a static method in SharedStuff which is something like:
void SharedStuff::do(x) {
SharedResourcePointer<SharedStuff> c;
c->actuallyDoStuff(x);
}
Which saves me some typing, I can just call SharedStuff:do(...) and not worry about having to declare the pointer each time.
More here:
http://www.juce.com/forum/topic/sharedresourcepointer
Does that help?
J.
*and as someone had just reported a crash involving a singleton when running auval that I couldn't repeat but looked weird..