--- nono/vm/event.cpp 2026/04/29 17:04:28 1.1 +++ nono/vm/event.cpp 2026/04/29 17:05:10 1.1.1.7 @@ -1,21 +1,56 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // -#include "event.h" +// +// イベント +// -// 全イベントの配列 -std::vector gEvents; +#include "event.h" +#include "scheduler.h" // コンストラクタ Event::Event() { - // 自身をリストに追加する - gEvents.push_back(this); +} + +// コンストラクタ (dev 指定あり) +Event::Event(Device *dev_) + : Event() +{ + dev = dev_; } // デストラクタ Event::~Event() { } + +// イベントを登録する +void +Event::Regist() +{ + gScheduler->RegistEvent(*this); +} + +// 名前をセットして、イベントを登録する (便利関数) +void +Event::Regist(const std::string& name_) +{ + SetName(name_); + Regist(); +} + +// 名前をセットする +void +Event::SetName(const std::string& val) +{ + name = val; + if (name.length() > 25) { + dev->putmsgn("Event Name \"%s\" is too long(%d chars)", + name.c_str(), (int)name.length()); + name.resize(25); + } +}