--- nono/vm/event.cpp 2026/04/29 17:04:32 1.1.1.3 +++ nono/vm/event.cpp 2026/04/29 17:05:50 1.1.1.10 @@ -1,19 +1,24 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt +// + +// +// イベント // #include "event.h" #include "scheduler.h" -// 全イベントの配列 -std::vector gEvents; - // コンストラクタ -Event::Event() +Event::Event(Device *dev_, int code_, + EventCallback_t func_, const std::string& name_) { - // 自身をリストに追加する - gEvents.push_back(this); + dev = dev_; + code = code_; + func = func_; + name = name_; } // デストラクタ @@ -21,28 +26,40 @@ Event::~Event() { } -// イベントタイマーを開始する -void -Event::Start() -{ - gScheduler->StartEvent(this); -} - -// イベントタイマーを停止する -void -Event::Stop() -{ - gScheduler->StopEvent(this); -} - // 名前をセットする void Event::SetName(const std::string& val) { name = val; if (name.length() > 25) { - dev->putmsg("Event Name \"%s\" is too long(%d chars)", - name.c_str(), (int)name.length()); + dev->putmsgn("Event Name \"%s\" is too long(%u chars)", + name.c_str(), (uint)name.length()); name.resize(25); } } + + +// +// イベントマネージャ +// + +// コンストラクタ +EventManager::EventManager() + : inherited(OBJ_EVENT_MANAGER) +{ +} + +// デストラクタ +EventManager::~EventManager() +{ +} + +// イベントを登録する。 +// こっちは初期設定のほう。イベントを有効にする、ではない。 +Event * +EventManager::Regist(Device *dev_, int code_, + EventCallback_t func_, const std::string& name_) +{ + all.push_back(new Event(dev_, code_, func_, name_)); + return all.back(); +}