diff --git a/bin/data/test_ProjectSettings.xml b/bin/data/test_ProjectSettings.xml
index 457d962f..7f3fd6fd 100644
--- a/bin/data/test_ProjectSettings.xml
+++ b/bin/data/test_ProjectSettings.xml
@@ -1,5 +1,5 @@
- the/awesome/path/to/the/code
+ data
diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp
index a028a83f..a8457fdf 100644
--- a/src/lib/Application.cpp
+++ b/src/lib/Application.cpp
@@ -35,5 +35,6 @@ void Application::loadProject()
m_componentManager->setup();
m_project = Project::create(m_codeAccess, m_graphAccess);
+ m_project->loadProjectSettings("data/test_ProjectSettings.xml");
m_project->parseCode();
}
diff --git a/src/lib/ApplicationSettings.h b/src/lib/ApplicationSettings.h
index 77a3c7e4..e620436b 100644
--- a/src/lib/ApplicationSettings.h
+++ b/src/lib/ApplicationSettings.h
@@ -18,5 +18,4 @@ private:
static std::shared_ptr s_instance;
};
-
#endif // APPLICATION_SETTINGS_H
diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp
index 3f2bf7dd..fe03438a 100644
--- a/src/lib/Project.cpp
+++ b/src/lib/Project.cpp
@@ -1,9 +1,11 @@
#include "Project.h"
-#include
#include
+#include
#include "data/parser/cxx/CxxParser.h"
+#include "utility/FileSystem.h"
+#include "utility/logging/logging.h"
std::shared_ptr Project::create(
std::shared_ptr codeAccess,
@@ -27,16 +29,22 @@ Project::~Project()
{
}
-const ProjectSettings& Project::getProjectSettings() const
+bool Project::loadProjectSettings(const std::string& projectSettingsFile)
{
- return m_settings;
+ return ProjectSettings::getInstance()->load(projectSettingsFile);
}
void Project::parseCode()
{
- std::vector filePaths;
- filePaths.push_back("data/test_code.cpp");
+ if (ProjectSettings::getInstance()->getSourcePath() != "")
+ {
+ std::vector extension;
+ extension.push_back(".cpp");
+ extension.push_back(".h");
- CxxParser parser(m_storage);
- parser.parseFiles(filePaths);
+ CxxParser parser(m_storage);
+ parser.parseFiles(
+ FileSystem::getSourceFilesFromDirectory(ProjectSettings::getInstance()->getSourcePath(), extension)
+ );
+ }
}
diff --git a/src/lib/Project.h b/src/lib/Project.h
index 9fc56e22..646ebeed 100644
--- a/src/lib/Project.h
+++ b/src/lib/Project.h
@@ -18,8 +18,7 @@ public:
~Project();
- const ProjectSettings& getProjectSettings() const;
-
+ bool loadProjectSettings(const std::string& projectSettingsFile);
void parseCode();
private:
@@ -27,10 +26,7 @@ private:
Project(const Project&);
Project operator=(const Project&);
- ProjectSettings m_settings;
-
std::shared_ptr m_storage;
-
std::shared_ptr m_codeAccess;
std::shared_ptr m_graphAccess;
};
diff --git a/src/lib/ProjectSettings.cpp b/src/lib/ProjectSettings.cpp
index 84f01262..f0273377 100644
--- a/src/lib/ProjectSettings.cpp
+++ b/src/lib/ProjectSettings.cpp
@@ -1 +1,71 @@
#include "ProjectSettings.h"
+
+#include "utility/logging/logging.h"
+
+#include "utility/text/TextAccess.h"
+
+#include "utility/FileSystem.h"
+
+std::shared_ptr ProjectSettings::s_instance;
+
+std::shared_ptr ProjectSettings::getInstance()
+{
+ if (!s_instance)
+ {
+ s_instance = std::shared_ptr(new ProjectSettings());
+ }
+
+ return s_instance;
+}
+
+ProjectSettings::ProjectSettings()
+{
+}
+
+ProjectSettings::~ProjectSettings()
+{
+}
+
+bool ProjectSettings::load(const std::string& projectSettingsFilePath)
+{
+ m_config.reset();
+ if (FileSystem::exists(projectSettingsFilePath))
+ {
+ m_config = ConfigManager::createAndLoad(TextAccess::createFromFile(projectSettingsFilePath));
+ }
+ else
+ {
+ LOG_WARNING("File for Projectsettings not found");
+ return false;
+ }
+}
+
+void ProjectSettings::save(const std::string& projectSettingsFilePath)
+{
+ if(m_config)
+ {
+ m_config->save();
+ }
+}
+
+std::string ProjectSettings::getSourcePath() const
+{
+ if(m_config)
+ {
+ std::string sourcePath;
+ if(m_config->getValue("SourcePath", sourcePath))
+ {
+ return sourcePath;
+ }
+ }
+ return "";
+}
+
+void ProjectSettings::setSourcePath(const std::string& sourcePath)
+{
+ if(m_config)
+ {
+ m_config->setValue("SourcePath", sourcePath);
+ }
+
+}
diff --git a/src/lib/ProjectSettings.h b/src/lib/ProjectSettings.h
index f4ad1b9e..a1b9ad73 100644
--- a/src/lib/ProjectSettings.h
+++ b/src/lib/ProjectSettings.h
@@ -1,9 +1,31 @@
#ifndef PROJECT_SETTINGS_H
#define PROJECT_SETTINGS_H
+#include
+#include
+
+#include "utility/ConfigManager.h"
+
class ProjectSettings
{
+public:
+ static std::shared_ptr getInstance();
+ ~ProjectSettings();
+
+ bool load(const std::string& projectSettingsFilePath);
+ void save(const std::string& projectSettingsFilePath);
+
+std::string getSourcePath() const;
+
+ void setSourcePath(const std::string& sourcePath);
+
+private:
+ static std::shared_ptr s_instance;
+ ProjectSettings();
+ ProjectSettings(const ProjectSettings&);
+ void operator=(const ProjectSettings&);
+
+ std::shared_ptr m_config;
};
-
#endif // PROJECT_SETTINGS_H
diff --git a/src/lib/utility/ConfigManager.cpp b/src/lib/utility/ConfigManager.cpp
index 27e613b6..be72fc1a 100644
--- a/src/lib/utility/ConfigManager.cpp
+++ b/src/lib/utility/ConfigManager.cpp
@@ -1,5 +1,6 @@
#include "utility/ConfigManager.h"
+#include "logging/logging.h"
#include "utility/text/TextAccess.h"
std::shared_ptr ConfigManager::createAndLoad(const std::shared_ptr textAccess)
@@ -111,6 +112,7 @@ void ConfigManager::load()
void ConfigManager::save()
{
+ LOG_ERROR("function: configmanager::save not implemented");
// LOG ("Saving config to file: " + m_filePath)
}
diff --git a/src/lib/utility/ConfigManager.h b/src/lib/utility/ConfigManager.h
index b17d2c90..f6040f5e 100644
--- a/src/lib/utility/ConfigManager.h
+++ b/src/lib/utility/ConfigManager.h
@@ -1,7 +1,6 @@
#ifndef CONFIG_MANAGER_H
#define CONFIG_MANAGER_H
-
#include