载入中...
搜索中...
未找到
SocialRuntime.cpp
浏览该文件的文档.
3
4namespace eve::social_editing {
6 social::SocialGraph* runtime) const {
7 if (!runtime)
8 return eve::editing::failed<void>(EditorStatus::Rejected, RuleId("editor.social.runtime"),
9 "Live SocialGraph is required");
10 const auto diagnostics = document.validate();
11 for (const auto& d : diagnostics)
12 if (d.severity() == DiagnosticSeverity::Error)
13 return Result<void>::failure(eve::Status(EditorStatus::Rejected, diagnostics));
14 runtime->clear();
15 for (const auto& e : document.edges()) {
16 bool accepted = false;
17 if (e.kind == "owner")
18 accepted = runtime->setOwner(e.source.value(), e.target.value());
19 else if (e.kind == "controller")
20 accepted = runtime->setController(e.source.value(), e.target.value());
21 else if (e.kind == "assignment")
22 accepted = runtime->assign(e.source.value(), e.type, e.target.value());
23 else
24 accepted = runtime->setRelation(e.source.value(), e.target.value(), e.type, e.weight);
25 if (!accepted)
26 return eve::editing::failed<void>(EditorStatus::Failed,
27 RuleId("editor.social.runtime-edge"),
28 "Social runtime rejected an authored edge");
29 }
30 return eve::editing::applied<void>();
31}
32} // namespace eve::social_editing
float d
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Structured status and zero or more diagnostics for an operation.
Definition Status.h:68
Indexed ownership, control, assignment, and typed-relation graph.
Definition SocialGraph.h:34
UI-neutral revisioned social graph authoring document.
std::vector< EditorDiagnostic > validate() const
Validate references, uniqueness constraints and finite weights.
std::vector< SocialEdgeRecord > edges() const
Enumerate edges in stable order.
Result< void > apply(const SocialDocumentTarget &document, social::SocialGraph *runtime) const
Applies .
editing::RuleId RuleId