Hazelcast C++ Client
 All Classes Functions Variables Enumerations Enumerator Pages
RawPointerList.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_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 hazelcast::client::impl::DataArrayImpl<T>(
103  list.toArrayData(), serializationService));
104  }
105 
112  bool add(const T &element) {
113  return list.add(element);
114  }
115 
122  bool remove(const T &element) {
123  return list.remove(element);
124  }
125 
132  bool containsAll(const std::vector<T> &elements) {
133  return list.containsAll(elements);
134  }
135 
142  bool addAll(const std::vector<T> &elements) {
143  return list.addAll(elements);
144  }
145 
157  bool addAll(int index, const std::vector<T> &elements) {
158  return list.addAll(index, elements);
159  }
160 
167  bool removeAll(const std::vector<T> &elements) {
168  return list.removeAll(elements);
169  }
170 
178  bool retainAll(const std::vector<T> &elements) {
179  return list.retainAll(elements);
180  }
181 
185  void clear() {
186  list.clear();
187  }
188 
201  std::auto_ptr<T> get(int index) {
202  return serializationService.toObject<T>(list.getData(index).get());
203  }
204 
214  std::auto_ptr<T> set(int index, const T &element) {
215  return serializationService.toObject<T>(
216  list.setData(index, serializationService.toData<T>(&element)).get());
217  }
218 
227  void add(int index, const T &element) {
228  list.add(index, element);
229  }
230 
238  std::auto_ptr<T> remove(int index) {
239  return serializationService.toObject<T>(list.removeData(index).get());
240  }
241 
249  int indexOf(const T &element) {
250  return list.indexOf(element);
251  }
252 
259  int lastIndexOf(const T &element) {
260  return list.lastIndexOf(element);
261  }
262 
268  std::auto_ptr<DataArray<T> > subList(int fromIndex, int toIndex) {
269  return std::auto_ptr<DataArray<T> >(new hazelcast::client::impl::DataArrayImpl<T>(
270  list.subListData(fromIndex, toIndex), serializationService));
271  }
272 
273  private:
274  IList<T> &list;
275  serialization::pimpl::SerializationService &serializationService;
276  };
277  }
278  }
279 }
280 
281 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
282 #pragma warning(pop)
283 #endif
284 
285 #endif /* HAZELCAST_CLIENT_ADAPTOR_RAWPOINTERLIST_H_ */
286 
bool containsAll(const std::vector< T > &elements)
Definition: RawPointerList.h:132
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:178
bool removeAll(const std::vector< T > &elements)
Definition: RawPointerList.h:167
int lastIndexOf(const T &element)
Definition: RawPointerList.h:259
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:185
int indexOf(const T &element)
Definition: RawPointerList.h:249
bool addAll(const std::vector< T > &elements)
Definition: RawPointerList.h:142
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:268
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:214
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:227
Item listener for IQueue, ISet and IList.
Definition: ItemListener.h:40
bool add(const T &element)
Definition: RawPointerList.h:112
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:157
bool contains(const E &element)
Definition: IList.h:100