GridGain C++
thin-client/include/ignite/thin/cache/event/cache_entry_event.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 GridGain Systems, Inc. and Contributors.
3  *
4  * Licensed under the GridGain Community Edition License (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  * https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
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 
22 #ifndef _IGNITE_THIN_CACHE_EVENT_CACHE_ENTRY_EVENT
23 #define _IGNITE_THIN_CACHE_EVENT_CACHE_ENTRY_EVENT
24 
27 
28 namespace ignite
29 {
30  namespace impl
31  {
32  namespace thin
33  {
34  namespace cache
35  {
36  namespace query
37  {
38  namespace continuous
39  {
40  template<typename K, typename V>
42  }
43  }
44  }
45  }
46  }
47  namespace thin
48  {
49  namespace cache
50  {
55  {
56  enum Type
57  {
59  CREATED = 0,
60 
62  UPDATED = 1,
63 
65  REMOVED = 2,
66 
68  EXPIRED = 3
69  };
70  };
71 
78  template<typename K, typename V>
79  class CacheEntryEvent : public CacheEntry<K, V>
80  {
82 
83  public:
90  CacheEntry<K, V>(),
91  oldVal(),
92  hasOldValue(false),
93  eventType(CacheEntryEventType::CREATED)
94  {
95  // No-op.
96  }
97 
104  CacheEntry<K, V>(other),
105  oldVal(other.oldVal),
106  hasOldValue(other.hasOldValue),
107  eventType(other.eventType)
108  {
109  // No-op.
110  }
111 
116  {
117  // No-op.
118  }
119 
127  {
128  if (this != &other)
129  {
131 
132  oldVal = other.oldVal;
133  hasOldValue = other.hasOldValue;
134  eventType = other.eventType;
135  }
136 
137  return *this;
138  }
139 
148  {
149  return eventType;
150  };
151 
157  const V& GetOldValue() const
158  {
159  return oldVal;
160  }
161 
167  bool HasOldValue() const
168  {
169  return hasOldValue;
170  }
171 
172  private:
178  void Read(binary::BinaryRawReader& reader)
179  {
180  this->key = reader.ReadObject<K>();
181 
182  this->hasOldValue = reader.TryReadObject(this->oldVal);
183  this->hasValue = reader.TryReadObject(this->val);
184 
185  int8_t intType = reader.ReadInt8();
186  if (intType < 0 || intType > 3)
187  {
188  std::string errMsg = "Event type is not supported: " + common::LexicalCast<std::string>(intType);
189  throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, errMsg.c_str());
190  }
191 
192  eventType = static_cast<CacheEntryEventType::Type>(intType);
193  }
194 
196  V oldVal;
197 
199  bool hasOldValue;
200 
202  CacheEntryEventType::Type eventType;
203  };
204  }
205  }
206 }
207 
208 #endif //_IGNITE_THIN_CACHE_EVENT_CACHE_ENTRY_EVENT
ignite::thin::cache::CacheEntryEvent
Cache entry event class template.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:79
ignite::thin::cache::CacheEntryEventType::CREATED
@ CREATED
An event type indicating that the cache entry was created.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:59
ignite::binary::BinaryRawReader
Binary raw reader.
Definition: binary_raw_reader.h:56
ignite
Ignite API.
Definition: cache.h:47
ignite::thin::cache::CacheEntry::operator=
CacheEntry & operator=(const CacheEntry &other)
Assignment operator.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:120
ignite::thin::cache::CacheEntry
Cache entry class template.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:49
ignite::thin::cache::CacheEntry::hasValue
bool hasValue
Indicates whether value exists.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:170
ignite::thin::cache::CacheEntryEventType::EXPIRED
@ EXPIRED
An event type indicating that the cache entry was removed by expiration policy.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:68
ignite::thin::cache::CacheEntryEventType::REMOVED
@ REMOVED
An event type indicating that the cache entry was removed.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:65
ignite::impl::thin::cache::query::continuous::ContinuousQueryClientHolder
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:41
ignite::thin::cache::CacheEntryEventType::UPDATED
@ UPDATED
An event type indicating that the cache entry was updated.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:62
ignite::thin::cache::CacheEntryEvent::~CacheEntryEvent
virtual ~CacheEntryEvent()
Destructor.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:115
ignite::thin::cache::CacheEntryEvent::CacheEntryEvent
CacheEntryEvent(const CacheEntryEvent< K, V > &other)
Copy constructor.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:103
ignite::binary::BinaryRawReader::TryReadObject
bool TryReadObject(T &res)
Try read object.
Definition: binary_raw_reader.h:492
ignite::thin::cache::CacheEntry::key
K key
Key.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:164
ignite::thin::cache::CacheEntry::val
V val
Value.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:167
ignite::binary::BinaryRawReader::ReadObject
T ReadObject()
Read object.
Definition: binary_raw_reader.h:464
binary_raw_reader.h
ignite::thin::cache::CacheEntryEventType::Type
Type
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:56
ignite::IgniteError::IGNITE_ERR_GENERIC
static const int IGNITE_ERR_GENERIC
Generic Ignite error.
Definition: ignite_error.h:130
ignite::thin::cache::CacheEntryEvent::CacheEntryEvent
CacheEntryEvent()
Default constructor.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:89
ignite::thin::cache::CacheEntryEventType
Cache event type.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:54
ignite::thin::cache::CacheEntryEvent::GetOldValue
const V & GetOldValue() const
Get old value.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:157
ignite::thin::cache::CacheEntryEvent::HasOldValue
bool HasOldValue() const
Check if the old value exists.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:167
ignite::binary::BinaryRawReader::ReadInt8
int8_t ReadInt8()
Read 8-byte signed integer.
Definition: binary_raw_reader.cpp:36
ignite::thin::cache::CacheEntryEvent::GetEventType
CacheEntryEventType::Type GetEventType() const
Get event type.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:147
ignite::IgniteError
Ignite error information.
Definition: ignite_error.h:93
ignite::thin::cache::CacheEntryEvent::operator=
CacheEntryEvent & operator=(const CacheEntryEvent< K, V > &other)
Assignment operator.
Definition: thin-client/include/ignite/thin/cache/event/cache_entry_event.h:126
cache_entry.h