| 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
26 #include <ignite/binary/binary_raw_reader.h>
27 #include <ignite/cache/cache_entry.h>
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:
48 CacheEntryEvent() :
49 CacheEntry<K, V>(),
50 oldVal(),
51 hasOldValue(false)
52 {
53 // No-op.
54 }
55
61 CacheEntryEvent(const CacheEntryEvent<K, V>& other) :
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
83 CacheEntryEvent& operator=(const CacheEntryEvent<K, V>& other)
84 {
85 if (this != &other)
86 {
87 CacheEntry<K, V>::operator=(other);
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
121 void Read(binary::BinaryRawReader& reader)
122 {
123 this->key = reader.ReadObject<K>();
124
125 this->hasOldValue = reader.TryReadObject(this->oldVal);
126 this->hasValue = reader.TryReadObject(this->val);
127
128 // Java send an event type, we need to fetch it from the buffer.
129 reader.ReadInt8();
130 }
131
132 private:
134 V oldVal;
135
137 bool hasOldValue;
138 };
139 }
140 }
141
142 #endif //_IGNITE_CACHE_EVENT_CACHE_ENTRY_EVENT
ignite::binary::BinaryRawReader
Binary raw reader.
Definition: binary_raw_reader.h:57
ignite
Apache Ignite API.
Definition: cache.h:48
ignite::cache::CacheEntryEvent::operator=
CacheEntryEvent & operator=(const CacheEntryEvent< K, V > &other)
Assignment operator.
Definition: cache_entry_event.h:83
ignite::cache::CacheEntry
Cache entry class template.
Definition: cache_entry.h:40
ignite::cache::CacheEntry::key
K key
Key.
Definition: cache_entry.h:154
ignite::binary::BinaryRawReader::TryReadObject
bool TryReadObject(T &res)
Try read object.
Definition: binary_raw_reader.h:486
ignite::binary::BinaryRawReader::ReadObject
T ReadObject()
Read object.
Definition: binary_raw_reader.h:458
binary_raw_reader.h
ignite::cache::CacheEntryEvent
Cache entry event class template.
Definition: cache_entry_event.h:40
ignite::cache::CacheEntryEvent::CacheEntryEvent
CacheEntryEvent()
Default constructor.
Definition: cache_entry_event.h:48
ignite::cache::CacheEntryEvent::GetOldValue
const V & GetOldValue() const
Get old value.
Definition: cache_entry_event.h:101
ignite::cache::CacheEntry::operator=
CacheEntry & operator=(const CacheEntry &other)
Assignment operator.
Definition: cache_entry.h:110
ignite::cache::CacheEntryEvent::CacheEntryEvent
CacheEntryEvent(const CacheEntryEvent< K, V > &other)
Copy constructor.
Definition: cache_entry_event.h:61
ignite::cache::CacheEntry::val
V val
Value.
Definition: cache_entry.h:157
ignite::cache::CacheEntryEvent::Read
void Read(binary::BinaryRawReader &reader)
Reads cache event using provided raw reader.
Definition: cache_entry_event.h:121
ignite::cache::CacheEntry::hasValue
bool hasValue
Indicates whether value exists.
Definition: cache_entry.h:160
ignite::cache::CacheEntryEvent::~CacheEntryEvent
virtual ~CacheEntryEvent()
Destructor.
Definition: cache_entry_event.h:72
ignite::binary::BinaryRawReader::ReadInt8
int8_t ReadInt8()
Read 8-byte signed integer.
Definition: binary_raw_reader.cpp:32
cache_entry.h
ignite::cache::CacheEntryEvent::HasOldValue
bool HasOldValue() const
Check if the old value exists.
Definition: cache_entry_event.h:111