Hazelcast C++ Client
Hazelcast C++ Client Library
transactional_map.h
1 /*
2  * Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include "hazelcast/client/proxy/TransactionalMapImpl.h"
19 
20 namespace hazelcast {
21  namespace client {
27  class HAZELCAST_API transactional_map : public proxy::TransactionalMapImpl {
28  friend class transaction_context;
29  public:
35  template<typename K>
36  boost::future<bool> contains_key(const K &key) {
37  return contains_key_data(to_data(key));
38  }
39 
45  template<typename K, typename V>
46  boost::future<boost::optional<V>> get(const K &key) {
47  return to_object<V>(get_data(to_data(key)));
48  }
49 
57  template<typename K, typename V, typename R=V>
58  boost::future<boost::optional<R>> put(const K &key, const V &value) {
59  return to_object<R>(put_data(to_data(key), to_data(value)));
60  }
61 
69  template<typename K, typename V>
70  boost::future<void> set(const K &key, const V &value) {
71  return set_data(to_data(key), to_data(value));
72  }
73 
81  template<typename K, typename V, typename R=V>
82  boost::future<boost::optional<R>> put_if_absent(const K &key, const V &value) {
83  return to_object<R>(put_if_absent_data(to_data(key), to_data(value)));
84  }
85 
93  template<typename K, typename V, typename R=V>
94  boost::future<boost::optional<R>> replace(const K &key, const V &value) {
95  return to_object<R>(replace_data(to_data(key), to_data(value)));
96  }
97 
105  template<typename K, typename V, typename N>
106  boost::future<bool> replace(const K &key, const V &old_value, const N &new_value) {
107  return replace_data(to_data(key), to_data(old_value), to_data(new_value));
108  }
109 
117  template<typename K, typename V>
118  boost::future<boost::optional<V>> remove(const K &key) {
119  return to_object<V>(remove_data(to_data(key)));
120  }
121 
129  template<typename K>
130  boost::future<void> delete_entry(const K &key) {
131  return delete_entry_data(to_data(key));
132  }
133 
141  template<typename K, typename V>
142  boost::future<bool> remove(const K &key, const V &value) {
143  return remove_data(to_data(key), to_data(value));
144  }
145 
152  template<typename K>
153  boost::future<std::vector<K>> key_set() {
154  return to_object_vector<K>(key_set_data());
155  }
156 
163  template<typename K, typename P>
164  boost::future<std::vector<K>> key_set(const P &predicate) {
165  return to_object_vector<K>(key_set_data(to_data(predicate)));
166  }
167 
174  template<typename V>
175  boost::future<std::vector<V>> values() {
176  return to_object_vector<V>(values_data());
177  }
178 
184  template<typename V, typename P>
185  boost::future<std::vector<V>> values(const P &predicate) {
186  return to_object_vector<V>(values_data(to_data(predicate)));
187  }
188 
189  private:
190  transactional_map(const std::string &name, txn::TransactionProxy &transaction_proxy)
191  : proxy::TransactionalMapImpl(name, transaction_proxy) {}
192  };
193  }
194 }
195 
Provides a context to do transactional operations; so beginning/committing transactions,...
Transactional implementation of imap.
boost::future< boost::optional< R > > replace(const K &key, const V &value)
Transactional implementation of imap::replace(key, value).
boost::future< std::vector< V > > values(const P &predicate)
Transactional implementation of imap::values(Predicate) .
boost::future< bool > remove(const K &key, const V &value)
Transactional implementation of imap::remove(key, value).
boost::future< std::vector< K > > key_set(const P &predicate)
Transactional implementation of imap::keySet(Predicate) .
boost::future< boost::optional< V > > remove(const K &key)
Transactional implementation of imap::remove(key).
boost::future< bool > contains_key(const K &key)
Transactional implementation of imap::contains_key(Object).
boost::future< void > delete_entry(const K &key)
Transactional implementation of imap::delete(key).
boost::future< boost::optional< R > > put_if_absent(const K &key, const V &value)
Transactional implementation of imap::putIfAbsent(key, value)
boost::future< std::vector< V > > values()
Transactional implementation of imap::values().
boost::future< boost::optional< R > > put(const K &key, const V &value)
Transactional implementation of imap::put(Object, Object).
boost::future< std::vector< K > > key_set()
Transactional implementation of imap::keySet().
boost::future< void > set(const K &key, const V &value)
Transactional implementation of imap::set(key, value).
boost::future< boost::optional< V > > get(const K &key)
Transactional implementation of imap::get(Object).
boost::future< bool > replace(const K &key, const V &old_value, const N &new_value)
Transactional implementation of imap::replace(key, value, oldValue).