#ifndef SOURCE_GROUP_SETTINGS_H #define SOURCE_GROUP_SETTINGS_H #include #include #include "settings/ProjectSettings.h" #include "settings/SourceGroupStatusType.h" #include "settings/SourceGroupType.h" class ProjectSettings; class SourceGroupSettings { public: static std::string s_keyPrefix; SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings); virtual ~SourceGroupSettings(); virtual void load(std::shared_ptr config); virtual void save(std::shared_ptr config); virtual bool equals(std::shared_ptr other) const; std::string getId() const; void setId(const std::string& id); std::string getName() const; void setName(const std::string& name); FilePath getProjectDirectoryPath() const; FilePath makePathExpandedAndAbsolute(const FilePath& path) const; std::vector makePathsExpandedAndAbsolute(const std::vector& paths) const; virtual std::vector getAvailableLanguageStandards() const = 0; virtual SourceGroupType getType() const; SourceGroupStatusType getStatus() const; void setStatus(SourceGroupStatusType status); std::string getStandard() const; void setStandard(const std::string& standard); std::vector getSourcePaths() const; std::vector getSourcePathsExpandedAndAbsolute() const; void setSourcePaths(const std::vector& sourcePaths); std::vector getExcludePaths() const; std::vector getExcludePathsExpandedAndAbsolute() const; void setExcludePaths(const std::vector& excludePaths); std::vector getSourceExtensions() const; void setSourceExtensions(const std::vector& sourceExtensions); protected: template static T getValue(const std::string& key, T defaultValue, std::shared_ptr config); template static std::vector getValues(const std::string& key, std::vector defaultValues, std::shared_ptr config); static std::vector getPathValues(const std::string& key, std::shared_ptr config); template static bool setValue(const std::string& key, T value, std::shared_ptr config); template static bool setValues(const std::string& key, std::vector values, std::shared_ptr config); static bool setPathValues(const std::string& key, const std::vector& paths, std::shared_ptr config); const ProjectSettings* m_projectSettings; private: virtual std::vector getDefaultSourceExtensions() const = 0; virtual std::string getDefaultStandard() const = 0; std::string m_id; std::string m_name; const SourceGroupType m_type; SourceGroupStatusType m_status; std::string m_standard; std::vector m_sourcePaths; std::vector m_excludePaths; std::vector m_sourceExtensions; }; template T SourceGroupSettings::getValue(const std::string& key, T defaultValue, std::shared_ptr config) { if (config) { T value; if (config->getValue(key, value)) { return value; } } return defaultValue; } template std::vector SourceGroupSettings::getValues(const std::string& key, std::vector defaultValues, std::shared_ptr config) { if (config) { std::vector values; if (config->getValues(key, values)) { return values; } } return defaultValues; } template bool SourceGroupSettings::setValue(const std::string& key, T value, std::shared_ptr config) { if (config) { config->setValue(key, value); return true; } return false; } template bool SourceGroupSettings::setValues(const std::string& key, std::vector values, std::shared_ptr config) { if (config) { config->setValues(key, values); return true; } return false; } #endif // SOURCE_GROUP_SETTINGS_H