Voltray Engine Docs
Loading...
Searching...
No Matches
Workspace.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <filesystem>
5#include <vector>
6#include <chrono>
7
26{
27 std::string name; // Display name of the workspace
28 std::string description; // Optional description
29 std::filesystem::path path; // Full path to workspace directory
30 std::chrono::system_clock::time_point lastOpened; // Last access time
31 std::chrono::system_clock::time_point created; // Creation time
32 bool isValid = true; // Whether the workspace path still exists
33
38 std::string ToJson() const;
39
45 static Workspace FromJson(const std::string &json);
46
51 bool IsPathValid() const;
52};
53
67{
68public:
73 static bool Initialize();
74
79 static std::vector<Workspace> GetAllWorkspaces();
80
88 static bool CreateWorkspace(const std::string &name, const std::filesystem::path &path, const std::string &description = "");
89
95 static bool RemoveWorkspace(const std::filesystem::path &workspacePath);
96
102 static bool UpdateLastOpened(const std::filesystem::path &workspacePath);
103
108 static const Workspace *GetCurrentWorkspace();
109
115 static bool SetCurrentWorkspace(const std::filesystem::path &workspacePath);
116
121 static bool SaveWorkspaces();
122
127 static bool LoadWorkspaces();
128
134 static bool IsValidWorkspaceDirectory(const std::filesystem::path &path);
135
140 static int CleanupInvalidWorkspaces();
141
142private:
143 static std::vector<Workspace> s_Workspaces; // All known workspaces
144 static Workspace *s_CurrentWorkspace; // Currently active workspace
145
150 static std::filesystem::path GetWorkspacesConfigFile();
151
157 static bool CreateWorkspaceStructure(const std::filesystem::path &path);
158
159 // Marker file that identifies a directory as a Voltray workspace
160 static constexpr const char *WORKSPACE_FILE_NAME = ".voltray_workspace";
161};
nlohmann::json json
Definition Workspace.cpp:9
Manages all workspace operations including creation, loading, and persistence.
Definition Workspace.h:67
static bool RemoveWorkspace(const std::filesystem::path &workspacePath)
Remove a workspace from the managed list (doesn't delete files)
Definition Workspace.cpp:354
static std::vector< Workspace > GetAllWorkspaces()
Get all available workspaces.
Definition Workspace.cpp:93
static bool LoadWorkspaces()
Load workspace list from persistent storage.
Definition Workspace.cpp:235
static bool UpdateLastOpened(const std::filesystem::path &workspacePath)
Update last opened time for a workspace.
Definition Workspace.cpp:340
static bool SetCurrentWorkspace(const std::filesystem::path &workspacePath)
Set the current active workspace.
Definition Workspace.cpp:323
static int CleanupInvalidWorkspaces()
Remove invalid workspaces from the list (paths that no longer exist)
Definition Workspace.cpp:282
static bool IsValidWorkspaceDirectory(const std::filesystem::path &path)
Check if a directory is a valid Voltray workspace.
Definition Workspace.cpp:187
static bool SaveWorkspaces()
Save workspace list to persistent storage.
Definition Workspace.cpp:199
static const Workspace * GetCurrentWorkspace()
Get the currently active workspace.
Definition Workspace.cpp:318
static bool Initialize()
Initialize the workspace manager and load existing workspaces.
Definition Workspace.cpp:70
static bool CreateWorkspace(const std::string &name, const std::filesystem::path &path, const std::string &description="")
Create a new workspace with standard directory structure.
Definition Workspace.cpp:98
Represents a workspace with its metadata and settings.
Definition Workspace.h:26
std::string description
Definition Workspace.h:28
std::chrono::system_clock::time_point created
Definition Workspace.h:31
static Workspace FromJson(const std::string &json)
Deserialize workspace from JSON string.
Definition Workspace.cpp:35
std::string name
Definition Workspace.h:27
bool isValid
Definition Workspace.h:32
std::chrono::system_clock::time_point lastOpened
Definition Workspace.h:30
bool IsPathValid() const
Check if the workspace path is valid and exists.
Definition Workspace.cpp:63
std::string ToJson() const
Serialize workspace to JSON string.
Definition Workspace.cpp:17
std::filesystem::path path
Definition Workspace.h:29