Hazelcast C++ Client
 All Classes Functions Variables Enumerations Enumerator Pages
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 
21 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
22 #pragma warning(push)
23 #pragma warning(disable: 4251) //for dll export
24 #endif
25 
26 namespace hazelcast {
27  namespace client {
28  namespace internal {
29  namespace adapter {
33  template <typename K, typename V>
35  public:
36  IMapDataStructureAdapter(map::ClientMapProxy<K, V> &imap) : map(imap) {
37  }
38 
39  virtual ~IMapDataStructureAdapter() {
40  }
41 
42  void clear() {
43  map.clear();
44  }
45 
46  void set(const K &key, const V &value) {
47  map.set(key, value);
48  }
49 
50  boost::shared_ptr<V> put(const K &key, const V &value) {
51  return map.putIfAbsent(key, value);
52  }
53 
54  boost::shared_ptr<V> get(const K &key) {
55  return map.get(key);
56  }
57 
58 /*
59  connection::CallFuture getAsync(const K &key) {
60  }
61 */
62 
63  void putAll(const std::map<K, V> entries) {
64  map.putAll(entries);
65  }
66 
67  std::map<K, V> getAll(const std::set<K> &keys) {
68  return map.getAll(keys);
69  }
70 
71  void remove(const K &key) {
72  map.remove(key);
73  }
74 
75  bool containsKey(const K &key) const {
76  return map.containsKey(key);
77  }
78  private:
79  map::ClientMapProxy<K, V> &map;
80  };
81  }
82  }
83  }
84 }
85 
86 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
87 #pragma warning(pop)
88 #endif
89 
90 #endif /* HAZELCAST_CLIENT_INTERNAL_ADAPTER_IMAPDATASTRUCTUREADAPTER_H_ */
91 
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:34