载入中...
搜索中...
未找到
archspace_editor.cpp
浏览该文件的文档.
2
5#include "common/Capability.h"
8
9#include <simplesquirrel/simplesquirrel.hpp>
10
11#include <stdexcept>
12#include <string>
13#include <string_view>
14#include <vector>
15
17namespace {
18
19std::string stringField(const editor::EditorValue::Object& request, const char* key) {
20 const auto found = request.find(key);
21 if (found == request.end()) return {};
22 const auto* value = found->second.getIf<std::string>();
23 return value ? *value : std::string{};
24}
25
26} // namespace
27
29public:
30 std::vector<std::string_view> types() const override { return {"archspace", "archspace-document"}; }
31
33 const editor::EditorValue::Object& request) override {
34 (void)type;
35 auto document = std::make_unique<archspace_editing::ArchSpaceDocumentTarget>(target.value());
36 const std::string site = stringField(request, "siteId");
37 if (!site.empty()) {
38 const std::string building = stringField(request, "buildingId");
39 const std::string level = stringField(request, "levelId");
40 auto operation = document->makeBootstrap(site, building.empty() ? site + ".building" : building,
41 level.empty() ? site + ".level0" : level);
42 if (!operation.ok())
44 auto applied = document->applyDomainOperation(operation.value());
45 if (!applied.ok()) return editor::Result<editor::AutomationOwnedTarget>::failure(applied.status());
46 }
48 owned.target = std::move(document);
49 return eve::editing::applied<editor::AutomationOwnedTarget>(std::move(owned));
50 }
51};
52
54
56 auto* registry = eve::cap::query<editing::IEditingCommandRegistry>();
57 if (!registry || !archspace_editing::registerEditingCommands(*registry).ok())
58 throw std::runtime_error("Failed to register ArchSpace editing commands");
59 eve::cap::addListener<editor::IEditorAutomationTargetFactory>(factory_.get());
60}
61
63 eve::cap::removeListener<editor::IEditorAutomationTargetFactory>(factory_.get());
64 if (auto* registry = eve::cap::query<editing::IEditingCommandRegistry>())
65 registry->unregisterOwner("archspace_editing").ignore("archspace editor adapter shutdown");
66}
67
68void ArchSpaceEditorModule::expose(ssq::Table& table) { table.addClass(name, ArchSpaceEditorModule::create, false); }
69
70void ArchSpaceEditorModule::expose(ssq::Class&) {}
71
72} // namespace eve::archspace_editor
LogicalId target
ActionParameterOperation operation
double value
ActiveSource owned
const GltfImportRequest & request
std::uint32_t key
std::string name
int level
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:26
bool found
Move-only operation result carrying either a value or Status.
Definition Result.h:155
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:314
std::vector< std::string_view > types() const override
Stable target type names this factory accepts.
editor::Result< editor::AutomationOwnedTarget > create(const editor::TargetId &target, std::string_view type, const editor::EditorValue::Object &request) override
Create a domain target from an automation request. @ownership Success transfers the target and any su...
Composition adapter that contributes ArchSpace editing commands and automation targets.
~ArchSpaceEditorModule() override
Arch space editor module.
std::map< std::string, Value > Object
Multi-provider extension point for domain-specific automation target creation.
editing::Result< void > registerEditingCommands(editing::IEditingCommandRegistry &registry)
Register ArchSpace-owned planned commands with a generic editing host.
Target plus optional borrowed-dependency owner returned by an automation factory.
std::unique_ptr< IEditableTarget > target