You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
821 B
30 lines
821 B
#pragma once |
|
|
|
#include "application/interfaces/IItemRepository.h" |
|
#include <string> |
|
#include <vector> |
|
#include <mutex> |
|
|
|
namespace nxl::autostore::infrastructure { |
|
|
|
class FileItemRepository : public application::IItemRepository |
|
{ |
|
public: |
|
explicit FileItemRepository(std::string_view dbPath); |
|
domain::Item::Id_t save(const domain::Item& item) override; |
|
std::optional<domain::Item> findById(domain::Item::Id_t id) override; |
|
std::vector<domain::Item> findByOwner(domain::User::Id_t userId) override; |
|
std::vector<domain::Item> |
|
findWhere(std::function<bool(const domain::Item&)> predicate) override; |
|
void remove(domain::Item::Id_t id) override; |
|
|
|
private: |
|
void load(); |
|
void persist(); |
|
|
|
std::string dbPath; |
|
std::vector<domain::Item> items; |
|
std::mutex mtx; |
|
}; |
|
|
|
} // namespace nxl::autostore::infrastructure
|