/src/CMake/Source/cmMessenger.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 | | #pragma once |
4 | | |
5 | | #include "cmConfigure.h" // IWYU pragma: keep |
6 | | |
7 | | #include <iosfwd> |
8 | | #include <memory> |
9 | | #include <string> |
10 | | #include <vector> |
11 | | |
12 | | #include <cm/optional> |
13 | | |
14 | | #include "cmDiagnosticContext.h" |
15 | | #include "cmDiagnostics.h" |
16 | | #include "cmListFileCache.h" |
17 | | #include "cmMessageType.h" // IWYU pragma: keep |
18 | | |
19 | | class cmStateSnapshot; |
20 | | |
21 | | #ifdef CMake_ENABLE_DEBUGGER |
22 | | namespace cmDebugger { |
23 | | class cmDebuggerAdapter; |
24 | | } |
25 | | #endif |
26 | | |
27 | | class cmMessenger |
28 | | { |
29 | | public: |
30 | | void IssueMessage( |
31 | | MessageType type, std::string const& text, |
32 | | cmListFileBacktrace const& backtrace = cmListFileBacktrace()); |
33 | | |
34 | | void IssueDiagnostic(cmDiagnosticCategory category, std::string const& text, |
35 | | cmStateSnapshot const& fallbackContext, |
36 | | cmDiagnosticContext const& context = {}); |
37 | | |
38 | | void DisplayMessage(MessageType type, cmDiagnosticCategory category, |
39 | | std::string const& text, |
40 | | cmListFileBacktrace const& backtrace); |
41 | | |
42 | | void SetTopSource(cm::optional<std::string> topSource); |
43 | | |
44 | | // Print the top of a backtrace. |
45 | | void PrintBacktraceTitle(std::ostream& out, |
46 | | cmListFileBacktrace const& bt) const; |
47 | | #ifdef CMake_ENABLE_DEBUGGER |
48 | | void SetDebuggerAdapter( |
49 | | std::shared_ptr<cmDebugger::cmDebuggerAdapter> const& debuggerAdapter) |
50 | 0 | { |
51 | 0 | DebuggerAdapter = debuggerAdapter; |
52 | 0 | } |
53 | | #endif |
54 | | |
55 | | struct Message |
56 | | { |
57 | | MessageType Type; |
58 | | cmDiagnosticCategory Category; |
59 | | cmListFileBacktrace Backtrace; |
60 | | std::string Text; |
61 | | }; |
62 | | |
63 | | std::vector<Message> const& GetDisplayedMessages() const |
64 | 0 | { |
65 | 0 | return this->DisplayedMessages; |
66 | 0 | } |
67 | | |
68 | | private: |
69 | | cm::optional<std::string> TopSource; |
70 | | |
71 | | std::vector<Message> DisplayedMessages; |
72 | | |
73 | | #ifdef CMake_ENABLE_DEBUGGER |
74 | | std::shared_ptr<cmDebugger::cmDebuggerAdapter> DebuggerAdapter; |
75 | | #endif |
76 | | }; |