|
|
nono 1.7.0
//
// nono
// Copyright (C) 2022 nono project
// Licensed under nono-license.txt
//
//
// ホストドライバ (基本クラス)
//
#pragma once
#include "object.h"
#include "monitor.h"
class HostDevice;
class Driver : public Object
{
using inherited = Object;
protected:
static const int NODATA = -1;
protected:
Driver(HostDevice *hostdev_, const std::string& drivername_);
public:
~Driver() override;
virtual bool InitDriver(bool startup = true);
// ドライバ固有の Dispatch。 udata を返す。
// 必要に応じて udata を変更しても良い。
// これ以上処理することがなければ HostDevice::DONE を返す。
virtual int Dispatch(int udata);
// モニタのうちドライバ依存部分の情報を書き出す。
// screen のうち y行目から2行のみがドライバ依存部分なので
// ここだけ書き出すこと。不要なら書き出さなくてよい。Clear() しないこと。
virtual void MonitorScreenMD(TextScreen& screen, int y);
// ドライバ名を取得。
const std::string& GetDriverName() const { return drivername; }
// 親ホストデバイス(基本クラス)を取得。
HostDevice *GetHostDev() const { return hostdev; }
// InitDriver() 中の(主に最後の)エラーメッセージ。
// 各ドライバはエラーが発生しても各自で warnx による表示は基本的にせず、
// ここにエラーメッセージをセットする。必要になった時点で HostDevice が
// 最後の一つを warnx() で表示する。
// なお、おそらくそれだけでは大抵何も分からないのでこれとは別に
// ログレベル 1 で putmsg() は充実させておくこと。
std::string errmsg {};
protected:
// 親ホストデバイス
HostDevice *hostdev {};
// ドライバ名 ("none" とか)。
// 設定ファイルに合わせてすべて小文字。
std::string drivername {};
};
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.