bolar_2 backup
This commit is contained in:
35
main/friend/friend_store.h
Normal file
35
main/friend/friend_store.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "friend/friend_types.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
|
||||
namespace borla {
|
||||
|
||||
struct FriendStoreSnapshot {
|
||||
std::array<char, kFriendNameCapacity> device_name{};
|
||||
std::array<FriendPeer, kMaximumFriendCount> friends{};
|
||||
size_t friend_count = 0;
|
||||
FriendPeer pending_upload{};
|
||||
bool has_pending_upload = false;
|
||||
};
|
||||
|
||||
class IFriendStore {
|
||||
public:
|
||||
virtual ~IFriendStore() = default;
|
||||
virtual bool Load(FriendStoreSnapshot* snapshot) const = 0;
|
||||
virtual bool Save(const FriendStoreSnapshot& snapshot) const = 0;
|
||||
};
|
||||
|
||||
class NvsFriendStore final : public IFriendStore {
|
||||
public:
|
||||
bool Load(FriendStoreSnapshot* snapshot) const override;
|
||||
bool Save(const FriendStoreSnapshot& snapshot) const override;
|
||||
};
|
||||
|
||||
bool AddOrUpdateFriend(
|
||||
FriendStoreSnapshot* snapshot,
|
||||
const FriendPeer& peer);
|
||||
|
||||
} // namespace borla
|
||||
Reference in New Issue
Block a user