initial commit
This commit is contained in:
37
include/sequence_store.hpp
Normal file
37
include/sequence_store.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "model_value.hpp"
|
||||
#include "sequence.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
constexpr const char* kSequencesKey = "command_sequences_v1";
|
||||
|
||||
class SequenceRepository {
|
||||
public:
|
||||
using LoadCallback = std::function<bool(const std::string& key, DaliValue* out)>;
|
||||
using SaveCallback = std::function<bool(const std::string& key, const DaliValue& value)>;
|
||||
|
||||
SequenceRepository() = default;
|
||||
SequenceRepository(LoadCallback loadCb, SaveCallback saveCb)
|
||||
: loadCallback_(std::move(loadCb)), saveCallback_(std::move(saveCb)) {}
|
||||
|
||||
void setLoadCallback(LoadCallback cb) { loadCallback_ = std::move(cb); }
|
||||
void setSaveCallback(SaveCallback cb) { saveCallback_ = std::move(cb); }
|
||||
|
||||
bool load();
|
||||
bool save() const;
|
||||
|
||||
const std::vector<CommandSequence>& sequences() const { return sequences_; }
|
||||
|
||||
void add(const CommandSequence& s);
|
||||
void remove(const std::string& id);
|
||||
void replace(const CommandSequence& s);
|
||||
|
||||
private:
|
||||
std::vector<CommandSequence> sequences_;
|
||||
LoadCallback loadCallback_;
|
||||
SaveCallback saveCallback_;
|
||||
};
|
||||
Reference in New Issue
Block a user