mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 21:09:27 -06:00
Code Cleanup (#2191)
* constexpr const -> constexpr * const char* -> std::string_view
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyInterfaces = "Interfaces";
|
||||
constexpr std::string_view KeyInterfaces = "Interfaces";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -51,28 +51,11 @@
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "ServerModule: Connection";
|
||||
constexpr std::string_view _loggerCat = "ServerModule: Connection";
|
||||
|
||||
constexpr const char* MessageKeyType = "type";
|
||||
constexpr const char* MessageKeyPayload = "payload";
|
||||
constexpr const char* MessageKeyTopic = "topic";
|
||||
|
||||
constexpr const char* VersionTopicKey = "version";
|
||||
constexpr const char* AuthenticationTopicKey = "authorize";
|
||||
constexpr const char* DocumentationTopicKey = "documentation";
|
||||
constexpr const char* GetPropertyTopicKey = "get";
|
||||
constexpr const char* LuaScriptTopicKey = "luascript";
|
||||
constexpr const char* EngineModeTopicKey = "engineMode";
|
||||
constexpr const char* SessionRecordingTopicKey = "sessionRecording";
|
||||
constexpr const char* SetPropertyTopicKey = "set";
|
||||
constexpr const char* ShortcutTopicKey = "shortcuts";
|
||||
constexpr const char* SubscriptionTopicKey = "subscribe";
|
||||
constexpr const char* TimeTopicKey = "time";
|
||||
constexpr const char* TriggerPropertyTopicKey = "trigger";
|
||||
constexpr const char* BounceTopicKey = "bounce";
|
||||
constexpr const char* FlightControllerTopicKey = "flightcontroller";
|
||||
constexpr const char* SkyBrowserKey = "skybrowser";
|
||||
constexpr const char* CameraKey = "camera";
|
||||
constexpr std::string_view MessageKeyType = "type";
|
||||
constexpr std::string_view MessageKeyPayload = "payload";
|
||||
constexpr std::string_view MessageKeyTopic = "topic";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -86,7 +69,7 @@ Connection::Connection(std::unique_ptr<ghoul::io::Socket> s, std::string address
|
||||
ghoul_assert(_socket, "Socket must not be nullptr");
|
||||
|
||||
_topicFactory.registerClass(
|
||||
AuthenticationTopicKey,
|
||||
"authorize",
|
||||
[password](bool, const ghoul::Dictionary&, ghoul::MemoryPoolBase* pool) {
|
||||
if (pool) {
|
||||
void* ptr = pool->allocate(sizeof(AuthorizationTopic));
|
||||
@@ -98,21 +81,21 @@ Connection::Connection(std::unique_ptr<ghoul::io::Socket> s, std::string address
|
||||
}
|
||||
);
|
||||
|
||||
_topicFactory.registerClass<DocumentationTopic>(DocumentationTopicKey);
|
||||
_topicFactory.registerClass<GetPropertyTopic>(GetPropertyTopicKey);
|
||||
_topicFactory.registerClass<LuaScriptTopic>(LuaScriptTopicKey);
|
||||
_topicFactory.registerClass<EngineModeTopic>(EngineModeTopicKey);
|
||||
_topicFactory.registerClass<SessionRecordingTopic>(SessionRecordingTopicKey);
|
||||
_topicFactory.registerClass<SetPropertyTopic>(SetPropertyTopicKey);
|
||||
_topicFactory.registerClass<ShortcutTopic>(ShortcutTopicKey);
|
||||
_topicFactory.registerClass<SubscriptionTopic>(SubscriptionTopicKey);
|
||||
_topicFactory.registerClass<TimeTopic>(TimeTopicKey);
|
||||
_topicFactory.registerClass<TriggerPropertyTopic>(TriggerPropertyTopicKey);
|
||||
_topicFactory.registerClass<BounceTopic>(BounceTopicKey);
|
||||
_topicFactory.registerClass<FlightControllerTopic>(FlightControllerTopicKey);
|
||||
_topicFactory.registerClass<VersionTopic>(VersionTopicKey);
|
||||
_topicFactory.registerClass<SkyBrowserTopic>(SkyBrowserKey);
|
||||
_topicFactory.registerClass<CameraTopic>(CameraKey);
|
||||
_topicFactory.registerClass<DocumentationTopic>("documentation");
|
||||
_topicFactory.registerClass<GetPropertyTopic>("get");
|
||||
_topicFactory.registerClass<LuaScriptTopic>("luascript");
|
||||
_topicFactory.registerClass<EngineModeTopic>("engineMode");
|
||||
_topicFactory.registerClass<SessionRecordingTopic>("sessionRecording");
|
||||
_topicFactory.registerClass<SetPropertyTopic>("set");
|
||||
_topicFactory.registerClass<ShortcutTopic>("shortcuts");
|
||||
_topicFactory.registerClass<SubscriptionTopic>("subscribe");
|
||||
_topicFactory.registerClass<TimeTopic>("time");
|
||||
_topicFactory.registerClass<TriggerPropertyTopic>("trigger");
|
||||
_topicFactory.registerClass<BounceTopic>("bounce");
|
||||
_topicFactory.registerClass<FlightControllerTopic>("flightcontroller");
|
||||
_topicFactory.registerClass<VersionTopic>("version");
|
||||
_topicFactory.registerClass<SkyBrowserTopic>("skybrowser");
|
||||
_topicFactory.registerClass<CameraTopic>("camera");
|
||||
}
|
||||
|
||||
void Connection::handleMessage(const std::string& message) {
|
||||
@@ -185,8 +168,8 @@ void Connection::handleJson(const nlohmann::json& json) {
|
||||
}
|
||||
std::string type = *typeJson;
|
||||
|
||||
if (!isAuthorized() && type != AuthenticationTopicKey) {
|
||||
LERROR("Connection isn't authorized.");
|
||||
if (!isAuthorized() && type != "authorize") {
|
||||
LERROR("Connection is not authorized");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,12 @@
|
||||
#include <functional>
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr const char* KeyIdentifier = "Identifier";
|
||||
constexpr const char* TcpSocketType = "TcpSocket";
|
||||
constexpr const char* WebSocketType = "WebSocket";
|
||||
constexpr const char* DenyAccess = "Deny";
|
||||
constexpr const char* RequirePassword = "RequirePassword";
|
||||
constexpr const char* AllowAccess = "Allow";
|
||||
constexpr std::string_view KeyIdentifier = "Identifier";
|
||||
constexpr std::string_view TcpSocketType = "TcpSocket";
|
||||
constexpr std::string_view WebSocketType = "WebSocket";
|
||||
constexpr std::string_view DenyAccess = "Deny";
|
||||
constexpr std::string_view RequirePassword = "RequirePassword";
|
||||
constexpr std::string_view AllowAccess = "Allow";
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo EnabledInfo = {
|
||||
"Enabled",
|
||||
@@ -110,12 +109,27 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& config)
|
||||
, _password(PasswordInfo)
|
||||
{
|
||||
|
||||
_type.addOption(static_cast<int>(InterfaceType::TcpSocket), TcpSocketType);
|
||||
_type.addOption(static_cast<int>(InterfaceType::WebSocket), WebSocketType);
|
||||
_type.addOption(
|
||||
static_cast<int>(InterfaceType::TcpSocket),
|
||||
std::string(TcpSocketType)
|
||||
);
|
||||
_type.addOption(
|
||||
static_cast<int>(InterfaceType::WebSocket),
|
||||
std::string(WebSocketType)
|
||||
);
|
||||
|
||||
_defaultAccess.addOption(static_cast<int>(Access::Deny), DenyAccess);
|
||||
_defaultAccess.addOption(static_cast<int>(Access::RequirePassword), RequirePassword);
|
||||
_defaultAccess.addOption(static_cast<int>(Access::Allow), AllowAccess);
|
||||
_defaultAccess.addOption(
|
||||
static_cast<int>(Access::Deny),
|
||||
std::string(DenyAccess)
|
||||
);
|
||||
_defaultAccess.addOption(
|
||||
static_cast<int>(Access::RequirePassword),
|
||||
std::string(RequirePassword)
|
||||
);
|
||||
_defaultAccess.addOption(
|
||||
static_cast<int>(Access::Allow),
|
||||
std::string(AllowAccess)
|
||||
);
|
||||
|
||||
if (config.hasKey(DefaultAccessInfo.identifier)) {
|
||||
std::string access = config.value<std::string>(DefaultAccessInfo.identifier);
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "AuthorizationTopic";
|
||||
constexpr std::string_view _loggerCat = "AuthorizationTopic";
|
||||
|
||||
constexpr const char* KeyStatus = "status";
|
||||
constexpr const char* Authorized = "authorized";
|
||||
constexpr const char* IncorrectKey = "incorrectKey";
|
||||
constexpr const char* BadRequest = "badRequest";
|
||||
constexpr std::string_view KeyStatus = "status";
|
||||
constexpr std::string_view Authorized = "authorized";
|
||||
constexpr std::string_view IncorrectKey = "incorrectKey";
|
||||
constexpr std::string_view BadRequest = "badRequest";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -36,9 +36,8 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* EventKey = "event";
|
||||
constexpr const char* SubscribeEvent = "start_subscription";
|
||||
constexpr const char* UnsubscribeEvent = "stop_subscription";
|
||||
constexpr std::string_view SubscribeEvent = "start_subscription";
|
||||
constexpr std::string_view UnsubscribeEvent = "stop_subscription";
|
||||
} // namespace
|
||||
|
||||
using nlohmann::json;
|
||||
@@ -63,7 +62,7 @@ bool CameraTopic::isDone() const {
|
||||
}
|
||||
|
||||
void CameraTopic::handleJson(const nlohmann::json& json) {
|
||||
std::string event = json.at(EventKey).get<std::string>();
|
||||
std::string event = json.at("event").get<std::string>();
|
||||
|
||||
if (event != SubscribeEvent) {
|
||||
_isDone = true;
|
||||
@@ -87,7 +86,7 @@ void CameraTopic::sendCameraData() {
|
||||
|
||||
GlobeBrowsingModule* module = global::moduleEngine->module<GlobeBrowsingModule>();
|
||||
glm::dvec3 position = module->geoPosition();
|
||||
std::pair<double, std::string> altSimplified = simplifyDistance(position.z);
|
||||
std::pair<double, std::string_view> altSimplified = simplifyDistance(position.z);
|
||||
|
||||
nlohmann::json jsonData = {
|
||||
{ "latitude", position.x },
|
||||
|
||||
@@ -34,41 +34,31 @@
|
||||
#include <openspace/scene/scenelicensewriter.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyType = "type";
|
||||
constexpr const char* TypeLua = "lua";
|
||||
constexpr const char* TypeFactories = "factories";
|
||||
constexpr const char* TypeKeyboard = "keyboard";
|
||||
constexpr const char* TypeAsset = "asset";
|
||||
constexpr const char* TypeMeta= "meta";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
void DocumentationTopic::handleJson(const nlohmann::json& json) {
|
||||
std::string requestedType = json.at(KeyType).get<std::string>();
|
||||
std::string requestedType = json.at("type").get<std::string>();
|
||||
|
||||
nlohmann::json response;
|
||||
|
||||
// @emiax: Proposed future refector.
|
||||
// Do not parse generated json. Instead implement ability to get
|
||||
// ghoul::Dictionary objects from ScriptEngine, FactoryManager, and KeybindingManager.
|
||||
if (requestedType == TypeLua) {
|
||||
if (requestedType == "lua") {
|
||||
response = json::parse(global::scriptEngine->generateJson());
|
||||
}
|
||||
else if (requestedType == TypeFactories) {
|
||||
else if (requestedType == "factories") {
|
||||
response = json::parse(FactoryManager::ref().generateJson());
|
||||
}
|
||||
else if (requestedType == TypeKeyboard) {
|
||||
else if (requestedType == "keyboard") {
|
||||
response = json::parse(global::keybindingManager->generateJson());
|
||||
}
|
||||
else if (requestedType == TypeAsset) {
|
||||
else if (requestedType == "asset") {
|
||||
response = json::parse(global::keybindingManager->generateJson());
|
||||
}
|
||||
else if (requestedType == TypeMeta) {
|
||||
else if (requestedType == "meta") {
|
||||
std::string docs = SceneLicenseWriter().generateJson();
|
||||
nlohmann::json parsedDocs = json::parse(docs);
|
||||
response = parsedDocs;
|
||||
|
||||
@@ -30,15 +30,11 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char _loggerCat[] = "EngineModeTopic";
|
||||
|
||||
constexpr const char EventKey[] = "event";
|
||||
constexpr const char SubscribeEvent[] = "start_subscription";
|
||||
constexpr const char UnsubscribeEvent[] = "stop_subscription";
|
||||
constexpr const char RefreshEvent[] = "refresh";
|
||||
|
||||
constexpr const char ModeKey[] = "mode";
|
||||
constexpr std::string_view _loggerCat = "EngineModeTopic";
|
||||
|
||||
constexpr std::string_view SubscribeEvent = "start_subscription";
|
||||
constexpr std::string_view UnsubscribeEvent = "stop_subscription";
|
||||
constexpr std::string_view RefreshEvent = "refresh";
|
||||
} // namespace
|
||||
|
||||
using nlohmann::json;
|
||||
@@ -60,7 +56,7 @@ bool EngineModeTopic::isDone() const {
|
||||
}
|
||||
|
||||
void EngineModeTopic::handleJson(const nlohmann::json& json) {
|
||||
const std::string event = json.at(EventKey).get<std::string>();
|
||||
const std::string event = json.at("event").get<std::string>();
|
||||
if (event != SubscribeEvent && event != UnsubscribeEvent &&
|
||||
event != RefreshEvent)
|
||||
{
|
||||
@@ -108,7 +104,7 @@ void EngineModeTopic::sendJsonData() {
|
||||
default:
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
stateJson[ModeKey] = modeString;
|
||||
stateJson["mode"] = modeString;
|
||||
|
||||
if (!stateJson.empty()) {
|
||||
_connection->sendJson(wrappedPayload(stateJson));
|
||||
|
||||
@@ -58,7 +58,8 @@ namespace {
|
||||
|
||||
using AxisType = openspace::interaction::WebsocketCameraStates::AxisType;
|
||||
|
||||
constexpr const char* _loggerCat = "FlightControllerTopic";
|
||||
constexpr std::string_view _loggerCat = "FlightControllerTopic";
|
||||
|
||||
constexpr const char* TypeKey = "type";
|
||||
constexpr const char* ValuesKey = "values";
|
||||
|
||||
|
||||
@@ -41,18 +41,18 @@
|
||||
using nlohmann::json;
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "GetPropertyTopic";
|
||||
constexpr const char* AllPropertiesValue = "__allProperties";
|
||||
constexpr const char* AllNodesValue = "__allNodes";
|
||||
constexpr const char* AllScreenSpaceRenderablesValue = "__screenSpaceRenderables";
|
||||
constexpr const char* PropertyKey = "property";
|
||||
constexpr const char* RootPropertyOwner = "__rootOwner";
|
||||
constexpr std::string_view _loggerCat = "GetPropertyTopic";
|
||||
constexpr std::string_view AllPropertiesValue = "__allProperties";
|
||||
constexpr std::string_view AllNodesValue = "__allNodes";
|
||||
constexpr std::string_view AllScreenSpaceRenderablesValue =
|
||||
"__screenSpaceRenderables";
|
||||
constexpr std::string_view RootPropertyOwner = "__rootOwner";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
void GetPropertyTopic::handleJson(const nlohmann::json& json) {
|
||||
std::string requestedKey = json.at(PropertyKey).get<std::string>();
|
||||
std::string requestedKey = json.at("property").get<std::string>();
|
||||
LDEBUG("Getting property '" + requestedKey + "'...");
|
||||
nlohmann::json response;
|
||||
if (requestedKey == AllPropertiesValue) {
|
||||
|
||||
@@ -33,11 +33,11 @@
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyScript = "script";
|
||||
constexpr const char* KeyFunction = "function";
|
||||
constexpr const char* KeyArguments = "arguments";
|
||||
constexpr const char* KeyReturn = "return";
|
||||
constexpr const char* _loggerCat = "LuaScriptTopic";
|
||||
constexpr std::string_view KeyScript = "script";
|
||||
constexpr std::string_view KeyFunction = "function";
|
||||
constexpr std::string_view KeyArguments = "arguments";
|
||||
constexpr std::string_view KeyReturn = "return";
|
||||
constexpr std::string_view _loggerCat = "LuaScriptTopic";
|
||||
|
||||
std::string formatLua(const nlohmann::json::const_iterator& it);
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "SessionRecordingTopic";
|
||||
constexpr const char* EventKey = "event";
|
||||
constexpr const char* SubscribeEvent = "start_subscription";
|
||||
constexpr const char* UnsubscribeEvent = "stop_subscription";
|
||||
constexpr const char* RefreshEvent = "refresh";
|
||||
constexpr std::string_view _loggerCat = "SessionRecordingTopic";
|
||||
|
||||
constexpr std::string_view SubscribeEvent = "start_subscription";
|
||||
constexpr std::string_view UnsubscribeEvent = "stop_subscription";
|
||||
constexpr std::string_view RefreshEvent = "refresh";
|
||||
|
||||
constexpr const char* PropertiesKey = "properties";
|
||||
constexpr const char* FilesKey = "files";
|
||||
@@ -60,7 +60,7 @@ bool SessionRecordingTopic::isDone() const {
|
||||
}
|
||||
|
||||
void SessionRecordingTopic::handleJson(const nlohmann::json& json) {
|
||||
const std::string event = json.at(EventKey).get<std::string>();
|
||||
const std::string event = json.at("event").get<std::string>();
|
||||
if (event != SubscribeEvent && event != UnsubscribeEvent &&
|
||||
event != RefreshEvent)
|
||||
{
|
||||
|
||||
@@ -34,10 +34,8 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* PropertyKey = "property";
|
||||
constexpr const char* ValueKey = "value";
|
||||
constexpr const char* _loggerCat = "SetPropertyTopic";
|
||||
constexpr const char* SpecialKeyTime = "__time";
|
||||
constexpr std::string_view _loggerCat = "SetPropertyTopic";
|
||||
constexpr std::string_view SpecialKeyTime = "__time";
|
||||
|
||||
std::string escapedLuaString(const std::string& str) {
|
||||
std::string luaString;
|
||||
@@ -113,15 +111,15 @@ namespace openspace {
|
||||
|
||||
void SetPropertyTopic::handleJson(const nlohmann::json& json) {
|
||||
try {
|
||||
const std::string& propertyKey = json.at(PropertyKey).get<std::string>();
|
||||
const std::string& propertyKey = json.at("property").get<std::string>();
|
||||
|
||||
if (propertyKey == SpecialKeyTime) {
|
||||
Time newTime;
|
||||
newTime.setTime(json.at(ValueKey).get<std::string>());
|
||||
newTime.setTime(json.at("value").get<std::string>());
|
||||
global::timeManager->setTimeNextFrame(newTime);
|
||||
}
|
||||
else {
|
||||
nlohmann::json value = json.at(ValueKey);
|
||||
nlohmann::json value = json.at("value");
|
||||
std::string literal = luaLiteralFromJson(value);
|
||||
|
||||
global::scriptEngine->queueScript(
|
||||
|
||||
@@ -29,12 +29,6 @@
|
||||
#include <openspace/interaction/actionmanager.h>
|
||||
#include <openspace/interaction/keybindingmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* EventKey = "event";
|
||||
constexpr const char* StartSubscription = "start_subscription";
|
||||
constexpr const char* StopSubscription = "stop_subscription";
|
||||
} // namespace
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
namespace openspace {
|
||||
@@ -91,12 +85,12 @@ void ShortcutTopic::sendData() const {
|
||||
}
|
||||
|
||||
void ShortcutTopic::handleJson(const nlohmann::json& input) {
|
||||
const std::string& event = input.at(EventKey).get<std::string>();
|
||||
if (event == StartSubscription) {
|
||||
const std::string& event = input.at("event").get<std::string>();
|
||||
if (event == "start_subscription") {
|
||||
// TODO: Subscribe to shortcuts and keybindings
|
||||
// shortcutManager.subscribe(); ...
|
||||
}
|
||||
else if (event == StopSubscription) {
|
||||
else if (event == "stop_subscription") {
|
||||
// TODO: Unsubscribe to shortcuts and keybindings
|
||||
// shortcutManager.unsubscribe(); ...
|
||||
return;
|
||||
|
||||
@@ -35,9 +35,8 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* EventKey = "event";
|
||||
constexpr const char* SubscribeEvent = "start_subscription";
|
||||
constexpr const char* UnsubscribeEvent = "stop_subscription";
|
||||
constexpr std::string_view SubscribeEvent = "start_subscription";
|
||||
constexpr std::string_view UnsubscribeEvent = "stop_subscription";
|
||||
} // namespace
|
||||
|
||||
using nlohmann::json;
|
||||
@@ -67,7 +66,7 @@ bool SkyBrowserTopic::isDone() const {
|
||||
}
|
||||
|
||||
void SkyBrowserTopic::handleJson(const nlohmann::json& json) {
|
||||
std::string event = json.at(EventKey).get<std::string>();
|
||||
std::string event = json.at("event").get<std::string>();
|
||||
if (event == UnsubscribeEvent) {
|
||||
_isDone = true;
|
||||
return;
|
||||
|
||||
@@ -33,12 +33,10 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "SubscriptionTopic";
|
||||
constexpr const char* PropertyKey = "property";
|
||||
constexpr const char* EventKey = "event";
|
||||
constexpr std::string_view _loggerCat = "SubscriptionTopic";
|
||||
|
||||
constexpr const char* StartSubscription = "start_subscription";
|
||||
constexpr const char* StopSubscription = "stop_subscription";
|
||||
constexpr std::string_view StartSubscription = "start_subscription";
|
||||
constexpr std::string_view StopSubscription = "stop_subscription";
|
||||
} // namespace
|
||||
|
||||
using nlohmann::json;
|
||||
@@ -68,10 +66,10 @@ void SubscriptionTopic::resetCallbacks() {
|
||||
}
|
||||
|
||||
void SubscriptionTopic::handleJson(const nlohmann::json& json) {
|
||||
const std::string& event = json.at(EventKey).get<std::string>();
|
||||
const std::string& event = json.at("event").get<std::string>();
|
||||
|
||||
if (event == StartSubscription) {
|
||||
std::string key = json.at(PropertyKey).get<std::string>();
|
||||
std::string key = json.at("property").get<std::string>();
|
||||
|
||||
_prop = property(key);
|
||||
resetCallbacks();
|
||||
|
||||
@@ -32,10 +32,9 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* EventKey = "event";
|
||||
constexpr const char* SubscribeEvent = "start_subscription";
|
||||
constexpr const char* UnsubscribeEvent = "stop_subscription";
|
||||
constexpr const std::chrono::milliseconds TimeUpdateInterval(50);
|
||||
constexpr std::string_view SubscribeEvent = "start_subscription";
|
||||
constexpr std::string_view UnsubscribeEvent = "stop_subscription";
|
||||
constexpr std::chrono::milliseconds TimeUpdateInterval(50);
|
||||
} // namespace
|
||||
|
||||
using nlohmann::json;
|
||||
@@ -65,7 +64,7 @@ bool TimeTopic::isDone() const {
|
||||
}
|
||||
|
||||
void TimeTopic::handleJson(const nlohmann::json& json) {
|
||||
std::string event = json.at(EventKey).get<std::string>();
|
||||
std::string event = json.at("event").get<std::string>();
|
||||
if (event == UnsubscribeEvent) {
|
||||
_isDone = true;
|
||||
return;
|
||||
|
||||
@@ -32,16 +32,14 @@
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* PropertyKey = "property";
|
||||
//constexpr const char* ValueKey = "value";
|
||||
constexpr const char* _loggerCat = "TriggerPropertyTopic";
|
||||
constexpr std::string_view _loggerCat = "TriggerPropertyTopic";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
void TriggerPropertyTopic::handleJson(const nlohmann::json& json) {
|
||||
try {
|
||||
const std::string& propertyKey = json.at(PropertyKey).get<std::string>();
|
||||
const std::string& propertyKey = json.at("property").get<std::string>();
|
||||
global::scriptEngine->queueScript(
|
||||
fmt::format(
|
||||
"openspace.setPropertyValueSingle(\"{}\", nil)", propertyKey
|
||||
|
||||
Reference in New Issue
Block a user