30 lines
776 B
C++
30 lines
776 B
C++
|
|
#include "PluginRegister.h"
|
|||
|
|
#include "plugin_support/PluginModule.h"
|
|||
|
|
#include <QDebug>
|
|||
|
|
|
|||
|
|
|
|||
|
|
PluginRegister* PluginRegister::s_pluginRegister;
|
|||
|
|
|
|||
|
|
PluginRegister* PluginRegister::getInstance()
|
|||
|
|
{
|
|||
|
|
static std::mutex m;
|
|||
|
|
// check if set without locking first (in most cases it will be set and it will never be unset) so locking the mutex everytime
|
|||
|
|
// is a waist of time.
|
|||
|
|
if (!s_pluginRegister) {
|
|||
|
|
// not set then lock
|
|||
|
|
std::lock_guard<std::mutex> guard(m);
|
|||
|
|
// recheck in case someone else just set it
|
|||
|
|
if (!s_pluginRegister) {
|
|||
|
|
s_pluginRegister = new PluginRegister;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return s_pluginRegister;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
PluginRegister::PluginRegister() = default;
|
|||
|
|
|
|||
|
|
void PluginRegister::registerModule(PluginModuleSPtr module)
|
|||
|
|
{
|
|||
|
|
qDebug() << "Register called for " << module->identifier();
|
|||
|
|
}
|