GridGain C++
core/include/ignite/cache/cache_entry.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 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_CACHE_CACHE_ENTRY
23 #define _IGNITE_CACHE_CACHE_ENTRY
24 
25 #include <utility>
26 #include <ignite/common/common.h>
27 
28 namespace ignite
29 {
30  namespace cache
31  {
38  template<typename K, typename V>
39  class CacheEntry
40  {
41  public:
48  key(),
49  val(),
50  hasValue(false)
51  {
52  // No-op.
53  }
54 
61  CacheEntry(const K& key, const V& val) :
62  key(key),
63  val(val),
64  hasValue(true)
65  {
66  // No-op.
67  }
68 
74  CacheEntry(const CacheEntry& other) :
75  key(other.key),
76  val(other.val),
77  hasValue(other.hasValue)
78  {
79  // No-op.
80  }
81 
87  CacheEntry(const std::pair<K, V>& p) :
88  key(p.first),
89  val(p.second),
90  hasValue(true)
91  {
92  // No-op.
93  }
94 
95 
99  virtual ~CacheEntry()
100  {
101  // No-op.
102  }
103 
110  {
111  if (this != &other)
112  {
113  key = other.key;
114  val = other.val;
115  hasValue = other.hasValue;
116  }
117 
118  return *this;
119  }
120 
126  const K& GetKey() const
127  {
128  return key;
129  }
130 
136  const V& GetValue() const
137  {
138  return val;
139  }
140 
146  bool HasValue() const
147  {
148  return hasValue;
149  }
150 
151  protected:
153  K key;
154 
156  V val;
157 
159  bool hasValue;
160  };
161  }
162 }
163 
164 #endif //_IGNITE_CACHE_CACHE_ENTRY
ignite::cache::CacheEntry::GetKey
const K & GetKey() const
Get key.
Definition: core/include/ignite/cache/cache_entry.h:126
ignite
Ignite API.
Definition: cache.h:47
ignite::cache::CacheEntry::CacheEntry
CacheEntry(const std::pair< K, V > &p)
Constructor.
Definition: core/include/ignite/cache/cache_entry.h:87
ignite::cache::CacheEntry::HasValue
bool HasValue() const
Check if the value exists.
Definition: core/include/ignite/cache/cache_entry.h:146
ignite::cache::CacheEntry
Cache entry class template.
Definition: core/include/ignite/cache/cache_entry.h:39
ignite::cache::CacheEntry::key
K key
Key.
Definition: core/include/ignite/cache/cache_entry.h:153
ignite::cache::CacheEntry::GetValue
const V & GetValue() const
Get value.
Definition: core/include/ignite/cache/cache_entry.h:136
ignite::cache::CacheEntry::CacheEntry
CacheEntry(const CacheEntry &other)
Copy constructor.
Definition: core/include/ignite/cache/cache_entry.h:74
ignite::cache::CacheEntry::~CacheEntry
virtual ~CacheEntry()
Destructor.
Definition: core/include/ignite/cache/cache_entry.h:99
ignite::cache::CacheEntry::operator=
CacheEntry & operator=(const CacheEntry &other)
Assignment operator.
Definition: core/include/ignite/cache/cache_entry.h:109
ignite::cache::CacheEntry::val
V val
Value.
Definition: core/include/ignite/cache/cache_entry.h:156
ignite::cache::CacheEntry::hasValue
bool hasValue
Indicates whether value exists.
Definition: core/include/ignite/cache/cache_entry.h:159
ignite::cache::CacheEntry::CacheEntry
CacheEntry()
Default constructor.
Definition: core/include/ignite/cache/cache_entry.h:47
ignite::cache::CacheEntry::CacheEntry
CacheEntry(const K &key, const V &val)
Constructor.
Definition: core/include/ignite/cache/cache_entry.h:61