25 #ifndef TASKOLIB_SEQUENCEMANAGER_H_
26 #define TASKOLIB_SEQUENCEMANAGER_H_
32 #include <gul14/optional.h>
33 #include <gul14/string_view.h>
34 #include <libgit4cpp/Repository.h>
68 std::filesystem::path
path;
75 return a.unique_id == b.unique_id && a.name == b.name && a.path == b.path;
201 static gul14::optional<SequenceOnDisk>
317 template <
typename T>
320 auto commit_body = std::string{ };
323 if constexpr (std::is_same<decltype(action()),
void>::value)
326 auto path = action();
330 if (not extra_dir.empty())
332 if (commit_body.empty())
334 git_repo_.commit(gul14::cat(message,
"\n", commit_body));
336 catch (std::exception
const& e) {
380 const std::vector<SequenceOnDisk>& sequences);
Declaration of the UniqueId class.
A class for listing, loading, storing, and renaming sequences in a given file system directory.
Definition: SequenceManager.h:61
bool perform_commit(std::string message, T action, std::string extra_dir="")
Perform changes and commit them to the git repository.
Definition: SequenceManager.h:318
SequenceManager(std::filesystem::path path)
Create a SequenceManager to manage sequences that are stored in a given directory.
Definition: SequenceManager.cc:143
Sequence load_sequence(UniqueId uid) const
Load a sequence from the base folder.
Definition: SequenceManager.cc:257
git::Repository git_repo_
Git repository in path_ that holds the sequences.
Definition: SequenceManager.h:267
Sequence import_sequence(const std::filesystem::path &path)
Import a sequence from a folder, assigning a new unique ID to it.
Definition: SequenceManager.cc:215
void rename_sequence(UniqueId unique_id, const SequenceName &new_name)
Change the machine-friendly name of a sequence on disk.
Definition: SequenceManager.cc:375
std::filesystem::path get_path() const
Return the base path of the serialized sequences.
Definition: SequenceManager.h:129
static UniqueId create_unique_id(const std::vector< SequenceOnDisk > &sequences)
Create a random unique ID that does not collide with the ID of any sequence in the given sequence lis...
Definition: SequenceManager.cc:189
Sequence create_sequence(gul14::string_view label="", SequenceName name=SequenceName{})
Create an empty sequence on disk.
Definition: SequenceManager.cc:173
static SequenceName make_sequence_name_from_label(gul14::string_view label)
Generate a machine-friendly sequence name from a human-readable label.
Definition: SequenceManager.cc:315
Sequence copy_sequence(UniqueId original_uid, const SequenceName &new_name)
Create a copy of an existing sequence (from disk).
Definition: SequenceManager.cc:152
std::string stage_files(const std::string &glob)
Stage files matching the specified glob for the next git commit.
Definition: SequenceManager.cc:434
bool store_sequence(const Sequence &sequence)
Store the given sequence in a subfolder under the base directory of this object.
Definition: SequenceManager.cc:405
static gul14::optional< SequenceOnDisk > parse_folder_name(const std::filesystem::path &folder)
Determine the name and unique ID of a sequence from a folder name, if possible.
Definition: SequenceManager.cc:333
std::filesystem::path path_
Base path to the sequences.
Definition: SequenceManager.h:264
std::string stage_files_in_directory(const std::string &directory)
Stage all changes to files in the given directory for the next git commit.
Definition: SequenceManager.cc:485
std::vector< SequenceOnDisk > list_sequences() const
Return an unsorted list of all valid sequences that are found in the base path.
Definition: SequenceManager.cc:232
std::string write_sequence_to_disk(const Sequence &sequence)
Actually write a sequence to disk (without commit in git)
Definition: SequenceManager.cc:413
void remove_sequence(UniqueId unique_id)
Remove a sequence from the base folder.
Definition: SequenceManager.cc:355
static SequenceOnDisk find_sequence_on_disk(UniqueId uid, const std::vector< SequenceOnDisk > &sequences)
Find the sequence with the given unique ID in the given list of sequences.
Definition: SequenceManager.cc:203
The machine-readable name of a Sequence.
Definition: SequenceName.h:44
A sequence of steps that can be modified and executed.
Definition: Sequence.h:160
An unsigned 64-bit integer for use as a unique ID.
Definition: UniqueId.h:40
Namespace task contains all Taskolib functions and classes.
Definition: CommChannel.h:33
A struct to represent a sequence on disk.
Definition: SequenceManager.h:65
UniqueId unique_id
Unique ID of the sequence.
Definition: SequenceManager.h:71
std::filesystem::path path
Path to the sequence (usually relative to SequenceManager base path, but can also be absolute)
Definition: SequenceManager.h:68
friend bool operator==(const SequenceOnDisk &a, const SequenceOnDisk &b) noexcept
Definition: SequenceManager.h:73
SequenceName name
Machine-friendly name of the sequence.
Definition: SequenceManager.h:70
friend bool operator!=(const SequenceOnDisk &a, const SequenceOnDisk &b) noexcept
Definition: SequenceManager.h:78