16 #ifndef HAZELCAST_IQUEUE
17 #define HAZELCAST_IQUEUE
19 #include "hazelcast/client/proxy/IQueueImpl.h"
20 #include "hazelcast/client/ItemListener.h"
21 #include "hazelcast/client/impl/ItemEventHandler.h"
23 #include "hazelcast/client/protocol/codec/QueueAddListenerCodec.h"
34 class IQueue :
public proxy::IQueueImpl {
53 spi::ClusterService& cs = context->getClusterService();
54 serialization::pimpl::SerializationService& ss = context->getSerializationService();
55 impl::ItemEventHandler<E, protocol::codec::QueueAddListenerCodec::AbstractEventHandler> *itemEventHandler =
56 new impl::ItemEventHandler<E, protocol::codec::QueueAddListenerCodec::AbstractEventHandler>(getName(), cs, ss, listener, includeValue);
57 return proxy::IQueueImpl::addItemListener(itemEventHandler, includeValue);
69 return proxy::IQueueImpl::removeItemListener(registrationId);
81 return offer(element, 0);
88 void put(
const E& e) {
101 bool offer(
const E& element,
long timeoutInMillis) {
102 return proxy::IQueueImpl::offer(toData(element), timeoutInMillis);
118 boost::shared_ptr<E>
poll(
long timeoutInMillis) {
119 return toObject<E>(proxy::IQueueImpl::poll(timeoutInMillis));
127 return proxy::IQueueImpl::remainingCapacity();
135 bool remove(
const E& element) {
136 return proxy::IQueueImpl::remove(toData(element));
145 return proxy::IQueueImpl::contains(toData(element));
165 int drainTo(std::vector<E>& elements,
int maxElements) {
166 std::vector<serialization::pimpl::Data> coll = proxy::IQueueImpl::drainTo(maxElements);
167 for (std::vector<serialization::pimpl::Data>::const_iterator it = coll.begin(); it != coll.end(); ++it) {
168 boost::shared_ptr<E> e = context->getSerializationService().template toObject<E>(*it);
169 elements.push_back(*e);
189 return toObject<E>(proxy::IQueueImpl::peek());
197 return proxy::IQueueImpl::size();
213 return toObjectCollection<E>(proxy::IQueueImpl::toArray());
223 std::vector<serialization::pimpl::Data> list = toDataCollection(elements);
224 return proxy::IQueueImpl::containsAll(list);
233 bool addAll(
const std::vector<E>& elements) {
234 std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
235 return proxy::IQueueImpl::addAll(dataList);
245 std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
246 return proxy::IQueueImpl::removeAll(dataList);
257 std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
258 return proxy::IQueueImpl::retainAll(dataList);
265 proxy::IQueueImpl::clear();
268 IQueue(
const std::string& instanceName, spi::ClientContext *context)
269 : proxy::IQueueImpl(instanceName, context){
void clear()
Removes all elements from queue.
Definition: IQueue.h:264
bool offer(const E &element, long timeoutInMillis)
Inserts the specified element into this queue.
Definition: IQueue.h:101
Concurrent, blocking, distributed, observable, client queue.
Definition: IQueue.h:34
bool offer(const E &element)
Inserts the specified element into this queue.
Definition: IQueue.h:80
std::vector< E > toArray()
Definition: IQueue.h:212
void put(const E &e)
Puts the element into queue.
Definition: IQueue.h:88
bool contains(const E &element)
Definition: IQueue.h:144
bool removeAll(const std::vector< E > &elements)
Definition: IQueue.h:244
int remainingCapacity()
Definition: IQueue.h:126
bool removeItemListener(const std::string ®istrationId)
Removes the specified item listener.
Definition: IQueue.h:68
std::string addItemListener(ItemListener< E > &listener, bool includeValue)
Adds an item listener for this collection.
Definition: IQueue.h:52
boost::shared_ptr< E > poll(long timeoutInMillis)
Definition: IQueue.h:118
int size()
Definition: IQueue.h:196
int drainTo(std::vector< E > &elements, int maxElements)
Note that elements will be pushed_back to vector.
Definition: IQueue.h:165
bool isEmpty()
Definition: IQueue.h:204
int drainTo(std::vector< E > &elements)
Note that elements will be pushed_back to vector.
Definition: IQueue.h:154
bool retainAll(const std::vector< E > &elements)
Removes the elements from this queue that are not available in given "elements" vector.
Definition: IQueue.h:256
boost::shared_ptr< E > peek()
Returns immediately without waiting.
Definition: IQueue.h:188
Item listener for IQueue, ISet and IList.
Definition: ItemListener.h:40
bool containsAll(const std::vector< E > &elements)
Definition: IQueue.h:222
bool addAll(const std::vector< E > &elements)
Definition: IQueue.h:233
boost::shared_ptr< E > poll()
Returns immediately without waiting.
Definition: IQueue.h:179
boost::shared_ptr< E > take()
Definition: IQueue.h:109
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster...
Definition: HazelcastClient.h:410