Annotation of nono/lib/mainapp.h, revision 1.1.1.12

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.