This commit is contained in:
2026-08-12 01:44:13 +08:00
parent 3b4d509d43
commit 4f2ec40922
6 changed files with 180 additions and 54 deletions
+22
View File
@@ -263,6 +263,28 @@ struct adminive::Object_Adapter<Runtime_Config> {
};
```
如果运行时对象已经拥有权威状态和并发策略,不要为了 Adminive 再造一份完整配置快照。`field(name, label, accessor)` 直接接受 Structive `Property_Accessor`;默认数据成员仍使用 `structive::Member_Accessor`,方法型或子控件属性可使用 Structive 的 getter/setter accessor
```cpp
template <>
struct adminive::Type_Descriptor<Runtime_Control> {
static auto get() {
auto accessor = structive::trusted_callable_accessor<Runtime_Control>(
[](const Runtime_Control& value) { return value.setting(); },
[](Runtime_Control& value, int setting) {
value.apply_setting(setting);
});
return adminive::object<Runtime_Control>(
"runtime_control",
adminive::field("setting", "Setting", std::move(accessor))
.editable()
.unsynchronized());
}
};
```
这种直接描述不要求对象可复制,也不经过 `Object_Adapter``.unsynchronized()` 只表示 Adminive/Structive 不增加同步域;访问器调用的业务方法及对象自身同步仍是唯一权威实现。
`Resource_Service` 始终通过 `Object_Adapter<T>::commit()`提交运行时模型。外部持久化和系统副作用通过 `Resource_Transaction<Model>` 分成准备、提交和回滚三个阶段:
```cpp