Extract Shade struct and create ShadeRepository

This commit is contained in:
2024-05-04 15:40:58 +10:00
parent eee6cbef46
commit a9dccae331
5 changed files with 386 additions and 123 deletions

View File

@@ -0,0 +1,25 @@
#ifndef SHADE_REPOSITORY_H
#define SHADE_REPOSITORY_H
#include <vector>
#include <functional>
#include "Shade.h"
class ShadeRepository {
private:
std::vector<Shade> shades;
std::vector<std::function<void(Shade&)>> shadeAddedCallbacks;
std::vector<std::function<void(Shade&)>> shadeChangedCallbacks;
public:
void upsert(Shade shade);
std::vector<Shade>::iterator begin();
std::vector<Shade>::iterator end();
Shade* findById(const uint16_t id);
Shade* findByKey(const std::string& key);
void addShadeAddedCallback(std::function<void(Shade&)> callback);
void addShadeChangedCallback(std::function<void(Shade&)> callback);
};
#endif // SHADE_REPOSITORY_H