This repository was archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy patharduinoContext.ts
54 lines (45 loc) · 1.72 KB
/
arduinoContext.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import { ArduinoApp } from "./arduino/arduino";
import { BoardManager } from "./arduino/boardManager";
import { hostPlatform } from "./common/platform";
import { DebuggerManager } from "./debug/debuggerManager";
import { DeviceContext } from "./deviceContext";
class ArduinoContext {
public get initialized(): boolean {
return !!this._arduinoApp;
}
public get arduinoApp(): ArduinoApp {
return this._arduinoApp;
}
public set arduinoApp(value: ArduinoApp) {
this._arduinoApp = value;
}
// TODO EW: This is redundant: the board manager is already part of
// the arduino app
public get boardManager() {
return this._boardManager;
}
public set boardManager(value: BoardManager) {
this._boardManager = value;
}
public get debuggerManager(): DebuggerManager {
if (this._debuggerManager === null) {
this._debuggerManager = new DebuggerManager(
DeviceContext.getInstance().extensionPath,
this.arduinoApp.settings,
this.boardManager,
hostPlatform());
this._debuggerManager.initialize();
}
return this._debuggerManager;
}
// TODO EW: You don't have to initialize members to null
// if they don't get a default value or aren't initialized
// within a constructor they are "undefined" by default.
// This makes comparing against null (above) superfluous.
private _arduinoApp: ArduinoApp = null;
private _debuggerManager: DebuggerManager = null;
private _boardManager: BoardManager = null;
}
export default new ArduinoContext();