|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
1.1.1.11! root 7: //
! 8: // CLI/GUI 共通のメイン部分
! 9: //
! 10:
1.1 root 11: #pragma once
12:
1.1.1.11! root 13: #include "vm.h"
! 14:
! 15: class Config;
! 16: class Logger;
! 17: class MonitorManager;
1.1 root 18:
1.1.1.2 root 19: class MainApp
1.1 root 20: {
1.1.1.2 root 21: public:
1.1.1.5 root 22: // Init() の戻り値
23: static const int PASS = -1; // 実行を継続
24:
25: public:
1.1.1.11! root 26: MainApp();
! 27: ~MainApp();
! 28:
1.1.1.7 root 29: // 初期化 (ステージ1)
30: int Init1(bool is_cli_, int ac, char *av[]);
1.1 root 31:
1.1.1.7 root 32: // 初期化 (ステージ2)
33: bool Init2();
1.1 root 34:
1.1.1.2 root 35: std::string SearchFile(const std::string& name) const;
36:
37: // vmtype (VMTYPE_*) を返す。
38: // (Config が持っているのは文字列)
39: vmtype_t GetVMType() const { return vmtype; }
40:
1.1.1.3 root 41: // 現在の VM が指定の feature を持っているか?
42: bool HasVMFeature(vmf_t flag) const;
43:
1.1.1.11! root 44: // VM ディレクトリを返す
! 45: const std::string& GetVMDir() const { return vmdir; }
! 46:
1.1.1.8 root 47: // ログレベルを設定する。
48: static bool SetLogopt(const std::vector<std::string>&, std::string *errmsg);
49:
50: // ログ名の一覧を表示する
51: static std::vector<std::string> GetLogNames();
52:
1.1.1.11! root 53: // オブジェクトを追加/削除 (Object が呼ぶ)
! 54: void AddObject(Object *);
! 55: void DeleteObject(Object *);
! 56:
! 57: // オブジェクトのリストを返す
! 58: const std::vector<Object *>& GetObjects() const { return objects; }
! 59:
! 60: // Logger を返す
! 61: Logger *GetLogger() const { return logger.get(); }
1.1.1.2 root 62:
1.1.1.11! root 63: public:
1.1.1.2 root 64: // -B: ベンチマークモード
1.1.1.5 root 65: int benchmark_mode {};
1.1.1.2 root 66:
1.1.1.11! root 67: // -b: ブレークポイント "<addr>[,<skip>]"
! 68: std::vector<std::string> debug_breakaddr {};
1.1.1.2 root 69:
70: // -d: 起動時にデバッガで停止
1.1.1.5 root 71: bool debug_on_start {};
1.1.1.2 root 72:
1.1.1.11! root 73: // -D: デバッガを stdio で使う
! 74: bool opt_D {};
1.1.1.2 root 75:
76: // -f: 高速モード (XXX 設定ファイルと含めて見直すこと)
1.1.1.5 root 77: bool fast_mode {};
1.1.1.2 root 78:
79: // --fontsize: フォントサイズ指定値 (値は fontsize_t ではない)
1.1.1.5 root 80: int fontsize {};
1.1.1.2 root 81:
1.1.1.9 root 82: // -H: 内蔵 Human68k 風を組み込む。-X による実行ファイル名が必要。
83: bool human_mode {};
84:
1.1.1.2 root 85: // -M: モニタ名
86: std::string monitor_opt {};
87:
88: // -s,--scale: 画面スケール
1.1.1.5 root 89: double screen_scale {};
1.1.1.2 root 90:
1.1.1.9 root 91: // -X: ホスト実行ファイル名とその引数
92: const char *exec_file {};
93: std::string exec_arg {};
1.1.1.10 root 94: bool load_and_exec {};
1.1.1.2 root 95:
96: private:
97: // ヘルプメッセージを表示する
98: void ShowHelp(bool all) const;
99:
100: // バージョンを表示する
101: void ShowVersion() const;
102:
103: // 引数を処理する
104: bool ParseOpt(int ac, char *av[]);
105:
1.1.1.11! root 106: // opt を logopt に追加する (-L オプション用)
! 107: void AddLogopt(const char *opt);
! 108:
1.1.1.2 root 109: // -L オプションを処理する
110: bool ParseLogopt();
111:
1.1.1.8 root 112: // ログレベル1つを設定する。
113: static bool SetLogopt1(const std::string&, std::string *errmsg);
114:
115: // コンパイルされている host netdriver の一覧を表示
116: void ShowHostnet() const;
117:
1.1.1.2 root 118: // CLI/GUI 区別
119: bool IsCLI() const { return is_cli; }
120: bool IsGUI() const { return !is_cli; }
1.1.1.5 root 121: bool is_cli {};
1.1.1.2 root 122:
1.1.1.11! root 123: // ログ
! 124: std::unique_ptr<Logger> logger /*{}*/;
! 125:
! 126: // 全オブジェクトへのポインタのリスト (所有はしていない)
! 127: std::vector<Object*> objects {};
! 128:
! 129: // VM
! 130: std::unique_ptr<VM> pVM {};
! 131:
! 132: // 設定項目
! 133: std::unique_ptr<Config> pConfig /*{}*/;
! 134:
1.1.1.2 root 135: // VM 種別
136: vmtype_t vmtype {};
1.1.1.11! root 137:
! 138: // モニタマネージャ
! 139: std::unique_ptr<MonitorManager> pMonitorManager /*{}*/;
! 140:
! 141: // -c: VM ディレクトリ or 設定ファイル
! 142: std::string vmdir {};
! 143: std::string vmfile {};
! 144:
! 145: // -C: ログをコンソールに出力
! 146: bool log_to_console {};
! 147:
! 148: // -L: ログ指定文字列
! 149: std::string logopt {};
! 150:
! 151: // --show-config: 設定内容を表示 (1なら通常、2ならall)
! 152: int show_config {};
! 153:
! 154: // -V: パラメータ指定
! 155: std::vector<std::string> config_options {};
1.1.1.2 root 156: };
157:
158: // グローバルインスタンス
159: extern MainApp gMainApp;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.