feat(frame): define module and cpu

This commit is contained in:
Wankupi
2024-07-23 18:39:44 +08:00
parent edb0dae127
commit 9038750dbe
2 changed files with 70 additions and 0 deletions

19
include/module.h Normal file
View File

@ -0,0 +1,19 @@
#include "synchronize.h"
namespace dark {
struct ModuleBase {
virtual void work() = 0;
virtual void sync() = 0;
virtual ~ModuleBase() = default;
};
template<typename _Tinput, typename _Toutput, typename _Tprivate>
struct Module : public ModuleBase, public _Tinput, public _Toutput, protected _Tprivate {
void sync() override final {
sync_member(static_cast<_Tinput &>(*this));
sync_member(static_cast<_Toutput &>(*this));
sync_member(static_cast<_Tprivate &>(*this));
}
};
}// namespace dark