Move generate json function from EventEngine to DocumentationEngine

This commit is contained in:
Ylva Selling
2024-02-26 09:45:56 +01:00
parent a911f340ce
commit 4a8e964f89
4 changed files with 21 additions and 26 deletions
+20 -1
View File
@@ -366,6 +366,25 @@ nlohmann::json DocumentationEngine::generateLicenseList() const {
return json;
}
nlohmann::json DocumentationEngine::generateEventJson() const {
nlohmann::json result;
result["name"] = "Events";
nlohmann::json data = nlohmann::json::array();
std::vector<EventEngine::ActionInfo> eventActions =
global::eventEngine->registeredActions();
for (const EventEngine::ActionInfo& eventAction : eventActions) {
nlohmann::json eventJson;
std::string eventName = std::string(events::toString(eventAction.type));
eventJson["name"] = eventName;
data.push_back(eventJson);
}
result["data"] = data;
return result;
}
nlohmann::json DocumentationEngine::generateFactoryManagerJson() const {
nlohmann::json json;
@@ -517,7 +536,7 @@ void DocumentationEngine::writeDocumentation() const {
nlohmann::json sceneProperties = settings.get();
nlohmann::json sceneGraph = sceneJson.get();
nlohmann::json actions = generateActionJson();
nlohmann::json events = global::eventEngine->generateJson();
nlohmann::json events = generateEventJson();
sceneProperties["name"] = "Settings";
sceneGraph["name"] = "Scene";
-23
View File
@@ -257,27 +257,4 @@ scripting::LuaLibrary EventEngine::luaLibrary() {
}
};
}
nlohmann::json EventEngine::generateJson() const {
nlohmann::json result;
result["name"] = "Events";
nlohmann::json data = nlohmann::json::array();
for (auto& [key, value] : _eventActions) {
nlohmann::json eventJson;
std::string eventName = std::string(events::toString(key));
eventJson["name"] = eventName;
data.push_back(eventJson);
}
for (auto& [key, value] : _eventTopics) {
nlohmann::json eventJson;
std::string eventName = std::string(events::toString(key));
eventJson["name"] = eventName;
data.push_back(eventJson);
}
result["data"] = data;
return result;
}
} // namespace openspace