| Apache Ignite C++

mutable_cache_entry.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_MUTABLE_CACHE_ENTRY
24 #define _IGNITE_CACHE_MUTABLE_CACHE_ENTRY
25
26 namespace ignite
27 {
28 namespace cache
29 {
39 template<typename K, typename V>
40 class MutableCacheEntry
41 {
42 public:
46 MutableCacheEntry() :
47 key(),
48 val(),
49 exists(false)
50 {
51 // No-op.
52 }
53
59 MutableCacheEntry(const K& key) :
60 key(key),
61 val(),
62 exists(false)
63 {
64 // No-op.
65 }
66
73 MutableCacheEntry(const K& key, const V& val) :
74 key(key),
75 val(val),
76 exists(true)
77 {
78 // No-op.
79 }
80
86 MutableCacheEntry(const MutableCacheEntry& other) :
87 key(other.key),
88 val(other.val),
89 exists(other.exists)
90 {
91 // No-op.
92 }
93
100 MutableCacheEntry& operator=(const MutableCacheEntry& other)
101 {
102 if (this != &other)
103 {
104 key = other.key;
105 val = other.val;
106 exists = other.exists;
107 }
108
109 return *this;
110 }
111
118 bool IsExists() const
119 {
120 return exists;
121 }
122
126 void Remove()
127 {
128 exists = false;
129 }
130
136 const K& GetKey() const
137 {
138 return key;
139 }
140
146 const V& GetValue() const
147 {
148 return val;
149 }
150
158 void SetValue(const V& val)
159 {
160 this->val = val;
161
162 exists = true;
163 }
164
165 private:
167 K key;
168
170 V val;
171
173 bool exists;
174 };
175 }
176 }
177
178 #endif //_IGNITE_CACHE_MUTABLE_CACHE_ENTRY
ignite::cache::MutableCacheEntry::MutableCacheEntry
MutableCacheEntry()
Default constructor.
Definition: mutable_cache_entry.h:46
ignite
Apache Ignite API.
Definition: cache.h:48
ignite::cache::MutableCacheEntry::MutableCacheEntry
MutableCacheEntry(const K &key, const V &val)
Constructor for existing entry.
Definition: mutable_cache_entry.h:73
ignite::cache::MutableCacheEntry::operator=
MutableCacheEntry & operator=(const MutableCacheEntry &other)
Assignment operator.
Definition: mutable_cache_entry.h:100
ignite::cache::MutableCacheEntry::MutableCacheEntry
MutableCacheEntry(const K &key)
Constructor for non-existing entry.
Definition: mutable_cache_entry.h:59
ignite::cache::MutableCacheEntry::IsExists
bool IsExists() const
Check whether cache entry exists in cache.
Definition: mutable_cache_entry.h:118
ignite::cache::MutableCacheEntry::SetValue
void SetValue(const V &val)
Sets or replaces the value associated with the key.
Definition: mutable_cache_entry.h:158
ignite::cache::MutableCacheEntry
Mutable representation of CacheEntry class template.
Definition: mutable_cache_entry.h:40
ignite::cache::MutableCacheEntry::Remove
void Remove()
Removes the entry from the Cache.
Definition: mutable_cache_entry.h:126
ignite::cache::MutableCacheEntry::MutableCacheEntry
MutableCacheEntry(const MutableCacheEntry &other)
Copy constructor.
Definition: mutable_cache_entry.h:86
ignite::cache::MutableCacheEntry::GetKey
const K & GetKey() const
Get key.
Definition: mutable_cache_entry.h:136
ignite::cache::MutableCacheEntry::GetValue
const V & GetValue() const
Get value.
Definition: mutable_cache_entry.h:146