|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2022 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // ホストドライバ (基本クラス)
9: //
10:
11: #pragma once
12:
13: #include "object.h"
14: #include "monitor.h"
15:
16: class HostDevice;
17:
18: class Driver : public Object
19: {
20: using inherited = Object;
21: protected:
22: static const int NODATA = -1;
23:
24: protected:
1.1.1.6 ! root 25: Driver(HostDevice *hostdev_, const std::string& drivername_);
1.1 root 26: public:
1.1.1.3 root 27: ~Driver() override;
1.1 root 28:
1.1.1.5 root 29: virtual bool InitDriver(bool startup = true);
1.1 root 30:
31: // ドライバ固有の Dispatch。 udata を返す。
32: // 必要に応じて udata を変更しても良い。
33: // これ以上処理することがなければ HostDevice::DONE を返す。
34: virtual int Dispatch(int udata);
35:
36: // モニタのうちドライバ依存部分の情報を書き出す。
1.1.1.2 root 37: // screen のうち y行目から2行のみがドライバ依存部分なので
1.1 root 38: // ここだけ書き出すこと。不要なら書き出さなくてよい。Clear() しないこと。
1.1.1.2 root 39: virtual void MonitorUpdateMD(TextScreen& screen, int y);
1.1 root 40:
41: // ドライバ名を取得。
1.1.1.6 ! root 42: const std::string& GetDriverName() const { return drivername; }
1.1 root 43:
1.1.1.4 root 44: // 親ホストデバイス(基本クラス)を取得。
45: HostDevice *GetHostDev() const { return hostdev; }
46:
1.1.1.5 root 47: // InitDriver() 中の(主に最後の)エラーメッセージ。
48: // 各ドライバはエラーが発生しても各自で warnx による表示は基本的にせず、
49: // ここにエラーメッセージをセットする。必要になった時点で HostDevice が
50: // 最後の一つを warnx() で表示する。
51: // なお、おそらくそれだけでは大抵何も分からないのでこれとは別に
52: // ログレベル 1 で putmsg() は充実させておくこと。
53: std::string errmsg {};
54:
1.1 root 55: protected:
56: // 親ホストデバイス
57: HostDevice *hostdev {};
58:
1.1.1.5 root 59: // ドライバ名 ("none" とか)。
60: // 設定ファイルに合わせてすべて小文字。
1.1.1.6 ! root 61: std::string drivername {};
1.1 root 62: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.