Files
Sourcetrail/src/lib/project/SourceGroupFactory.cpp
T
Andreas Stallinger 37ead804bf src: clazy compiler warnings
get rid of most clazy warnings (https://github.com/KDE/clazy)
* range loop use refs
* qcolor ctor with ints
* missing Q_OBJECT macro
* use .constfirst instead of .first

enabled ccache for unix systems for fasterr recompiling
* if ccache is in path we use it now
2017-08-10 09:45:55 +02:00

56 lines
1.4 KiB
C++

#include "project/SourceGroupFactory.h"
#include "project/SourceGroup.h"
#include "project/SourceGroupFactoryModule.h"
#include "settings/SourceGroupSettings.h"
std::shared_ptr<SourceGroupFactory> SourceGroupFactory::getInstance()
{
if (!s_instance)
{
s_instance = std::shared_ptr<SourceGroupFactory>(new SourceGroupFactory());
}
return s_instance;
}
void SourceGroupFactory::addModule(std::shared_ptr<SourceGroupFactoryModule> module)
{
m_modules.push_back(module);
}
std::vector<std::shared_ptr<SourceGroup>> SourceGroupFactory::createSourceGroups(std::vector<std::shared_ptr<SourceGroupSettings>> allSourceGroupSettings)
{
std::vector<std::shared_ptr<SourceGroup>> sourceGroups;
for (const std::shared_ptr<SourceGroupSettings>& sourceGroupSettings: allSourceGroupSettings)
{
std::shared_ptr<SourceGroup> sourceGroup = createSourceGroup(sourceGroupSettings);
if (sourceGroup)
{
sourceGroups.push_back(sourceGroup);
}
}
return sourceGroups;
}
std::shared_ptr<SourceGroup> SourceGroupFactory::createSourceGroup(std::shared_ptr<SourceGroupSettings> settings)
{
std::shared_ptr<SourceGroup> sourceGroup;
for (const std::shared_ptr<SourceGroupFactoryModule>& module: m_modules)
{
if (module->supports(settings->getType()))
{
sourceGroup = module->createSourceGroup(settings);
break;
}
}
return sourceGroup;
}
std::shared_ptr<SourceGroupFactory> SourceGroupFactory::s_instance;
SourceGroupFactory::SourceGroupFactory()
{
}