Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[glass] Storage: Use std::variant #7373

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datalogtool/src/main/native/cpp/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void Application(std::string_view saveDir) {
gui::Initialize("Datalog Tool", 925, 510);

gDownloadVisible =
&glass::GetStorageRoot().GetChild("download").GetBool("visible", true);
&glass::GetStorageRoot().GetChild("download").Get<bool>("visible", true);

gui::Main();

Expand Down
10 changes: 5 additions & 5 deletions datalogtool/src/main/native/cpp/Downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#include "Sftp.h"

Downloader::Downloader(glass::Storage& storage)
: m_serverTeam{storage.GetString("serverTeam")},
m_remoteDir{storage.GetString("remoteDir", "/home/lvuser/logs")},
m_username{storage.GetString("username", "lvuser")},
m_localDir{storage.GetString("localDir")},
m_deleteAfter{storage.GetBool("deleteAfter", true)},
: m_serverTeam{storage.Get<std::string>("serverTeam")},
m_remoteDir{storage.Get<std::string>("remoteDir", "/home/lvuser/logs")},
m_username{storage.Get<std::string>("username", "lvuser")},
m_localDir{storage.Get<std::string>("localDir")},
m_deleteAfter{storage.Get<bool>("deleteAfter", true)},
m_thread{[this] { ThreadMain(); }} {}

Downloader::~Downloader() {
Expand Down
2 changes: 1 addition & 1 deletion datalogtool/src/main/native/cpp/Exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ static void ExportCsv(std::string_view outputFolder, int style) {
}

void DisplayOutput(glass::Storage& storage) {
static std::string& outputFolder = storage.GetString("outputFolder");
static std::string& outputFolder = storage.Get<std::string>("outputFolder");
static std::unique_ptr<pfd::select_folder> outputFolderSelector;

SetNextWindowPos(ImVec2{380, 390}, ImGuiCond_FirstUseEver);
Expand Down
2 changes: 1 addition & 1 deletion glass/src/app/native/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ int main(int argc, char** argv) {

gui::Initialize("Glass - DISCONNECTED", 1024, 768,
ImGuiConfigFlags_DockingEnable);
gEnterKey = &glass::GetStorageRoot().GetInt("enterKey", GLFW_KEY_ENTER);
gEnterKey = &glass::GetStorageRoot().Get<int>("enterKey", GLFW_KEY_ENTER);
if (auto win = gui::GetSystemWindow()) {
gPrevKeyCallback = glfwSetKeyCallback(win, RemapEnterKeyCallback);
}
Expand Down
4 changes: 2 additions & 2 deletions glass/src/lib/native/cpp/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ void glass::EndChild() {
}

bool glass::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags) {
bool& open = GetStorage().GetChild(label).GetBool(
bool& open = GetStorage().GetChild(label).Get<bool>(
"open", (flags & ImGuiTreeNodeFlags_DefaultOpen) != 0);
ImGui::SetNextItemOpen(open);
open = ImGui::CollapsingHeader(label, flags);
Expand All @@ -492,7 +492,7 @@ bool glass::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags) {

bool glass::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags) {
PushStorageStack(label);
bool& open = GetStorage().GetBool(
bool& open = GetStorage().Get<bool>(
"open", (flags & ImGuiTreeNodeFlags_DefaultOpen) != 0);
ImGui::SetNextItemOpen(open);
open = ImGui::TreeNodeEx(label, flags);
Expand Down
4 changes: 3 additions & 1 deletion glass/src/lib/native/cpp/DataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "glass/DataSource.h"

#include <string>

#include <fmt/format.h>

#include "glass/ContextInternal.h"
Expand All @@ -13,7 +15,7 @@ using namespace glass;
wpi::sig::Signal<const char*, DataSource*> DataSource::sourceCreated;

DataSource::DataSource(std::string_view id)
: m_id{id}, m_name{gContext->sourceNameStorage.GetString(m_id)} {
: m_id{id}, m_name{gContext->sourceNameStorage.Get<std::string>(m_id)} {
gContext->sources.try_emplace(m_id, this);
sourceCreated(m_id.c_str(), this);
}
Expand Down
Loading
Loading