This commit is contained in:
2026-08-20 14:55:35 +08:00
parent 44af33bee6
commit b8a8470ced
6 changed files with 20 additions and 11 deletions
+11 -3
View File
@@ -586,10 +586,18 @@ concept Object_Root = requires {
requires Object_Core<T>; requires Object_Core<T>;
typename T::template Builder<T>; typename T::template Builder<T>;
}; };
namespace detail { // Attached 约束真正进入运行时依赖图的对象必须来自 Attach_Object。Rely_Type 只声明允许绑定的基类型,实际节点在加入图时必须满足该概念。
template <typename T> template <typename T>
concept Rely_Object = requires { concept Attached = requires {
requires Root_Derived<T>; requires Object_Core<T>;
typename T::Attached_Object;
requires Object_Root<typename T::Attached_Object>;
requires std::derived_from<T, typename T::Attached_Object>;
};
namespace detail {
// Rely_Object 表示已经附着运行时数据、可以安全进入依赖图的实际对象类型。图内保存 Root* 后静态类型会被擦除,因此该约束必须在入图边界完成。
template <typename T>
concept Rely_Object = Attached<T> && requires {
typename T::State; typename T::State;
typename T::Buffers; typename T::Buffers;
requires Prop_State<typename T::State>; requires Prop_State<typename T::State>;
@@ -57,13 +57,6 @@ concept Impl_Mechanisms = requires {
requires State_List<Impl_States<Base, Local_Mechanisms...>>; requires State_List<Impl_States<Base, Local_Mechanisms...>>;
}; };
} }
template <typename T>
concept Attached = requires {
requires Object_Core<T>;
typename T::Attached_Object;
requires Object_Root<typename T::Attached_Object>;
requires std::derived_from<T, typename T::Attached_Object>;
};
// Impl 在编译期把 Buffer/Rely/State 三类机制叠加到继承链;每一层只声明自己的机制,最终类型汇总完整能力。 // Impl 在编译期把 Buffer/Rely/State 三类机制叠加到继承链;每一层只声明自己的机制,最终类型汇总完整能力。
template <typename Self, typename Base, typename... Local_Mechanisms> requires template <typename Self, typename Base, typename... Local_Mechanisms> requires
detail::Impl_Mechanisms<Base, Local_Mechanisms...> detail::Impl_Mechanisms<Base, Local_Mechanisms...>
+1 -1
View File
@@ -117,7 +117,7 @@ public:
this->rely->for_each(std::forward<Callback>(callback)); this->rely->for_each(std::forward<Callback>(callback));
} }
}; };
// Editor 只操作待提交图;结构是否合法由编辑完成后的拓扑验证统一判断,不在每个底层操作重复检查 // Editor 只操作待提交图;结构是否合法由编辑完成后的拓扑验证统一判断。新增节点和依赖源必须满足 Attached,保证进入图的 Root* 一定已由 Attach_Object 绑定运行时 exchange
template <typename Bound_Object> requires Root_Derived<Bound_Object> template <typename Bound_Object> requires Root_Derived<Bound_Object>
class Editor : public View { class Editor : public View {
private: private:
+1
View File
@@ -2,6 +2,7 @@
#include <chrono> #include <chrono>
#include <limits> #include <limits>
#include <taskflow/observer/interface.hpp> #include <taskflow/observer/interface.hpp>
#include "double_buffer/core.hpp"
namespace aethera { namespace aethera {
namespace { namespace {
class Stage_Registry : ::double_buffer::Pinned { class Stage_Registry : ::double_buffer::Pinned {
+1
View File
@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "double_buffer/object.hpp" #include "double_buffer/object.hpp"
#include "double_buffer/core.hpp"
#include <array> #include <array>
#include <string> #include <string>
#include <taskflow/taskflow.hpp> #include <taskflow/taskflow.hpp>
+6
View File
@@ -21,6 +21,12 @@ struct Graph_Object : double_buffer::Impl<Graph_Object, double_buffer::Root, dou
struct Private : Prev_Private {}; struct Private : Prev_Private {};
}; };
using Graph = double_buffer::Attach_Object<Graph_Object>; using Graph = double_buffer::Attach_Object<Graph_Object>;
static_assert(!double_buffer::Attached<Node_Object>);
static_assert(double_buffer::Attached<Node>);
static_assert(!double_buffer::detail::Rely_Object<Node_Object>);
static_assert(double_buffer::detail::Rely_Object<Node>);
static_assert(!double_buffer::detail::State_Rely_Source<Node_Object, &Node_Object::State::value>);
static_assert(double_buffer::detail::State_Rely_Source<Node, &Node_Object::State::value>);
} }
TEST(rely_storage, edited_graph_moves_inward_and_stays_synchronized) { TEST(rely_storage, edited_graph_moves_inward_and_stays_synchronized) {
Node first; Node first;