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 boost::filesystem::path& BasePath() const { return basePath; }
63 const std::std::vector<std::string>&ProjectFilePaths() const{returnprojectFilePaths;}
64 const std::std::vector<std::string>&RelativeProjectFilePaths() const{returnrelativeProjectFilePaths;}
65 const std::u32string& ActiveProjectName() const { return activeProjectName; }
66 void AddProject(std::std::unique_ptr<Project>&&project);
67 std::vector<Project*> CreateBuildOrder();
68 void AddDeclaration(SolutionDeclaration* declaration);
69 void ResolveDeclarations();
70 private:
71 std::u32string name;
72 std::string filePath;
73 boost::filesystem::path basePath;
74 std::vector<std::std::unique_ptr<SolutionDeclaration>>declarations;
75 std::vector<std::string> projectFilePaths;
76 std::vector<std::string> relativeProjectFilePaths;
77 std::vector<std::std::unique_ptr<Project>>projects;
78 std::u32string activeProjectName;
79 std::vector<std::std::unique_ptr<ProjectDependencyDeclaration>>additionalDependencyDeclarations;
80 std::unordered_map<std::u32string, ProjectDependencyDeclaration*> dependencyMap;
81 void AddDependencies();
82 };
83
84 } }
85
86 #endif // SNGCM_AST_SOLUTION_INCLUDED