PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
SnapshotManager.h
Go to the documentation of this file.
1// SnapshotManager.h - PEBL snapshot creation and management
2// Copyright (c) 2026 Shane T. Mueller
3// Licensed under GPL
4
5#ifndef SNAPSHOTMANAGER_H
6#define SNAPSHOTMANAGER_H
7
8#include <string>
9#include <vector>
10#include <memory>
11
12class Study;
13
14// Manages snapshot creation, validation, and import
16public:
19
20 // Create snapshot from study
21 // Returns snapshot directory name (e.g., "study-name_v1_2026-01-09")
22 std::string CreateSnapshot(const std::string& studyPath,
23 const std::string& snapshotsDir);
24
25 // Validate snapshot directory
27 bool isValid;
28 std::vector<std::string> errors;
29 std::vector<std::string> warnings;
30 };
31 ValidationResult ValidateSnapshot(const std::string& snapshotPath);
32
33 // Import snapshot into my_studies
34 bool ImportSnapshot(const std::string& snapshotPath,
35 const std::string& studiesDir,
36 const std::string& newStudyName);
37
38 // Get snapshot name format: studyname_vN_YYYY-MM-DD
39 static std::string GenerateSnapshotName(const std::string& studyName, int version);
40
41 // Extract study metadata from snapshot
42 struct SnapshotInfo {
43 std::string studyName;
45 std::string description;
46 std::string author;
47 std::string createdDate;
50 };
51 SnapshotInfo GetSnapshotInfo(const std::string& snapshotPath);
52
53 // Convert platform snapshot format to launcher format (in place)
54 bool ConvertSnapshotFormat(const std::string& studyPath);
55
56private:
57 bool CopyDirectory(const std::string& source, const std::string& dest, bool excludeData);
58 bool CopyFileContents(const std::string& source, const std::string& dest);
59 bool DirectoryExists(const std::string& path) const;
60 bool FileExists(const std::string& path) const;
61 std::string GetCurrentDateString() const; // Returns YYYY-MM-DD
62 bool ShouldExcludeFromSnapshot(const std::string& name, bool isDirectory) const;
63};
64
65#endif // SNAPSHOTMANAGER_H
SnapshotInfo GetSnapshotInfo(const std::string &snapshotPath)
std::string CreateSnapshot(const std::string &studyPath, const std::string &snapshotsDir)
static std::string GenerateSnapshotName(const std::string &studyName, int version)
bool ConvertSnapshotFormat(const std::string &studyPath)
bool ImportSnapshot(const std::string &snapshotPath, const std::string &studiesDir, const std::string &newStudyName)
ValidationResult ValidateSnapshot(const std::string &snapshotPath)
Definition Study.h:44
std::vector< std::string > errors
std::vector< std::string > warnings