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