src: Project Refactoring
* Added language specific Project and ProjectSettings * moved project specific code from Application to Project * made Application a singleton * added handleDialog method to Application which displays a dialog window and waits for user input * Added ScopedFunctor that executes a function when deleted
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#include "utility/ScopedFunctor.h"
|
||||
|
||||
ScopedFunctor::ScopedFunctor(std::function<void(void)> onDestroy)
|
||||
: m_onDestroy(onDestroy)
|
||||
{
|
||||
}
|
||||
|
||||
ScopedFunctor::~ScopedFunctor()
|
||||
{
|
||||
m_onDestroy();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef SCOPED_FUNCTOR_H
|
||||
#define SCOPED_FUNCTOR_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
class ScopedFunctor
|
||||
{
|
||||
public:
|
||||
ScopedFunctor(std::function<void(void)> onDestroy);
|
||||
~ScopedFunctor();
|
||||
|
||||
private:
|
||||
std::function<void(void)> m_onDestroy;
|
||||
};
|
||||
|
||||
#endif // SCOPED_FUNCTOR_H
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
virtual std::vector<std::string> getProjectItems() = 0;
|
||||
virtual std::vector<std::string> getCompileFlags() = 0;
|
||||
|
||||
virtual ProjectSettings getProjectSettings(const std::string& solutionFilePath) = 0;
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& solutionFilePath) = 0;
|
||||
|
||||
virtual std::string getIdeName() const = 0;
|
||||
virtual std::string getButtonText() const = 0;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "SolutionParserUtility.h"
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
SolutionParserCodeBlocks::SolutionParserCodeBlocks()
|
||||
@@ -174,14 +175,12 @@ std::vector<std::string> SolutionParserCodeBlocks::getCompileFlags()
|
||||
return compilerFlags;
|
||||
}
|
||||
|
||||
ProjectSettings SolutionParserCodeBlocks::getProjectSettings(const std::string& solutionFilePath)
|
||||
std::shared_ptr<ProjectSettings> SolutionParserCodeBlocks::getProjectSettings(const std::string& solutionFilePath)
|
||||
{
|
||||
openSolutionFile(solutionFilePath);
|
||||
|
||||
ProjectSettings settings;
|
||||
settings.setProjectName(getSolutionName());
|
||||
settings.setProjectFileLocation(getSolutionPath());
|
||||
settings.setVisualStudioSolutionPath(solutionFilePath);
|
||||
std::shared_ptr<CxxProjectSettings> settings = std::make_shared<CxxProjectSettings>(getSolutionName(), getSolutionPath());
|
||||
settings->setVisualStudioSolutionPath(solutionFilePath); // why is it called vs solution if it is used for codeblocks as well?
|
||||
|
||||
std::vector<std::string> sourceFiles = getProjectItems();
|
||||
std::vector<FilePath> sourcePaths;
|
||||
@@ -197,8 +196,8 @@ ProjectSettings SolutionParserCodeBlocks::getProjectSettings(const std::string&
|
||||
headerPaths.push_back(FilePath(p));
|
||||
}
|
||||
|
||||
settings.setSourcePaths(sourcePaths);
|
||||
settings.setHeaderSearchPaths(headerPaths);
|
||||
settings->setSourcePaths(sourcePaths);
|
||||
settings->setHeaderSearchPaths(headerPaths);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
virtual std::vector<std::string> getIncludePaths();
|
||||
virtual std::vector<std::string> getCompileFlags();
|
||||
|
||||
virtual ProjectSettings getProjectSettings(const std::string& solutionFilePath);
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& solutionFilePath);
|
||||
|
||||
virtual std::string getIdeName() const;
|
||||
virtual std::string getButtonText() const;
|
||||
|
||||
@@ -39,7 +39,7 @@ bool SolutionParserManager::canParseSolution(const std::string& ideId) const
|
||||
return false;
|
||||
}
|
||||
|
||||
ProjectSettings SolutionParserManager::getProjectSettings(const std::string& ideId, const std::string& solutionFilePath) const
|
||||
std::shared_ptr<ProjectSettings> SolutionParserManager::getProjectSettings(const std::string& ideId, const std::string& solutionFilePath) const
|
||||
{
|
||||
std::string lIdeId = ideId;
|
||||
boost::algorithm::to_lower(lIdeId);
|
||||
@@ -57,7 +57,7 @@ ProjectSettings SolutionParserManager::getProjectSettings(const std::string& ide
|
||||
|
||||
LOG_ERROR_STREAM(<< "Solution type is unknown");
|
||||
|
||||
return ProjectSettings();
|
||||
return std::shared_ptr<ProjectSettings>();
|
||||
}
|
||||
|
||||
unsigned int SolutionParserManager::getParserCount() const
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
|
||||
bool canParseSolution(const std::string& ideId) const;
|
||||
|
||||
ProjectSettings getProjectSettings(const std::string& ideId, const std::string& solutionFilePath) const;
|
||||
std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& ideId, const std::string& solutionFilePath) const;
|
||||
|
||||
unsigned int getParserCount() const;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "SolutionParserUtility.h"
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
SolutionParserVisualStudio::SolutionParserVisualStudio()
|
||||
@@ -202,7 +203,7 @@ std::vector<std::string> SolutionParserVisualStudio::getCompileFlags()
|
||||
return compilerFlags;
|
||||
}
|
||||
|
||||
ProjectSettings SolutionParserVisualStudio::getProjectSettings(const std::string& solutionFilePath)
|
||||
std::shared_ptr<ProjectSettings> SolutionParserVisualStudio::getProjectSettings(const std::string& solutionFilePath)
|
||||
{
|
||||
LOG_INFO_STREAM(<< "Starting to parse VS solution");
|
||||
|
||||
@@ -218,10 +219,8 @@ ProjectSettings SolutionParserVisualStudio::getProjectSettings(const std::string
|
||||
|
||||
LOG_INFO_STREAM(<< "Setting meta information");
|
||||
|
||||
ProjectSettings settings;
|
||||
settings.setProjectName(getSolutionName());
|
||||
settings.setProjectFileLocation(getSolutionPath());
|
||||
settings.setVisualStudioSolutionPath(solutionFilePath);
|
||||
std::shared_ptr<CxxProjectSettings> settings = std::make_shared<CxxProjectSettings>(getSolutionName(), getSolutionPath());
|
||||
settings->setVisualStudioSolutionPath(solutionFilePath);
|
||||
|
||||
LOG_INFO_STREAM(<< "Parsing project files");
|
||||
|
||||
@@ -247,10 +246,10 @@ ProjectSettings SolutionParserVisualStudio::getProjectSettings(const std::string
|
||||
LOG_INFO_STREAM(<< "Setting compile flags");
|
||||
|
||||
std::vector<std::string> compilerFlags = getCompileFlags();
|
||||
settings.setCompilerFlags(compilerFlags);
|
||||
settings->setCompilerFlags(compilerFlags);
|
||||
|
||||
settings.setSourcePaths(sourcePaths);
|
||||
settings.setHeaderSearchPaths(headerPaths);
|
||||
settings->setSourcePaths(sourcePaths);
|
||||
settings->setHeaderSearchPaths(headerPaths);
|
||||
|
||||
LOG_INFO_STREAM(<< "Done parsing VS solution");
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
virtual std::vector<std::string> getIncludePaths();
|
||||
virtual std::vector<std::string> getCompileFlags();
|
||||
|
||||
virtual ProjectSettings getProjectSettings(const std::string& solutionFilePath);
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& solutionFilePath);
|
||||
|
||||
virtual std::string getIdeName() const;
|
||||
virtual std::string getButtonText() const;
|
||||
|
||||
Reference in New Issue
Block a user