GridGain C++
thin-client/include/ignite/thin/cache/cache_entry.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_CACHE_ENTRY
23 #define _IGNITE_THIN_CACHE_CACHE_ENTRY
24 
25 #include <utility>
26 #include <ignite/common/common.h>
27 
28 namespace ignite
29 {
30  namespace impl
31  {
32  namespace thin
33  {
34  template<typename T>
35  class ReadableImpl;
36  }
37  }
38  namespace thin
39  {
40  namespace cache
41  {
48  template<typename K, typename V>
49  class CacheEntry
50  {
52  public:
59  key(),
60  val(),
61  hasValue(false)
62  {
63  // No-op.
64  }
65 
72  CacheEntry(const K& key, const V& val) :
73  key(key),
74  val(val),
75  hasValue(true)
76  {
77  // No-op.
78  }
79 
85  CacheEntry(const CacheEntry& other) :
86  key(other.key),
87  val(other.val),
88  hasValue(other.hasValue)
89  {
90  // No-op.
91  }
92 
98  CacheEntry(const std::pair<K, V>& p) :
99  key(p.first),
100  val(p.second),
101  hasValue(true)
102  {
103  // No-op.
104  }
105 
106 
110  virtual ~CacheEntry()
111  {
112  // No-op.
113  }
114 
121  {
122  if (this != &other)
123  {
124  key = other.key;
125  val = other.val;
126  hasValue = other.hasValue;
127  }
128 
129  return *this;
130  }
131 
137  const K& GetKey() const
138  {
139  return key;
140  }
141 
147  const V& GetValue() const
148  {
149  return val;
150  }
151 
157  bool HasValue() const
158  {
159  return hasValue;
160  }
161 
162  protected:
164  K key;
165 
167  V val;
168 
170  bool hasValue;
171  };
172  }
173  }
174 }
175 
176 #endif //_IGNITE_THIN_CACHE_CACHE_ENTRY
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::CacheEntry::CacheEntry
CacheEntry(const std::pair< K, V > &p)
Constructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:98
ignite::thin::cache::CacheEntry::CacheEntry
CacheEntry(const CacheEntry &other)
Copy constructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:85
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::thin::cache::CacheEntry::CacheEntry
CacheEntry(const K &key, const V &val)
Constructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:72
ignite::thin::cache::CacheEntry::GetValue
const V & GetValue() const
Get value.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:147
ignite::thin::cache::CacheEntry::HasValue
bool HasValue() const
Check if the value exists.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:157
ignite::thin::cache::CacheEntry::GetKey
const K & GetKey() const
Get key.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:137
ignite::thin::cache::CacheEntry::~CacheEntry
virtual ~CacheEntry()
Destructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:110
ignite::impl::thin::ReadableImpl
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:35