Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
TransactionalMap.h
1 /*
2  * Copyright (c) 2008-2015, 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 //
17 // Created by sancar koyunlu on 8/5/13.
18 
19 
20 
21 
22 
23 #ifndef HAZELCAST_TransactionalMap
24 #define HAZELCAST_TransactionalMap
25 
26 #include "hazelcast/client/proxy/TransactionalMapImpl.h"
27 
28 namespace hazelcast {
29  namespace serialization {
30  namespace pimpl {
31  class Data;
32  }
33  }
34  namespace client {
35 
43  template<typename K, typename V>
44  class TransactionalMap : public proxy::TransactionalMapImpl {
45  friend class TransactionContext;
46 
47  public:
53  bool containsKey(const K& key) {
54  return proxy::TransactionalMapImpl::containsKey(toData(&key));
55  }
56 
62  boost::shared_ptr<V> get(const K& key) {
63  return toObject<V>(proxy::TransactionalMapImpl::get(toData(&key)));
64  }
65 
71  int size() {
72  return proxy::TransactionalMapImpl::size();
73  }
74 
80  bool isEmpty() {
81  return size() == 0;
82  }
83 
91  boost::shared_ptr<V> put(const K& key, const V& value) {
92  return toObject<V>(proxy::TransactionalMapImpl::put(toData(&key), toData(&value)));
93  };
94 
102  void set(const K& key, const V& value) {
103  proxy::TransactionalMapImpl::set(toData(&key), toData(&value));
104  }
105 
113  boost::shared_ptr<V> putIfAbsent(const K& key, const V& value) {
114  return toObject<V>(proxy::TransactionalMapImpl::putIfAbsent(toData(&key), toData(&value)));
115  };
116 
124  boost::shared_ptr<V> replace(const K& key, const V& value) {
125  return toObject<V>(proxy::TransactionalMapImpl::replace(toData(&key), toData(&value)));
126  };
127 
135  bool replace(const K& key, const V& oldValue, const V& newValue) {
136  return proxy::TransactionalMapImpl::replace(toData(&key), toData(&oldValue), toData(&newValue));
137  };
138 
146  boost::shared_ptr<V> remove(const K& key) {
147  return toObject<V>(proxy::TransactionalMapImpl::remove(toData(&key)));
148  };
149 
158  void deleteEntry(const K& key) {
159  proxy::TransactionalMapImpl::deleteEntry(toData(&key));
160  };
161 
169  bool remove(const K& key, const V& value) {
170  return proxy::TransactionalMapImpl::remove(toData(&key), toData(&value));
171  }
172 
179  std::vector<K> keySet() {
180  return toObjectCollection<K>(proxy::TransactionalMapImpl::keySet());
181  }
182 
189  std::vector<K> keySet(const serialization::IdentifiedDataSerializable *predicate) {
190  return toObjectCollection<K>(proxy::TransactionalMapImpl::keySet(predicate));
191  }
192 
199  std::vector<V> values() {
200  return toObjectCollection<K>(proxy::TransactionalMapImpl::values());
201  }
202 
208  std::vector<V> values(const serialization::IdentifiedDataSerializable *predicate) {
209  return toObjectCollection<K>(proxy::TransactionalMapImpl::values(predicate));
210  }
211 
212  private:
213  TransactionalMap(const std::string& name, txn::TransactionProxy *transactionProxy)
214  : proxy::TransactionalMapImpl(name, transactionProxy) {
215 
216  }
217 
218  };
219  }
220 }
221 
222 
223 #endif //HAZELCAST_TransactionalMap
224 
bool isEmpty()
Transactional implementation of IMap::isEmpty().
Definition: TransactionalMap.h:80
void set(const K &key, const V &value)
Transactional implementation of IMap::set(key, value).
Definition: TransactionalMap.h:102
bool replace(const K &key, const V &oldValue, const V &newValue)
Transactional implementation of IMap::replace(key, value, oldValue).
Definition: TransactionalMap.h:135
Transactional implementation of IMap.
Definition: TransactionalMap.h:44
boost::shared_ptr< V > put(const K &key, const V &value)
Transactional implementation of IMap::put(Object, Object).
Definition: TransactionalMap.h:91
std::vector< V > values(const serialization::IdentifiedDataSerializable *predicate)
Transactional implementation of IMap::values(Predicate) .
Definition: TransactionalMap.h:208
bool containsKey(const K &key)
Transactional implementation of IMap::containsKey(Object).
Definition: TransactionalMap.h:53
Classes that will be used with hazelcast data structures like IMap, IQueue etc should either inherit ...
Definition: IdentifiedDataSerializable.h:42
std::vector< K > keySet(const serialization::IdentifiedDataSerializable *predicate)
Transactional implementation of IMap::keySet(Predicate) .
Definition: TransactionalMap.h:189
void deleteEntry(const K &key)
Transactional implementation of IMap::delete(key).
Definition: TransactionalMap.h:158
int size()
Transactional implementation of IMap::size().
Definition: TransactionalMap.h:71
boost::shared_ptr< V > replace(const K &key, const V &value)
Transactional implementation of IMap::replace(key, value).
Definition: TransactionalMap.h:124
boost::shared_ptr< V > putIfAbsent(const K &key, const V &value)
Transactional implementation of IMap::putIfAbsent(key, value)
Definition: TransactionalMap.h:113
std::vector< K > keySet()
Transactional implementation of IMap::keySet().
Definition: TransactionalMap.h:179
std::vector< V > values()
Transactional implementation of IMap::values().
Definition: TransactionalMap.h:199
Provides a context to do transactional operations; so beginning/committing transactions, but also retrieving transactional data-structures like the TransactionalMap.
Definition: TransactionContext.h:57