载入中...
搜索中...
未找到
CrowdNavigationBindings.cpp
浏览该文件的文档.
28 if (value.getType() != ssq::Type::INTEGER) throw ssq::TypeException("Flow token requires integer fields");
32 constexpr const char* states[] = {"ready", "cancelled", "committed", "pending", "failed", "unreachable"};
33 return Value(Value::Object{{"state", Value(std::string(states[static_cast<int>(progress.state)]))},
40Result<std::reference_wrapper<Crowd::NavigationRequests::Entry>> Crowd::NavigationRequests::resolve(
51 if (entry.occupied && generation > 0 && static_cast<std::uint64_t>(generation) == entry.generation)
75 const auto lookup = [](Crowd* crowd, ssq::Table token) -> Result<std::reference_wrapper<Entry>> {
88 while (index < entries.size() && (entries[index].occupied || entries[index].generation == UINT32_MAX))
115 vm, Result<Value>::failure(Diagnostic::error(DiagnosticCode::Failed, error.what(), "flowRequest")),
121 cls.addFunc("acquireFlowRequestLease", [vm = cls.getHandle(), lookup](Crowd* crowd, ssq::Table token) {
124 return script::projectResult(vm, Result<Value>::failure(found.status()), [](Value value) { return value; });
131 // Pin belongs to the already known request; callers can release it even if VM projection fails.
134 return script::projectResult(vm, Result<Value>::failure(lease.status()), [](Value value) { return value; });
141 cls.addFunc("sampleFlowRequestLease", [vm = cls.getHandle(), lookup](Crowd* crowd, ssq::Table token, float x,
153 return script::projectResult(vm, crowd->sampleFlowField(*entry.lease, x, y), [](FlowSample value) {
155 {"state", Value(std::string(value.state == FlowSampleState::Reachable ? "reachable" : "unreachable"))},
160 cls.addFunc("advanceFlowRequest", [vm = cls.getHandle(), lookup](Crowd* crowd, ssq::Table token, int maxWork) {
174 if (plan.state() == Crowd::FlowBuildState::Pending || plan.state() == Crowd::FlowBuildState::Ready ||
177 return script::projectResult(vm, Result<Crowd::FlowBuildProgress>::success({plan.state(), 0, 0}),
180 cls.addFunc("commitFlowRequest", [vm = cls.getHandle(), lookup](Crowd* crowd, ssq::Table token) {
185 cls.addFunc("cancelFlowRequest", [vm = cls.getHandle(), lookup](Crowd* crowd, ssq::Table token) {
The single Squirrel projection for common Result, Status and Value.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
@ Unreachable
friend Result< FlowLease > resolveFlowRequestLease(Crowd &crowd, const ssq::Table &token)
Resolve a checked request-owned lease without retaining script table references.
Definition CrowdNavigationBindings.cpp:61
friend void exposeNavigationRequests(ssq::Class &cls)
Register generation-qualified transient navigation request bindings.
Definition CrowdNavigationBindings.cpp:73
Result< FlowLease > acquireFlowField(std::span< const FlowGoal > goals)
Acquire an existing field for a canonical goal set without graph work.
Definition CrowdFlowCache.cpp:98
Definition Crowd.cpp:14
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:540
@ InvalidArgument
@ NotFound
@ Conflict
@ Applied