Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
EntryEvent.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 //
17 // Created by ihsan demir on 9/9/15.
18 // Copyright (c) 2015 hazelcast. All rights reserved.
19 
20 #ifndef HAZELCAST_ENTRY_EVENT
21 #define HAZELCAST_ENTRY_EVENT
22 
23 #include "hazelcast/client/Member.h"
24 #include <boost/shared_ptr.hpp>
25 
26 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
27 #pragma warning(push)
28 #pragma warning(disable: 4251) //for dll export
29 #endif
30 
31 namespace hazelcast {
32  namespace client {
36  class HAZELCAST_API EntryEventType {
37  public:
41  enum Type {
42  UNDEFINED = 0 ,
43  ADDED = 1,
44  REMOVED = 1 << 1,
45  UPDATED = 1 << 2,
46  EVICTED = 1 << 3 ,
47  EVICT_ALL = 1 << 4 ,
48  CLEAR_ALL = 1 << 5 ,
49  MERGED = 1 << 6 ,
50  EXPIRED = 1 << 7,
51  ALL = 0xFF
52  };
57 
62 
66  EntryEventType(Type value);
67 
71  operator int() const;
72 
76  void operator = (int i);
77 
78  };
79 
88  template <typename K, typename V>
89  class EntryEvent {
90  public:
94  EntryEvent(const std::string &name, const Member &member, EntryEventType eventType,
95  boost::shared_ptr<K> key, boost::shared_ptr<V> value)
96  : name(name)
97  , member(member)
98  , eventType(eventType)
99  , key(key)
100  , value(value) {
101 
102  };
103 
107  EntryEvent(const std::string &name, const Member &member, EntryEventType eventType,
108  boost::shared_ptr<K> key, boost::shared_ptr<V> value,
109  boost::shared_ptr<V> oldValue, boost::shared_ptr<V> mergingValue)
110  : name(name)
111  , member(member)
112  , eventType(eventType)
113  , key(key)
114  , value(value)
115  , oldValue(oldValue)
116  , mergingValue(mergingValue) {
117 
118  };
119 
125  const K &getKey() const {
126  return *key;
127  };
128 
134  const V &getOldValue() const {
135  return *oldValue;
136  };
137 
143  const V &getValue() const {
144  return *value;
145  };
146 
152  const V &getMErgingValue() const {
153  return *mergingValue;
154  };
155 
161  Member getMember() const {
162  return member;
163  };
164 
171  return eventType;
172  };
173 
179  std::string getName() const {
180  return name;
181  };
182 
183  private:
184  std::string name;
185  Member member;
186  EntryEventType eventType;
187  boost::shared_ptr<K> key;
188  boost::shared_ptr<V> value;
189  boost::shared_ptr<V> oldValue;
190  boost::shared_ptr<V> mergingValue;
191 
192  };
193  }
194 }
195 
196 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
197 #pragma warning(pop)
198 #endif
199 
200 #endif //__EntryEvent_H_
201 
EntryEvent(const std::string &name, const Member &member, EntryEventType eventType, boost::shared_ptr< K > key, boost::shared_ptr< V > value, boost::shared_ptr< V > oldValue, boost::shared_ptr< V > mergingValue)
Constructor.
Definition: EntryEvent.h:107
const K & getKey() const
Returns the key of the entry event.
Definition: EntryEvent.h:125
const V & getOldValue() const
Returns the old value of the entry event.
Definition: EntryEvent.h:134
Type
Type enum.
Definition: EntryEvent.h:41
EntryEventType getEventType() const
Return the event type.
Definition: EntryEvent.h:170
Member getMember() const
Returns the member fired this event.
Definition: EntryEvent.h:161
Cluster member class.
Definition: Member.h:44
Map Entry event.
Definition: EntryEvent.h:89
const V & getMErgingValue() const
Returns the incoming merging value of the entry event.
Definition: EntryEvent.h:152
Type value
Type value.
Definition: EntryEvent.h:56
EntryEvent(const std::string &name, const Member &member, EntryEventType eventType, boost::shared_ptr< K > key, boost::shared_ptr< V > value)
Constructor.
Definition: EntryEvent.h:94
Type of entry event.
Definition: EntryEvent.h:36
std::string getName() const
Returns the name of the map for this event.
Definition: EntryEvent.h:179
const V & getValue() const
Returns the value of the entry event.
Definition: EntryEvent.h:143