Hazelcast C++ Client
IMapDataStructureAdapter.h
1 /*
2  * Copyright (c) 2008-2017, 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 #ifndef HAZELCAST_CLIENT_INTERNAL_ADAPTER_IMAPDATASTRUCTUREADAPTER_H_
17 #define HAZELCAST_CLIENT_INTERNAL_ADAPTER_IMAPDATASTRUCTUREADAPTER_H_
18 
19 #include "hazelcast/client/internal/adapter/DataStructureAdapter.h"
20 #include "hazelcast/client/map/ClientMapProxy.h"
21 
22 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
23 #pragma warning(push)
24 #pragma warning(disable: 4251) //for dll export
25 #endif
26 
27 namespace hazelcast {
28  namespace client {
29  namespace internal {
30  namespace adapter {
34  template <typename K, typename V>
36  public:
37  IMapDataStructureAdapter(map::ClientMapProxy<K, V> &imap) : map(imap) {
38  }
39 
40  virtual ~IMapDataStructureAdapter() {
41  }
42 
43  void clear() {
44  map.clear();
45  }
46 
47  void set(const K &key, const V &value) {
48  map.set(key, value);
49  }
50 
51  boost::shared_ptr<V> put(const K &key, const V &value) {
52  return map.putIfAbsent(key, value);
53  }
54 
55  boost::shared_ptr<V> get(const K &key) {
56  return map.get(key);
57  }
58 
59 /*
60  connection::CallFuture getAsync(const K &key) {
61  }
62 */
63 
64  void putAll(const std::map<K, V> entries) {
65  map.putAll(entries);
66  }
67 
68  std::map<K, V> getAll(const std::set<K> &keys) {
69  return map.getAll(keys);
70  }
71 
72  void remove(const K &key) {
73  map.remove(key);
74  }
75 
76  bool containsKey(const K &key) const {
77  return map.containsKey(key);
78  }
79  private:
80  map::ClientMapProxy<K, V> &map;
81  };
82  }
83  }
84  }
85 }
86 
87 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
88 #pragma warning(pop)
89 #endif
90 
91 #endif /* HAZELCAST_CLIENT_INTERNAL_ADAPTER_IMAPDATASTRUCTUREADAPTER_H_ */
92 
Abstracts the Hazelcast data structures with Near Cache support for the Near Cache usage...
Definition: DataStructureAdapter.h:37
Abstracts the Hazelcast data structures with Near Cache support for the Near Cache usage...
Definition: IMapDataStructureAdapter.h:35
Definition: MapEntryView.h:32