CCF
Loading...
Searching...
No Matches
untyped_map_handle.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
7#include "ccf/kv/version.h"
8
9#include <functional>
10#include <optional>
11#include <string>
12
13namespace ccf::kv::untyped
14{
15 struct ChangeSet;
16
18 {
19 public:
20 // Expose these types so that other code can use them as MyTx::KeyType or
21 // MyMap::MapHandle::KeyType, templated on the MapHandle or Map type
24
26 std::function<void(const KeyType& k, const ValueType& V)>;
27
29 std::function<bool(const KeyType& k, const ValueType& V)>;
30
31 protected:
33 std::string map_name;
34
42 const ValueType* read_key(const KeyType& key);
43
45 const ElementVisitorWithEarlyOut& fn, bool always_consider_writes);
46
47 public:
49
50 std::string get_name_of_map() const;
51
52 std::optional<ValueType> get(const KeyType& key);
53
54 std::optional<Version> get_version_of_previous_write(const KeyType& key);
55
56 std::optional<ValueType> get_globally_committed(const KeyType& key);
57
58 bool has(const KeyType& key);
59
60 bool has_globally_committed(const KeyType& key);
61
62 void put(const KeyType& key, const ValueType& value);
63
64 void remove(const KeyType& key);
65
66 void clear();
67
68 void foreach(const ElementVisitorWithEarlyOut& fn);
69
70 size_t size();
71
72 // Sub-range variant of foreach. Visits the range of keys in [from, to).
73 void range(
74 const ElementVisitor& fn,
75 const std::optional<KeyType>& from,
76 const std::optional<KeyType>& to);
77 };
78}
Definition abstract_handle.h:8
Definition untyped_map_handle.h:18
void clear()
Definition untyped_map_handle.cpp:175
void foreach_state_and_writes(const ElementVisitorWithEarlyOut &fn, bool always_consider_writes)
Definition untyped_map_handle.cpp:44
ccf::kv::untyped::ChangeSet & tx_changes
Definition untyped_map_handle.h:32
bool has(const KeyType &key)
Definition untyped_map_handle.cpp:145
bool has_globally_committed(const KeyType &key)
Definition untyped_map_handle.cpp:154
void put(const KeyType &key, const ValueType &value)
Definition untyped_map_handle.cpp:160
void range(const ElementVisitor &fn, const std::optional< KeyType > &from, const std::optional< KeyType > &to)
Definition untyped_map_handle.cpp:200
std::optional< Version > get_version_of_previous_write(const KeyType &key)
Definition untyped_map_handle.cpp:111
std::optional< ValueType > get(const KeyType &key)
Definition untyped_map_handle.cpp:96
const ValueType * read_key(const KeyType &key)
Definition untyped_map_handle.cpp:10
std::optional< ValueType > get_globally_committed(const KeyType &key)
Definition untyped_map_handle.cpp:131
ccf::kv::serialisers::SerialisedEntry ValueType
Definition untyped_map_handle.h:23
std::function< bool(const KeyType &k, const ValueType &V)> ElementVisitorWithEarlyOut
Definition untyped_map_handle.h:29
std::function< void(const KeyType &k, const ValueType &V)> ElementVisitor
Definition untyped_map_handle.h:26
size_t size()
Definition untyped_map_handle.cpp:188
void remove(const KeyType &key)
Definition untyped_map_handle.cpp:168
std::string map_name
Definition untyped_map_handle.h:33
std::string get_name_of_map() const
Definition untyped_map_handle.cpp:91
ccf::kv::serialisers::SerialisedEntry KeyType
Definition untyped_map_handle.h:22
ccf::ByteVector SerialisedEntry
Definition serialised_entry.h:8
Definition untyped.h:12
SerialisedEntry V
Definition untyped_change_set.h:23
Definition untyped_change_set.h:43