Hazelcast C++ Client
ReplicatedMap.h
1 /*
2  * Copyright (c) 2008-2018, 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 #ifndef HAZELCAST_CLIENT_REPLICATED_MAP_H_
18 #define HAZELCAST_CLIENT_REPLICATED_MAP_H_
19 
20 #include <stdint.h>
21 #include <string>
22 
23 #include <boost/shared_ptr.hpp>
24 
25 #include "hazelcast/client/DistributedObject.h"
26 #include "hazelcast/client/EntryListener.h"
27 #include "hazelcast/client/query/Predicate.h"
28 #include "hazelcast/client/DataArray.h"
29 #include "hazelcast/client/LazyEntryArray.h"
30 
31 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
32 #pragma warning(push)
33 #pragma warning(disable: 4251) //for dll export
34 #endif
35 
36 namespace hazelcast {
37  namespace client {
38 
52  template <typename K, typename V>
53  class ReplicatedMap : public virtual DistributedObject {
54  public:
67  virtual boost::shared_ptr<V> put(const K &key, const V &value, int64_t ttl) = 0;
68 
79  virtual void putAll(const std::map<K, V> &entries) = 0;
80 
86  virtual void clear() = 0;
87 
95  virtual bool removeEntryListener(const std::string &registrationId) = 0;
96 
103  virtual std::string addEntryListener(const boost::shared_ptr<EntryListener<K, V> > &listener) = 0;
104 
117  virtual std::string addEntryListener(const boost::shared_ptr<EntryListener<K, V> > &listener, const K &key) = 0;
118 
126  virtual const std::string addEntryListener(const boost::shared_ptr<EntryListener<K, V> > &listener,
127  const query::Predicate &predicate) = 0;
128 
137  virtual std::string addEntryListener(const boost::shared_ptr<EntryListener<K, V> > &listener,
138  const query::Predicate &predicate, const K &key) = 0;
139 
153  virtual boost::shared_ptr<DataArray<V> > values() = 0;
154 
167  virtual boost::shared_ptr<LazyEntryArray<K, V> > entrySet() = 0;
168 
181  virtual boost::shared_ptr<DataArray<K> > keySet() = 0;
182 
187  virtual int32_t size() = 0;
188 
193  virtual bool isEmpty() = 0;
194 
200  virtual bool containsKey(const K &key) = 0;
201 
207  virtual bool containsValue(const V &value) = 0;
208 
214  virtual boost::shared_ptr<V> get(const K &key) = 0;
215 
222  virtual boost::shared_ptr<V> put(const K &key, const V &value) = 0;
223 
229  virtual boost::shared_ptr<V> remove(const K &key) = 0;
230  };
231  }
232 }
233 
234 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
235 #pragma warning(pop)
236 #endif
237 
238 #endif //HAZELCAST_CLIENT_REPLICATED_MAP_H_
239 
Map Entry listener to get notified when a map entry is added, removed, updated or evicted...
Definition: EntryListener.h:45
virtual boost::shared_ptr< DataArray< K > > keySet()=0
Returns a lazy DataArray view of the key contained in this map.
virtual boost::shared_ptr< DataArray< V > > values()=0
Due to the lazy nature of the returned array, changes to the map (addition, removal, update) might be reflected on the collection.
Definition: ReplicatedMap.h:53
Base class for all distributed objects.
Definition: DistributedObject.h:58
virtual std::string addEntryListener(const boost::shared_ptr< EntryListener< K, V > > &listener)=0
Adds an entry listener for this map.
virtual bool removeEntryListener(const std::string &registrationId)=0
Removes the specified entry listener.
virtual boost::shared_ptr< LazyEntryArray< K, V > > entrySet()=0
Returns a lazy LazyEntryArray view of the mappings contained in this map.
This is a marker class for Predicate classes.
Definition: Predicate.h:36
virtual bool containsKey(const K &key)=0
PN (Positive-Negative) CRDT counter.
Definition: MapEntryView.h:32
virtual bool containsValue(const V &value)=0
virtual void putAll(const std::map< K, V > &entries)=0
Copies all of the mappings from the specified map to this map (optional operation).
virtual boost::shared_ptr< V > put(const K &key, const V &value, int64_t ttl)=0