Method for counting instances of a plug-in

Hi,

Is there a safe way for counting the number of intances of a certain plug-in running inside a host?

a static int? Should be pretty safe.

yeah i always do something like:

MyPlugin.h

class MyPlugin { //... static int numInstances; //...

MyPlugin.cpp

[code]int MyPlugin::numInstances = 0;

MyPlugin::~MyPlugin ()
{
if (–MyPlugin::numInstances == 0)
{
// shared deinitialization when all instances off
}
}

AudioFilterBase* createPluginFilter()
{
if (MyPlugin::numInstances++ == 0)
{
// shared initialization among instances
}

return new MyPlugin();

}
[/code]

and it works like a charm !

thanks, thats a good idea that I didn’t think of.