Apache Ignite C++
cache_entry_event.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
23 #ifndef _IGNITE_CACHE_EVENT_CACHE_ENTRY_EVENT
24 #define _IGNITE_CACHE_EVENT_CACHE_ENTRY_EVENT
25 
28 
29 namespace ignite
30 {
31  namespace cache
32  {
39  template<typename K, typename V>
40  class CacheEntryEvent : public CacheEntry<K, V>
41  {
42  public:
49  CacheEntry<K, V>(),
50  oldVal(),
51  hasOldValue(false)
52  {
53  // No-op.
54  }
55 
62  CacheEntry<K, V>(other),
63  oldVal(other.oldVal),
64  hasOldValue(other.hasOldValue)
65  {
66  // No-op.
67  }
68 
72  virtual ~CacheEntryEvent()
73  {
74  // No-op.
75  }
76 
84  {
85  if (this != &other)
86  {
88 
89  oldVal = other.oldVal;
90  hasOldValue = other.hasOldValue;
91  }
92 
93  return *this;
94  }
95 
101  const V& GetOldValue() const
102  {
103  return oldVal;
104  }
105 
111  bool HasOldValue() const
112  {
113  return hasOldValue;
114  }
115 
122  {
123  this->key = reader.ReadObject<K>();
124 
125  this->hasOldValue = reader.TryReadObject(this->oldVal);
126  this->hasValue = reader.TryReadObject(this->val);
127  }
128 
129  private:
131  V oldVal;
132 
134  bool hasOldValue;
135  };
136  }
137 }
138 
139 #endif //_IGNITE_CACHE_EVENT_CACHE_ENTRY_EVENT
bool HasOldValue() const
Check if the old value exists.
Definition: cache_entry_event.h:111
K key
Key.
Definition: cache_entry.h:154
void Read(binary::BinaryRawReader &reader)
Reads cache event using provided raw reader.
Definition: cache_entry_event.h:121
Cache entry event class template.
Definition: cache_entry_event.h:40
virtual ~CacheEntryEvent()
Destructor.
Definition: cache_entry_event.h:72
CacheEntryEvent & operator=(const CacheEntryEvent< K, V > &other)
Assignment operator.
Definition: cache_entry_event.h:83
bool TryReadObject(T &res)
Try read object.
Definition: binary_raw_reader.h:431
T ReadObject()
Read object.
Definition: binary_raw_reader.h:416
Cache entry class template.
Definition: cache_entry.h:40
V val
Value.
Definition: cache_entry.h:157
CacheEntry & operator=(const CacheEntry &other)
Assignment operator.
Definition: cache_entry.h:110
Declares ignite::cache::CacheEntry class.
Declares ignite::binary::BinaryRawReader class.
const V & GetOldValue() const
Get old value.
Definition: cache_entry_event.h:101
CacheEntryEvent()
Default constructor.
Definition: cache_entry_event.h:48
bool hasValue
Indicates whether value exists.
Definition: cache_entry.h:160
Apache Ignite API.
Definition: cache.h:48
CacheEntryEvent(const CacheEntryEvent< K, V > &other)
Copy constructor.
Definition: cache_entry_event.h:61
Binary raw reader.
Definition: binary_raw_reader.h:56