Hazelcast C++ Client
IQueue.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_MIXEDTYPE_IQUEUE_H_
17 #define HAZELCAST_CLIENT_MIXEDTYPE_IQUEUE_H_
18 
19 #include "hazelcast/client/proxy/IQueueImpl.h"
20 #include "hazelcast/client/ItemListener.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 mixedtype {
30 
35  class HAZELCAST_API IQueue : public proxy::IQueueImpl {
36  friend class client::HazelcastClient;
37 
38  public:
53  std::string addItemListener(MixedItemListener &listener, bool includeValue);
54 
63  bool removeItemListener(const std::string& registrationId);
64 
73  template <typename E>
74  bool offer(const E& element) {
75  return offer(element, 0);
76  }
77 
82  template <typename E>
83  void put(const E& element) {
84  proxy::IQueueImpl::put(toData(element));
85  }
86 
96  template <typename E>
97  bool offer(const E& element, long timeoutInMillis) {
98  return proxy::IQueueImpl::offer(toData(element), timeoutInMillis);
99  }
100 
105  TypedData take();
106 
112  TypedData poll(long timeoutInMillis);
113 
118  int remainingCapacity();
119 
125  template <typename E>
126  bool remove(const E& element) {
127  return proxy::IQueueImpl::remove(toData(element));
128  }
129 
135  template <typename E>
136  bool contains(const E& element) {
137  return proxy::IQueueImpl::contains(toData(element));
138  }
139 
146  size_t drainTo(std::vector<TypedData> &elements);
147 
155  size_t drainTo(std::vector<TypedData> &elements, int64_t maxElements);
156 
162  TypedData poll();
163 
169  TypedData peek();
170 
175  int size();
176 
181  bool isEmpty();
182 
187  std::vector<TypedData> toArray();
188 
195  template <typename E>
196  bool containsAll(const std::vector<E> &elements) {
197  std::vector<serialization::pimpl::Data> list = toDataCollection(elements);
198  return proxy::IQueueImpl::containsAll(list);
199  }
200 
207  template <typename E>
208  bool addAll(const std::vector<E>& elements) {
209  std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
210  return proxy::IQueueImpl::addAll(dataList);
211  }
212 
219  template <typename E>
220  bool removeAll(const std::vector<E>& elements) {
221  std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
222  return proxy::IQueueImpl::removeAll(dataList);
223  }
224 
232  template <typename E>
233  bool retainAll(const std::vector<E> &elements) {
234  std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
235  return proxy::IQueueImpl::retainAll(dataList);
236  }
237 
241  void clear();
242  private:
243  IQueue(const std::string& instanceName, spi::ClientContext *context);
244  };
245  }
246  }
247 }
248 
249 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
250 #pragma warning(pop)
251 #endif
252 
253 #endif /* HAZELCAST_CLIENT_MIXEDTYPE_IQUEUE_H_ */
254 
bool containsAll(const std::vector< E > &elements)
Definition: IQueue.h:196
bool contains(const E &element)
Definition: IQueue.h:136
void put(const E &element)
Puts the element into queue.
Definition: IQueue.h:83
bool offer(const E &element, long timeoutInMillis)
Inserts the specified element into this queue.
Definition: IQueue.h:97
bool offer(const E &element)
Inserts the specified element into this queue.
Definition: IQueue.h:74
bool retainAll(const std::vector< E > &elements)
Removes the elements from this queue that are not available in given "elements" vector.
Definition: IQueue.h:233
bool addAll(const std::vector< E > &elements)
Definition: IQueue.h:208
Item listener for IQueue, ISet and IList.
Definition: ItemListener.h:40
Concurrent, blocking, distributed, observable, client queue.
Definition: IQueue.h:35
Definition: MapEntryView.h:32
bool removeAll(const std::vector< E > &elements)
Definition: IQueue.h:220
TypedData class is a wrapper class for the serialized binary data.
Definition: TypedData.h:40
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster...
Definition: HazelcastClient.h:459