Annotation of nono/vm/uimessage.h, revision 1.1.1.2

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2021 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
                      7: //
1.1.1.2 ! root        8: // UI スレッドへのメッセージ機構
1.1       root        9: //
                     10: 
                     11: #pragma once
                     12: 
                     13: #include "fixedqueue.h"
                     14: #include <functional>
                     15: 
                     16: class UIMessage
                     17: {
                     18:  public:
                     19:        // メッセージ ID
                     20:        enum ID {
                     21:                NONE = 0,
                     22: 
1.1.1.2 ! root       23:                // アプリケーションを終了する
        !            24:                APPEXIT,
1.1       root       25: 
                     26:                // MPU がホールト状態になった
                     27:                HALT,
                     28: 
                     29:                // SCSI (各 ID) のメディア状態が変わった (Load/Unload)
                     30:                SCSI_MEDIA_CHANGE,
                     31: 
                     32:                // SCSI メディアの挿入に失敗した
                     33:                SCSI_MEDIA_FAILED,
                     34: 
                     35:                // キー入力状態が変わった
                     36:                KEYBOARD,
                     37: 
                     38:                // LCD 状態が変わった
                     39:                LCD,
                     40: 
1.1.1.2 ! root       41:                // 画面を更新した
        !            42:                RENDER,
        !            43: 
        !            44:                // パレットが変更になった
        !            45:                PALETTE,
        !            46: 
1.1       root       47:                ID_MAX,
                     48:        };
                     49: 
                     50:        using Queue = FixedQueue<UIMessage, 16>;
                     51: 
                     52:  public:
                     53:        UIMessage();
1.1.1.2 ! root       54:        UIMessage(ID id_, int arg_);
1.1       root       55: 
                     56:        ID GetID() const { return id; }
                     57:        int GetArg() const { return arg; }
                     58: 
                     59:        // メッセージ処理関数をアタッチ
                     60:        static void Attach(const std::function<void(Queue&)>& process_);
                     61: 
                     62:        // 新しい UIMessage を生成して投函
                     63:        static void Post(ID id);
                     64:        // 新しい UIMessage を生成して投函(argあり)
                     65:        static void Post(ID id, int arg);
                     66: 
                     67:  protected:
                     68:        // 自身を投函
                     69:        void Post();
                     70: 
                     71:  private:
1.1.1.2 ! root       72:        ID id {};
        !            73:        int arg {};
1.1       root       74: 
                     75:        static Queue queue;
                     76: 
                     77:        // メッセージ処理コールバック
                     78:        static std::function<void(Queue&)> process;
                     79: };

unix.superglobalmegacorp.com

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