Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
RawPointerTransactionalMap.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 ihsan demir on 24/03/16.
18 #ifndef HAZELCAST_CLIENT_ADAPTOR_RAWPOINTERRawPointerTransactionalMap_H_
19 #define HAZELCAST_CLIENT_ADAPTOR_RAWPOINTERRawPointerTransactionalMap_H_
20 
21 #include "hazelcast/client/TransactionalMap.h"
22 #include "hazelcast/client/impl/DataArrayImpl.h"
23 
24 namespace hazelcast {
25  namespace client {
26  namespace adaptor {
34  template<typename K, typename V>
36  public:
37  RawPointerTransactionalMap(TransactionalMap<K, V> &m) : map(m), serializationService(
38  m.context->getSerializationService()) {
39  }
40 
46  bool containsKey(const K &key) {
47  return map.containsKey(key);
48  }
49 
55  std::auto_ptr<V> get(const K &key) {
56  return serializationService.toObject<V>(map.getData(serializationService.toData<K>(&key)).get());
57  }
58 
64  int size() {
65  return map.size();
66  }
67 
73  bool isEmpty() {
74  return map.isEmpty();
75  }
76 
84  std::auto_ptr<V> put(const K &key, const V &value) {
85  return serializationService.toObject<V>(map.putData(serializationService.toData<K>(&key),
86  serializationService.toData<V>(&value)).get());
87  };
88 
96  void set(const K &key, const V &value) {
97  map.set(key, value);
98  }
99 
107  std::auto_ptr<V> putIfAbsent(const K &key, const V &value) {
108  return serializationService.toObject<V>(map.putIfAbsentData(serializationService.toData<K>(&key),
109  serializationService.toData<V>(
110  &value)).get());
111  };
112 
120  std::auto_ptr<V> replace(const K &key, const V &value) {
121  return serializationService.toObject<V>(map.replaceData(serializationService.toData<K>(&key),
122  serializationService.toData<V>(
123  &value)).get());
124  };
125 
133  bool replace(const K &key, const V &oldValue, const V &newValue) {
134  return map.replace(key, oldValue, newValue);
135  };
136 
144  std::auto_ptr<V> remove(const K &key) {
145  return serializationService.toObject<V>(map.removeData(serializationService.toData<K>(&key)).get());
146  };
147 
156  void deleteEntry(const K &key) {
157  map.deleteEntry(key);
158  };
159 
167  bool remove(const K &key, const V &value) {
168  return map.remove(key, value);
169  }
170 
177  std::auto_ptr<DataArray<K> > keySet() {
178  return std::auto_ptr<DataArray<K> >(new impl::DataArrayImpl<K>(map.keySetData(), serializationService));
179  }
180 
187  std::auto_ptr<DataArray<K> > keySet(const serialization::IdentifiedDataSerializable *predicate) {
188  return std::auto_ptr<DataArray<K> >(new impl::DataArrayImpl<K>(map.keySetData(predicate), serializationService));
189  }
190 
197  std::auto_ptr<DataArray<V> > values() {
198  return std::auto_ptr<DataArray<V> >(new impl::DataArrayImpl<V>(map.valuesData(), serializationService));
199  }
200 
206  std::auto_ptr<DataArray<V> > values(const serialization::IdentifiedDataSerializable *predicate) {
207  return std::auto_ptr<DataArray<V> >(new impl::DataArrayImpl<V>(map.valuesData(predicate), serializationService));
208  }
209 
210  private:
212  serialization::pimpl::SerializationService &serializationService;
213  };
214  }
215  }
216 }
217 
218 
219 #endif //HAZELCAST_CLIENT_ADAPTOR_RAWPOINTERRawPointerTransactionalMap_H_
220 
void set(const K &key, const V &value)
Transactional implementation of IMap::set(key, value).
Definition: RawPointerTransactionalMap.h:96
std::auto_ptr< DataArray< V > > values(const serialization::IdentifiedDataSerializable *predicate)
Transactional implementation of IMap::values(Predicate) .
Definition: RawPointerTransactionalMap.h:206
bool containsKey(const K &key)
Transactional implementation of IMap::containsKey(Object).
Definition: RawPointerTransactionalMap.h:46
std::auto_ptr< DataArray< K > > keySet(const serialization::IdentifiedDataSerializable *predicate)
Transactional implementation of IMap::keySet(Predicate) .
Definition: RawPointerTransactionalMap.h:187
Transactional implementation of IMap.
Definition: TransactionalMap.h:43
bool replace(const K &key, const V &oldValue, const V &newValue)
Transactional implementation of IMap::replace(key, value, oldValue).
Definition: RawPointerTransactionalMap.h:133
std::auto_ptr< V > put(const K &key, const V &value)
Transactional implementation of IMap::put(Object, Object).
Definition: RawPointerTransactionalMap.h:84
Classes that will be used with hazelcast data structures like IMap, IQueue etc should either inherit ...
Definition: IdentifiedDataSerializable.h:42
bool isEmpty()
Transactional implementation of IMap::isEmpty().
Definition: RawPointerTransactionalMap.h:73
std::auto_ptr< V > putIfAbsent(const K &key, const V &value)
Transactional implementation of IMap::putIfAbsent(key, value)
Definition: RawPointerTransactionalMap.h:107
Transactional implementation of IMap.
Definition: RawPointerTransactionalMap.h:35
void deleteEntry(const K &key)
Transactional implementation of IMap::delete(key).
Definition: RawPointerTransactionalMap.h:156
int size()
Transactional implementation of IMap::size().
Definition: RawPointerTransactionalMap.h:64
std::auto_ptr< DataArray< K > > keySet()
Transactional implementation of IMap::keySet().
Definition: RawPointerTransactionalMap.h:177
std::auto_ptr< DataArray< V > > values()
Transactional implementation of IMap::values().
Definition: RawPointerTransactionalMap.h:197
std::auto_ptr< V > replace(const K &key, const V &value)
Transactional implementation of IMap::replace(key, value).
Definition: RawPointerTransactionalMap.h:120