1 //===-- MIDriverBase.cpp ----------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // Third party headers:
11 #include "lldb/API/SBBroadcaster.h"
12 #include "lldb/API/SBEvent.h"
13
14 // In-house headers:
15 #include "MIDriverBase.h"
16
17 //++
18 //------------------------------------------------------------------------------------
19 // Details: CMIDriverBase constructor.
20 // Type: Method.
21 // Args: None.
22 // Return: None.
23 // Throws: None.
24 //--
CMIDriverBase()25 CMIDriverBase::CMIDriverBase()
26 : m_pDriverFallThru(nullptr), m_pDriverParent(nullptr), m_bExitApp(false) {}
27
28 //++
29 //------------------------------------------------------------------------------------
30 // Details: CMIDriverBase destructor.
31 // Type: Overrideable.
32 // Args: None.
33 // Return: None.
34 // Throws: None.
35 //--
~CMIDriverBase()36 CMIDriverBase::~CMIDriverBase() { m_pDriverFallThru = NULL; }
37
38 //++
39 //------------------------------------------------------------------------------------
40 // Details: This function allows *this driver to call on another driver to
41 // perform work
42 // should this driver not be able to handle the client data input.
43 // Type: Overrideable.
44 // Check the error message if the function returns a failure.
45 // Type: Overridden.
46 // Args: vCmd - (R) Command instruction to interpret.
47 // vwErrMsg - (W) Status description on command failing.
48 // Return: MIstatus::success - Command succeeded.
49 // MIstatus::failure - Command failed.
50 // Throws: None.
51 //--
DoFallThruToAnotherDriver(const CMIUtilString & vCmd,CMIUtilString & vwErrMsg)52 bool CMIDriverBase::DoFallThruToAnotherDriver(const CMIUtilString &vCmd,
53 CMIUtilString &vwErrMsg) {
54 // Do nothing - override and implement. Use m_pDriverFallThru.
55 return MIstatus::success;
56 }
57
58 //++
59 //------------------------------------------------------------------------------------
60 // Details: This function allows *this driver to call on another driver to
61 // perform work
62 // should this driver not be able to handle the client data input.
63 // Type: Overrideable.
64 // Args: vrOtherDriver - (R) Reference to another driver object.
65 // Return: MIstatus::success - Functional succeeded.
66 // MIstatus::failure - Functional failed.
67 // Throws: None.
68 //--
SetDriverToFallThruTo(const CMIDriverBase & vrOtherDriver)69 bool CMIDriverBase::SetDriverToFallThruTo(const CMIDriverBase &vrOtherDriver) {
70 MIunused(vrOtherDriver);
71
72 // Do nothing - override and implement. Set m_pDriverFallThru.
73
74 return MIstatus::success;
75 }
76
77 //++
78 //------------------------------------------------------------------------------------
79 // Details: This function allows *this driver to call functionality on the
80 // parent driver
81 // ask for information for example.
82 // Type: Overrideable.
83 // Args: vrOtherDriver - (R) Reference to another driver object.
84 // Return: MIstatus::success - Functional succeeded.
85 // MIstatus::failure - Functional failed.
86 // Throws: None.
87 //--
SetDriverParent(const CMIDriverBase & vrOtherDriver)88 bool CMIDriverBase::SetDriverParent(const CMIDriverBase &vrOtherDriver) {
89 MIunused(vrOtherDriver);
90
91 // Do nothing - override and implement. Set m_pDriverParent.
92
93 return MIstatus::success;
94 }
95
96 //++
97 //------------------------------------------------------------------------------------
98 // Details: Retrieve the parent driver to *this driver if one assigned. If
99 // assigned *this
100 // is the pass through driver that the parent driver passes work to.
101 // Type: Method.
102 // Args: None.
103 // Return: CMIDriverBase * - Pointer to a driver object.
104 // - NULL = there is not parent to *this driver.
105 // Throws: None.
106 //--
GetDriversParent() const107 CMIDriverBase *CMIDriverBase::GetDriversParent() const {
108 return m_pDriverParent;
109 }
110
111 //++
112 //------------------------------------------------------------------------------------
113 // Details: Retrieve the pointer to the other fall through driver *this driver
114 // is using
115 // (or not using).
116 // Type: Method.
117 // Args: None.
118 // Return: CMIDriverBase * - Pointer to other driver.
119 // - NULL if no driver set.
120 // Throws: None.
121 //--
GetDriverToFallThruTo() const122 CMIDriverBase *CMIDriverBase::GetDriverToFallThruTo() const {
123 return m_pDriverFallThru;
124 }
125
126 //++
127 //------------------------------------------------------------------------------------
128 // Details: *this driver provides a file stream to other drivers on which *this
129 // driver
130 // write's out to and they read as expected input. *this driver is
131 // passing
132 // through commands to the (child) pass through assigned driver.
133 // Type: Overrideable.
134 // Args: None.
135 // Return: FILE * - Pointer to stream.
136 // Throws: None.
137 //--
GetStdin() const138 FILE *CMIDriverBase::GetStdin() const {
139 // Do nothing - override and implement
140 return nullptr;
141 }
142
143 //++
144 //------------------------------------------------------------------------------------
145 // Details: *this driver provides a file stream to other pass through assigned
146 // drivers
147 // so they know what to write to.
148 // Type: Overrideable.
149 // Args: None.
150 // Return: FILE * - Pointer to stream.
151 // Throws: None.
152 //--
GetStdout() const153 FILE *CMIDriverBase::GetStdout() const {
154 // Do nothing - override and implement
155 return nullptr;
156 }
157
158 //++
159 //------------------------------------------------------------------------------------
160 // Details: *this driver provides a error file stream to other pass through
161 // assigned drivers
162 // so they know what to write to.
163 // Type: Overrideable.
164 // Args: None.
165 // Return: FILE * - Pointer to stream.
166 // Throws: None.
167 //--
GetStderr() const168 FILE *CMIDriverBase::GetStderr() const {
169 // Do nothing - override and implement
170 return nullptr;
171 }
172
173 //++
174 //------------------------------------------------------------------------------------
175 // Details: Set the MI Driver's exit application flag. The application checks
176 // this flag
177 // after every stdin line is read so the exit may not be instantaneous.
178 // If vbForceExit is false the MI Driver queries its state and
179 // determines if is
180 // should exit or continue operating depending on that running state.
181 // Type: Overrideable.
182 // Args: vbForceExit - (R) True = Do not query, set state to exit, false =
183 // query if can/should exit right now.
184 // Return: None.
185 // Throws: None.
186 //--
SetExitApplicationFlag(const bool vbForceExit)187 void CMIDriverBase::SetExitApplicationFlag(const bool vbForceExit) {
188 MIunused(vbForceExit);
189
190 // Do nothing - override and implement
191 }
192