13 #include <immer/map.hpp>
14 #include <zug/transducer/filter.hpp>
15 #include <zug/transducer/eager.hpp>
16 #include <lager/deps.hpp>
17 #include <boost/container_hash/hash.hpp>
18 #include <boost/serialization/string.hpp>
29 template<
class K,
class V,
class List,
class Func>
30 immer::map<K, V>
merge(immer::map<K, V> map, List list, Func keyOf)
34 map = std::move(map).set(key, v);
60 template<
class Archive>
75 template<
class Context>
78 return lager::get<JobInterface &>(std::forward<Context>(ctx));
81 template<
class Context>
84 return lager::get<EventInterface &>(std::forward<Context>(ctx));
89 template<
class ImmerT>
92 using value_type =
typename ImmerT::value_type;
93 using reference =
typename ImmerT::reference;
94 using pointer =
const value_type *;
95 using difference_type =
long int;
96 using iterator_category = std::random_access_iterator_tag;
98 ImmerIterator(
const ImmerT &container, std::size_t index)
99 : m_container(
std::ref(container))
103 ImmerIterator &operator+=(difference_type d) {
108 ImmerIterator &operator-=(difference_type d) {
113 difference_type operator-(ImmerIterator b)
const {
114 return index() - b.index();
117 ImmerIterator &operator++() {
121 ImmerIterator operator++(
int) {
127 ImmerIterator &operator--() {
131 ImmerIterator operator--(
int) {
138 reference &operator*()
const {
139 return m_container.get().at(m_index);
142 reference operator[](difference_type d)
const;
144 std::size_t index()
const {
return m_index; }
148 std::reference_wrapper<const ImmerT> m_container;
152 template<
class ImmerT>
153 auto ImmerIterator<ImmerT>::operator[](difference_type d)
const -> reference
158 template<
class ImmerT>
159 auto operator+(ImmerIterator<ImmerT> a,
long int d)
164 template<
class ImmerT>
165 auto operator+(
long int d, ImmerIterator<ImmerT> a)
170 template<
class ImmerT>
171 auto operator-(ImmerIterator<ImmerT> a,
long int d)
176 template<
class ImmerT>
177 auto immerBegin(
const ImmerT &c)
179 return ImmerIterator<ImmerT>(c, 0);
182 template<
class ImmerT>
183 auto immerEnd(
const ImmerT &c)
185 return ImmerIterator<ImmerT>(c, c.size());
189 template<
class ImmerT1,
class RangeT2,
class Pred,
class Func>
193 zug::filter([=](
auto a) {
198 auto cmp = [=](
auto a,
auto b) {
199 return keyOf(a) < keyOf(b);
202 for (
auto item : needToAdd) {
203 auto it = std::upper_bound(immerBegin(base), immerEnd(base), item, cmp);
204 auto index = it.index();
205 base = std::move(base).insert(index, item);
213 std::string
getTxnId(Event event, ClientModel &m);
218 template<>
struct hash<
Kazv::KeyOfState>
221 std::size_t seed = 0;
222 boost::hash_combine(seed, k.type);
223 boost::hash_combine(seed, k.stateKey);
229 #define KAZV_WRAP_ATTR(_type, _d, _attr) \
230 inline auto _attr() const { \
231 KAZV_VERIFY_THREAD_ID(); \
232 return (_d)[&_type::_attr]; \
Definition: context.hpp:130
Definition: eventinterface.hpp:15
std::string stateKey() const
Definition: event.cpp:74
std::string type() const
Definition: event.cpp:62
std::string id() const
returns the id of this event
Definition: event.cpp:42
std::string sender() const
Definition: event.cpp:49
auto operator+(Cursor &&c)
Definition: cursorutil.hpp:122
Definition: location.hpp:10
std::string increaseTxnId(std::string cur)
Definition: clientutil.cpp:14
std::string keyOfAccountData(Event e)
Definition: clientutil.hpp:43
immer::map< K, V > merge(immer::map< K, V > map, List list, Func keyOf)
Definition: clientutil.hpp:30
bool operator==(BaseJob a, BaseJob b)
Definition: basejob.cpp:280
detail::IntoImmerT intoImmer
Definition: cursorutil.hpp:88
ImmerT1 sortedUniqueMerge(ImmerT1 base, RangeT2 addon, Pred exists, Func keyOf)
Definition: clientutil.hpp:190
std::string getTxnId(Event, ClientModel &m)
Definition: clientutil.cpp:19
KeyOfState keyOfState(Event e)
Definition: clientutil.hpp:71
std::string keyOfEphemeral(Event e)
Definition: clientutil.hpp:51
std::string keyOfPresence(Event e)
Definition: clientutil.hpp:39
std::string keyOfTimeline(Event e)
Definition: clientutil.hpp:47
void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
Definition: client-model.hpp:582
JobInterface & getJobHandler(Context &&ctx)
Definition: clientutil.hpp:76
EventInterface & getEventEmitter(Context &&ctx)
Definition: clientutil.hpp:82
Definition: clientutil.hpp:217
Definition: jobinterface.hpp:21
Definition: clientutil.hpp:56
std::string type
Definition: clientutil.hpp:57
std::string stateKey
Definition: clientutil.hpp:58
std::size_t operator()(const Kazv::KeyOfState &k) const noexcept
Definition: clientutil.hpp:220