PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
WorkspaceManager.h
Go to the documentation of this file.
1// WorkspaceManager.h - PEBL workspace initialization and management
2// Copyright (c) 2026 Shane T. Mueller
3// Licensed under GPL
4
5#ifndef WORKSPACEMANAGER_H
6#define WORKSPACEMANAGER_H
7
8#include <string>
9#include <vector>
10
11// Fallback if not defined by build system via -DPEBL_VERSION=...
12#ifndef PEBL_VERSION
13#define PEBL_VERSION "2.4"
14#endif
15
16// Manages PEBL workspace directory structure in Documents/pebl-exp.2.4/
18public:
21
22 // Check if running in portable mode
23 bool IsPortableMode() const;
24
25 // Check if this is first run (workspace doesn't exist)
26 bool IsFirstRun() const;
27
28 // Initialize workspace (creates directories on first run)
29 bool Initialize();
30
31 // Copy resources from installation (docs, demos, tutorials)
32 bool CopyResources(const std::string& installationPath);
33
34 // Check if workspace is initialized
35 bool IsInitialized() const;
36
37 // Set workspace path (override auto-detected path, e.g. from saved config)
38 void SetWorkspacePath(const std::string& path) { mWorkspacePath = path; }
39
40 // Get workspace paths
41 std::string GetWorkspacePath() const { return mWorkspacePath; }
42 std::string GetStudiesPath() const { return mWorkspacePath + "/my_studies"; }
43 std::string GetSnapshotsPath() const { return mWorkspacePath + "/snapshots"; }
44 std::string GetChainsPath() const { return mWorkspacePath + "/chains"; }
45 std::string GetScalesPath() const { return mWorkspacePath + "/scales"; }
46 std::string GetDocsPath() const { return mWorkspacePath + "/doc"; }
47 std::string GetDemoPath() const { return mWorkspacePath + "/demo"; }
48 std::string GetTutorialPath() const { return mWorkspacePath + "/tutorial"; }
49
50 // Get list of studies
51 std::vector<std::string> GetStudyDirectories() const;
52
53 // Get list of snapshots
54 std::vector<std::string> GetSnapshotDirectories() const;
55
56 // Create new study directory
57 bool CreateStudyDirectory(const std::string& studyName);
58
59 // Create snapshot from study
60 bool CreateSnapshot(const std::string& studyPath, const std::string& snapshotName);
61
62 // Import snapshot into my_studies
63 bool ImportSnapshot(const std::string& snapshotPath, const std::string& newStudyName);
64
65private:
66 bool CreateDir(const std::string& path);
67 bool DirectoryExists(const std::string& path) const;
68 bool FileExists(const std::string& path) const;
69 bool CopyDirectory(const std::string& source, const std::string& dest, bool excludeData = false, const std::vector<std::string>& excludeDirs = {});
70 bool CopyFileContents(const std::string& source, const std::string& dest);
71 std::string GetDocumentsPath() const;
72 std::string GetPortableWorkspacePath() const;
73
74 std::string mWorkspacePath; // e.g., /home/user/Documents/pebl-exp.2.4
75 bool mInitialized;
76};
77
78#endif // WORKSPACEMANAGER_H
std::string GetTutorialPath() const
bool CreateSnapshot(const std::string &studyPath, const std::string &snapshotName)
std::string GetDemoPath() const
std::string GetWorkspacePath() const
std::string GetChainsPath() const
bool CopyResources(const std::string &installationPath)
void SetWorkspacePath(const std::string &path)
bool ImportSnapshot(const std::string &snapshotPath, const std::string &newStudyName)
std::string GetScalesPath() const
std::string GetStudiesPath() const
std::string GetDocsPath() const
bool IsInitialized() const
bool IsPortableMode() const
std::vector< std::string > GetSnapshotDirectories() const
std::vector< std::string > GetStudyDirectories() const
std::string GetSnapshotsPath() const
bool CreateStudyDirectory(const std::string &studyName)