/src/CMake/Source/cmStateSnapshot.h
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | |
4 | | #pragma once |
5 | | |
6 | | #include "cmConfigure.h" // IWYU pragma: keep |
7 | | |
8 | | #include <string> |
9 | | #include <vector> |
10 | | |
11 | | #include <cm/string_view> |
12 | | |
13 | | #include "cmDiagnostics.h" |
14 | | #include "cmPolicies.h" |
15 | | #include "cmStateTypes.h" |
16 | | #include "cmValue.h" |
17 | | |
18 | | class cmPackageState; |
19 | | class cmState; |
20 | | class cmStateDirectory; |
21 | | |
22 | | class cmStateSnapshot |
23 | | { |
24 | | public: |
25 | | cmStateSnapshot(cmState* state = nullptr); |
26 | | cmStateSnapshot(cmState* state, cmStateDetail::PositionType position); |
27 | | |
28 | | cmValue GetDefinition(std::string const& name) const; |
29 | | bool IsInitialized(std::string const& name) const; |
30 | | void SetDefinition(std::string const& name, cm::string_view value); |
31 | | void RemoveDefinition(std::string const& name); |
32 | | std::vector<std::string> ClosureKeys() const; |
33 | | bool RaiseScope(std::string const& var, char const* varDef); |
34 | | |
35 | | void SetListFile(std::string const& listfile); |
36 | | |
37 | | std::string const& GetExecutionListFile() const; |
38 | | |
39 | | std::vector<cmStateSnapshot> GetChildren(); |
40 | | |
41 | | bool IsValid() const; |
42 | | cmStateSnapshot GetBuildsystemDirectory() const; |
43 | | cmStateSnapshot GetBuildsystemDirectoryParent() const; |
44 | | cmStateSnapshot GetCallStackParent() const; |
45 | | cmStateSnapshot GetCallStackBottom() const; |
46 | | cmStateEnums::SnapshotType GetType() const; |
47 | | |
48 | | cmStateEnums::SnapshotUnwindType GetUnwindType() const; |
49 | | void SetUnwindType(cmStateEnums::SnapshotUnwindType type); |
50 | | |
51 | | cmStateEnums::SnapshotUnwindState GetUnwindState() const; |
52 | | void SetUnwindState(cmStateEnums::SnapshotUnwindState state); |
53 | | |
54 | | void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); |
55 | | cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id, |
56 | | bool parent_scope = false) const; |
57 | | void PushPolicy(cmPolicies::PolicyMap const& entry, bool weak); |
58 | | bool PopPolicy(); |
59 | | bool CanPopPolicyScope() const; |
60 | | |
61 | | void SetDiagnostic(cmDiagnosticCategory category, cmDiagnosticAction action, |
62 | | bool recursive); |
63 | | void PromoteDiagnostic(cmDiagnosticCategory category, |
64 | | cmDiagnosticAction action, bool recursive); |
65 | | void DemoteDiagnostic(cmDiagnosticCategory category, |
66 | | cmDiagnosticAction action, bool recursive); |
67 | | cmDiagnosticAction GetDiagnostic(cmDiagnosticCategory category, |
68 | | cmDiagnosticAction defaultAction) const; |
69 | | cmDiagnosticAction GetDiagnostic(cmDiagnosticCategory category) const |
70 | 0 | { |
71 | 0 | return this->GetDiagnostic( |
72 | 0 | category, cmDiagnostics::CategoryInfo[category].DefaultAction); |
73 | 0 | } |
74 | | void PushDiagnostic(cmDiagnostics::DiagnosticMap entry, bool weak); |
75 | | bool PopDiagnostic(); |
76 | | bool CanPopDiagnosticScope() const; |
77 | | |
78 | | cmState* GetState() const; |
79 | | |
80 | | cmStateDirectory GetDirectory() const; |
81 | | |
82 | | void SetProjectName(std::string const& name); |
83 | | std::string GetProjectName() const; |
84 | | bool CheckProjectName(std::string const& name) const; |
85 | | |
86 | | cmPackageState& GetPackageState(std::string const& packagePath); |
87 | | |
88 | | void InitializeFromParent_ForSubdirsCommand(); |
89 | | |
90 | | struct StrictWeakOrder |
91 | | { |
92 | | bool operator()(cmStateSnapshot const& lhs, |
93 | | cmStateSnapshot const& rhs) const; |
94 | | }; |
95 | | |
96 | | void SetDirectoryDefinitions(); |
97 | | void SetDefaultDefinitions(); |
98 | | |
99 | | private: |
100 | | friend bool operator==(cmStateSnapshot const& lhs, |
101 | | cmStateSnapshot const& rhs); |
102 | | friend bool operator!=(cmStateSnapshot const& lhs, |
103 | | cmStateSnapshot const& rhs); |
104 | | friend class cmState; |
105 | | friend class cmStateDirectory; |
106 | | friend struct StrictWeakOrder; |
107 | | |
108 | | void InitializeFromParent(); |
109 | | |
110 | | using AlterDiagnosticFunction = bool (*)(cmDiagnosticAction current, |
111 | | cmDiagnosticAction desired); |
112 | | void AlterDiagnostic(cmDiagnosticCategory category, |
113 | | cmDiagnosticAction action, |
114 | | AlterDiagnosticFunction function, bool recursive); |
115 | | |
116 | | cmState* State; |
117 | | cmStateDetail::PositionType Position; |
118 | | }; |
119 | | |
120 | | bool operator==(cmStateSnapshot const& lhs, cmStateSnapshot const& rhs); |
121 | | bool operator!=(cmStateSnapshot const& lhs, cmStateSnapshot const& rhs); |