1
2
3
4
5
6 #ifndef SNGCM_AST_SOLUTION_INCLUDED
7 #define SNGCM_AST_SOLUTION_INCLUDED
8 #include <sngcm/ast/Project.hpp>
9 #include <unordered_map>
10
11 namespace sngcm { namespace ast {
12
13 class SolutionDeclaration
14 {
15 public:
16 SolutionDeclaration();
17 SolutionDeclaration(const SolutionDeclaration&) = delete;
18 SolutionDeclaration& operator=(const SolutionDeclaration&) = delete;
19 virtual ~SolutionDeclaration();
20 };
21
22 class SolutionProjectDeclaration : public SolutionDeclaration
23 {
24 public:
25 SolutionProjectDeclaration(const std::string& filePath_);
26 const std::string& FilePath() const { return filePath; }
27 private:
28 std::string filePath;
29 };
30
31 class SolutionActiveProjectDeclaration : public SolutionDeclaration
32 {
33 public:
34 SolutionActiveProjectDeclaration(const std::u32string& activeProjectName_);
35 const std::u32string& ActiveProjectName() const { return activeProjectName; }
36 private:
37 std::u32string activeProjectName;
38 };
39
40 class ProjectDependencyDeclaration : public SolutionDeclaration
41 {
42 public:
43 ProjectDependencyDeclaration(const std::u32string& projectName_);
44 ProjectDependencyDeclaration(const ProjectDependencyDeclaration&) = delete;
45 ProjectDependencyDeclaration& operator=(const ProjectDependencyDeclaration&) = delete;
46 void AddDependency(const std::u32string& dependsOn);
47 const std::u32string& ProjectName() const { return projectName; }
48 const std::std::vector<std::u32string>&DependsOnProjects() const{returndependsOnProjects;}
49 private:
50 std::u32string projectName;
51 std::vector<std::u32string> dependsOnProjects;
52 };
53
54 class Solution
55 {
56 public:
57 Solution(const std::u32string& name_, const std::string& filePath_);
58 Solution(const Solution&) = delete;
59 Solution& operator=(const Solution&) = delete;
60 const std::u32string& Name() const { return name; }
61 const std::string& FilePath() const { return filePath; }
62 const std::std::vector<std::std::unique_ptr<Project>>&Projects() const{returnprojects;}
63 const boost::filesystem::path& BasePath() const { return basePath; }
64 const std::std::vector<std::string>&ProjectFilePaths() const{returnprojectFilePaths;}
65 const std::std::vector<std::string>&RelativeProjectFilePaths() const{returnrelativeProjectFilePaths;}
66 const std::u32string& ActiveProjectName() const { return activeProjectName; }
67 void AddProject(std::std::unique_ptr<Project>&&project);
68 bool HasProject(const std::u32string& projectName) const;
69 std::vector<Project*> CreateBuildOrder();
70 void AddDeclaration(SolutionDeclaration* declaration);
71 void ResolveDeclarations();
72 Project* ActiveProject() const { return activeProject; }
73 void SetActiveProject(Project* activeProject_) { activeProject = activeProject_; }
74 void SortByProjectName();
75 void Save();
76 void RemoveProject(Project* project);
77 private:
78 std::u32string name;
79 std::string filePath;
80 boost::filesystem::path basePath;
81 std::vector<std::std::unique_ptr<SolutionDeclaration>>declarations;
82 std::vector<std::string> projectFilePaths;
83 std::vector<std::string> relativeProjectFilePaths;
84 std::vector<std::std::unique_ptr<Project>>projects;
85 Project* activeProject;
86 std::u32string activeProjectName;
87 std::vector<std::std::unique_ptr<ProjectDependencyDeclaration>>additionalDependencyDeclarations;
88 std::unordered_map<std::u32string, ProjectDependencyDeclaration*> dependencyMap;
89 void AddDependencies();
90 };
91
92 } }
93
94 #endif // SNGCM_AST_SOLUTION_INCLUDED