Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
RawPointerList.h
1 /*
2  * Copyright (c) 2008-2015, 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_ADAPTOR_RAWPOINTERLIST_H_
17 #define HAZELCAST_CLIENT_ADAPTOR_RAWPOINTERLIST_H_
18 
19 #include "hazelcast/client/IList.h"
20 #include "hazelcast/client/adaptor/MapEntryView.h"
21 #include "hazelcast/client/impl/DataArrayImpl.h"
22 #include "hazelcast/client/impl/EntryArrayImpl.h"
23 
24 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
25 #pragma warning(push)
26 #pragma warning(disable: 4251) //for dll export
27 #endif
28 
29 namespace hazelcast {
30  namespace client {
31  namespace adaptor {
37  template<typename T>
39  public:
40  RawPointerList(IList<T> &listToBeAdopted): list(listToBeAdopted), serializationService(
41  list.context->getSerializationService()) {
42  }
43 
55  std::string addItemListener(ItemListener<T> &listener, bool includeValue) {
56  return list.addItemListener(listener, includeValue);
57  }
58 
67  bool removeItemListener(const std::string &registrationId) {
68  return list.removeItemListener(registrationId);
69  }
70 
75  int size() {
76  return list.size();
77  }
78 
83  bool isEmpty() {
84  return list.isEmpty();
85  }
86 
93  bool contains(const T &element) {
94  return list.contains(element);
95  }
96 
101  std::auto_ptr<DataArray<T> > toArray() {
102  return std::auto_ptr<DataArray<T> >(new impl::DataArrayImpl<T>(list.toArrayData(), serializationService));
103  }
104 
111  bool add(const T &element) {
112  return list.add(element);
113  }
114 
121  bool remove(const T &element) {
122  return list.remove(element);
123  }
124 
131  bool containsAll(const std::vector<T> &elements) {
132  return list.containsAll(elements);
133  }
134 
141  bool addAll(const std::vector<T> &elements) {
142  return list.addAll(elements);
143  }
144 
156  bool addAll(int index, const std::vector<T> &elements) {
157  return list.addAll(index, elements);
158  }
159 
166  bool removeAll(const std::vector<T> &elements) {
167  return list.removeAll(elements);
168  }
169 
177  bool retainAll(const std::vector<T> &elements) {
178  return list.retainAll(elements);
179  }
180 
184  void clear() {
185  list.clear();
186  }
187 
200  std::auto_ptr<T> get(int index) {
201  return serializationService.toObject<T>(list.getData(index).get());
202  }
203 
213  std::auto_ptr<T> set(int index, const T &element) {
214  return serializationService.toObject<T>(list.setData(index, serializationService.toData<T>(&element)).get());
215  }
216 
225  void add(int index, const T &element) {
226  list.add(index, element);
227  }
228 
236  std::auto_ptr<T> remove(int index) {
237  return serializationService.toObject<T>(list.removeData(index).get());
238  }
239 
247  int indexOf(const T &element) {
248  return list.indexOf(element);
249  }
250 
257  int lastIndexOf(const T &element) {
258  return list.lastIndexOf(element);
259  }
260 
266  std::auto_ptr<DataArray<T> > subList(int fromIndex, int toIndex) {
267  return std::auto_ptr<DataArray<T> >(new impl::DataArrayImpl<T>(list.subListData(fromIndex, toIndex), serializationService));
268  }
269 
270  private:
271  IList<T> &list;
272  serialization::pimpl::SerializationService &serializationService;
273  };
274  }
275  }
276 }
277 
278 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
279 #pragma warning(pop)
280 #endif
281 
282 #endif /* HAZELCAST_CLIENT_ADAPTOR_RAWPOINTERLIST_H_ */
283 
bool containsAll(const std::vector< T > &elements)
Definition: RawPointerList.h:131
std::string addItemListener(ItemListener< E > &listener, bool includeValue)
Warning 1: If listener should do a time consuming operation, off-load the operation to another thread...
Definition: IList.h:58
int size()
Definition: RawPointerList.h:75
int indexOf(const E &element)
Definition: IList.h:254
bool retainAll(const std::vector< T > &elements)
Removes the elements from this list that are not available in given "elements" vector.
Definition: RawPointerList.h:177
bool removeAll(const std::vector< T > &elements)
Definition: RawPointerList.h:166
int lastIndexOf(const T &element)
Definition: RawPointerList.h:257
int lastIndexOf(const E &element)
Definition: IList.h:264
bool retainAll(const std::vector< E > &elements)
Removes the elements from this list that are not available in given "elements" vector.
Definition: IList.h:184
void clear()
Removes all elements from list.
Definition: RawPointerList.h:184
int indexOf(const T &element)
Definition: RawPointerList.h:247
bool addAll(const std::vector< T > &elements)
Definition: RawPointerList.h:141
int size()
Definition: IList.h:82
boost::shared_ptr< E > get(int index)
You can check if element is available by.
Definition: IList.h:207
bool removeAll(const std::vector< E > &elements)
Definition: IList.h:173
std::auto_ptr< DataArray< T > > subList(int fromIndex, int toIndex)
Definition: RawPointerList.h:266
bool removeItemListener(const std::string &registrationId)
Removes the specified item listener.
Definition: IList.h:74
bool containsAll(const std::vector< E > &elements)
Definition: IList.h:138
bool contains(const T &element)
Definition: RawPointerList.h:93
bool add(const E &element)
Definition: IList.h:118
Concurrent, distributed , client implementation of std::list.
Definition: RawPointerList.h:38
std::auto_ptr< T > set(int index, const T &element)
Replaced the element in the given index.
Definition: RawPointerList.h:213
void clear()
Removes all elements from list.
Definition: IList.h:191
bool isEmpty()
Definition: RawPointerList.h:83
std::auto_ptr< DataArray< T > > toArray()
Definition: RawPointerList.h:101
bool remove(const E &element)
Definition: IList.h:128
bool isEmpty()
Definition: IList.h:90
bool addAll(const std::vector< E > &elements)
Definition: IList.h:148
void add(int index, const T &element)
Adds the element to the given index.
Definition: RawPointerList.h:225
Item listener for IQueue, ISet and IList.
Definition: ItemListener.h:40
bool add(const T &element)
Definition: RawPointerList.h:111
bool removeItemListener(const std::string &registrationId)
Removes the specified item listener.
Definition: RawPointerList.h:67
std::string addItemListener(ItemListener< T > &listener, bool includeValue)
Warning 1: If listener should do a time consuming operation, off-load the operation to another thread...
Definition: RawPointerList.h:55
bool addAll(int index, const std::vector< T > &elements)
Adds elements in vector to the list with given order.
Definition: RawPointerList.h:156
bool contains(const E &element)
Definition: IList.h:100