--- nono/lib/mainapp.h 2026/04/29 17:04:51 1.1.1.7 +++ nono/lib/mainapp.h 2026/04/29 17:05:08 1.1.1.11 @@ -4,15 +4,18 @@ // Licensed under nono-license.txt // +// +// CLI/GUI 共通のメイン部分 +// + #pragma once -#include "config.h" -#include "debugger.h" -#include "logger.h" -#include "vm_luna.h" -#include "vm_x68k.h" +#include "vm.h" + +class Config; +class Logger; +class MonitorManager; -// 起動時の引数処理などを行う。 class MainApp { public: @@ -20,6 +23,9 @@ class MainApp static const int PASS = -1; // 実行を継続 public: + MainApp(); + ~MainApp(); + // 初期化 (ステージ1) int Init1(bool is_cli_, int ac, char *av[]); @@ -35,29 +41,37 @@ class MainApp // 現在の VM が指定の feature を持っているか? bool HasVMFeature(vmf_t flag) const; - public: - // -A: ホストファイル名 (とりあえず) - const char *host_file {}; + // VM ディレクトリを返す + const std::string& GetVMDir() const { return vmdir; } - // -b: ブレークポイント "[,]" - std::vector debug_breakaddr {}; + // ログレベルを設定する。 + static bool SetLogopt(const std::vector&, std::string *errmsg); + + // ログ名の一覧を表示する + static std::vector GetLogNames(); + + // オブジェクトを追加/削除 (Object が呼ぶ) + void AddObject(Object *); + void DeleteObject(Object *); + // オブジェクトのリストを返す + const std::vector& GetObjects() const { return objects; } + + // Logger を返す + Logger *GetLogger() const { return logger.get(); } + + public: // -B: ベンチマークモード int benchmark_mode {}; - // -c: VM ディレクトリ or 設定ファイル - std::string vmdir {}; - std::string vmfile {}; - const std::string& GetVMDir() const { return vmdir; } - - // -C: ログをコンソールに出力 - bool log_to_console {}; + // -b: ブレークポイント "[,]" + std::vector debug_breakaddr {}; // -d: 起動時にデバッガで停止 bool debug_on_start {}; - // -D: コンソールをデバッガで使う - bool debug_on_console {}; + // -D: デバッガを stdio で使う + bool opt_D {}; // -f: 高速モード (XXX 設定ファイルと含めて見直すこと) bool fast_mode {}; @@ -65,8 +79,8 @@ class MainApp // --fontsize: フォントサイズ指定値 (値は fontsize_t ではない) int fontsize {}; - // -L: ログ指定文字列 - char logopt[256] {}; + // -H: 内蔵 Human68k 風を組み込む。-X による実行ファイル名が必要。 + bool human_mode {}; // -M: モニタ名 std::string monitor_opt {}; @@ -74,15 +88,10 @@ class MainApp // -s,--scale: 画面スケール double screen_scale {}; - // --show-config: 設定内容を表示 (1なら通常、2ならall) - int show_config {}; - - // -V: パラメータ指定 - std::vector config_options {}; - - // -X: Human68k 実行ファイル名と引数 - const char *human68k_file {}; - char human68k_arg[256] {}; + // -X: ホスト実行ファイル名とその引数 + const char *exec_file {}; + std::string exec_arg {}; + bool load_and_exec {}; private: // ヘルプメッセージを表示する @@ -94,16 +103,56 @@ class MainApp // 引数を処理する bool ParseOpt(int ac, char *av[]); + // opt を logopt に追加する (-L オプション用) + void AddLogopt(const char *opt); + // -L オプションを処理する bool ParseLogopt(); + // ログレベル1つを設定する。 + static bool SetLogopt1(const std::string&, std::string *errmsg); + + // コンパイルされている host netdriver の一覧を表示 + void ShowHostnet() const; + // CLI/GUI 区別 bool IsCLI() const { return is_cli; } bool IsGUI() const { return !is_cli; } bool is_cli {}; + // ログ + std::unique_ptr logger /*{}*/; + + // 全オブジェクトへのポインタのリスト (所有はしていない) + std::vector objects {}; + + // VM + std::unique_ptr pVM {}; + + // 設定項目 + std::unique_ptr pConfig /*{}*/; + // VM 種別 vmtype_t vmtype {}; + + // モニタマネージャ + std::unique_ptr pMonitorManager /*{}*/; + + // -c: VM ディレクトリ or 設定ファイル + std::string vmdir {}; + std::string vmfile {}; + + // -C: ログをコンソールに出力 + bool log_to_console {}; + + // -L: ログ指定文字列 + std::string logopt {}; + + // --show-config: 設定内容を表示 (1なら通常、2ならall) + int show_config {}; + + // -V: パラメータ指定 + std::vector config_options {}; }; // グローバルインスタンス