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"
22 #include "hazelcast/client/protocol/codec/QueueAddListenerCodec.h"
29 class RawPointerQueue;
38 class IQueue :
public proxy::IQueueImpl {
58 spi::ClusterService& cs = context->getClusterService();
59 serialization::pimpl::SerializationService& ss = context->getSerializationService();
60 impl::ItemEventHandler<E, protocol::codec::QueueAddListenerCodec::AbstractEventHandler> *itemEventHandler =
61 new impl::ItemEventHandler<E, protocol::codec::QueueAddListenerCodec::AbstractEventHandler>(getName(), cs, ss, listener, includeValue);
62 return proxy::IQueueImpl::addItemListener(itemEventHandler, includeValue);
74 return proxy::IQueueImpl::removeItemListener(registrationId);
86 return offer(element, 0);
93 void put(
const E& element) {
94 proxy::IQueueImpl::put(toData(element));
106 bool offer(
const E& element,
long timeoutInMillis) {
107 return proxy::IQueueImpl::offer(toData(element), timeoutInMillis);
123 boost::shared_ptr<E>
poll(
long timeoutInMillis) {
124 return boost::shared_ptr<E>(boost::shared_ptr<E>(toObject<E>(
125 proxy::IQueueImpl::pollData(timeoutInMillis))));
133 return proxy::IQueueImpl::remainingCapacity();
141 bool remove(
const E& element) {
142 return proxy::IQueueImpl::remove(toData(element));
151 return proxy::IQueueImpl::contains(toData(element));
171 size_t drainTo(std::vector<E>& elements,
size_t maxElements) {
172 std::vector<serialization::pimpl::Data> coll = proxy::IQueueImpl::drainToData(maxElements);
173 for (std::vector<serialization::pimpl::Data>::const_iterator it = coll.begin(); it != coll.end(); ++it) {
174 std::auto_ptr<E> e = context->getSerializationService().template toObject<E>(*it);
175 elements.push_back(*e);
195 return boost::shared_ptr<E>(toObject<E>(proxy::IQueueImpl::peekData()));
203 return proxy::IQueueImpl::size();
219 return toObjectCollection<E>(proxy::IQueueImpl::toArrayData());
229 std::vector<serialization::pimpl::Data> list = toDataCollection(elements);
230 return proxy::IQueueImpl::containsAll(list);
239 bool addAll(
const std::vector<E>& elements) {
240 std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
241 return proxy::IQueueImpl::addAll(dataList);
251 std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
252 return proxy::IQueueImpl::removeAll(dataList);
263 std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
264 return proxy::IQueueImpl::retainAll(dataList);
271 proxy::IQueueImpl::clear();
274 IQueue(
const std::string& instanceName, spi::ClientContext *context)
275 : proxy::IQueueImpl(instanceName, context) {
void clear()
Removes all elements from queue.
Definition: IQueue.h:270
bool offer(const E &element, long timeoutInMillis)
Inserts the specified element into this queue.
Definition: IQueue.h:106
Concurrent, blocking, distributed, observable, client queue.
Definition: IQueue.h:38
bool offer(const E &element)
Inserts the specified element into this queue.
Definition: IQueue.h:85
std::vector< E > toArray()
Definition: IQueue.h:218
Concurrent, blocking, distributed, observable, client queue.
Definition: RawPointerQueue.h:33
size_t drainTo(std::vector< E > &elements, size_t maxElements)
Note that elements will be pushed_back to vector.
Definition: IQueue.h:171
bool contains(const E &element)
Definition: IQueue.h:150
bool removeAll(const std::vector< E > &elements)
Definition: IQueue.h:250
size_t drainTo(std::vector< E > &elements)
Note that elements will be pushed_back to vector.
Definition: IQueue.h:160
int remainingCapacity()
Definition: IQueue.h:132
bool removeItemListener(const std::string ®istrationId)
Removes the specified item listener.
Definition: IQueue.h:73
std::string addItemListener(ItemListener< E > &listener, bool includeValue)
Adds an item listener for this collection.
Definition: IQueue.h:57
boost::shared_ptr< E > poll(long timeoutInMillis)
Definition: IQueue.h:123
int size()
Definition: IQueue.h:202
void put(const E &element)
Puts the element into queue.
Definition: IQueue.h:93
bool isEmpty()
Definition: IQueue.h:210
bool retainAll(const std::vector< E > &elements)
Removes the elements from this queue that are not available in given "elements" vector.
Definition: IQueue.h:262
boost::shared_ptr< E > peek()
Returns immediately without waiting.
Definition: IQueue.h:194
Item listener for IQueue, ISet and IList.
Definition: ItemListener.h:40
bool containsAll(const std::vector< E > &elements)
Definition: IQueue.h:228
bool addAll(const std::vector< E > &elements)
Definition: IQueue.h:239
boost::shared_ptr< E > poll()
Returns immediately without waiting.
Definition: IQueue.h:185
boost::shared_ptr< E > take()
Definition: IQueue.h:114
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster...
Definition: HazelcastClient.h:459