| Apache Ignite C++

thin-client/include/ignite/thin/cache/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_THIN_CACHE_CACHE_ENTRY
24 #define _IGNITE_THIN_CACHE_CACHE_ENTRY
25
26 #include <utility>
27 #include <ignite/common/common.h>
28
29 namespace ignite
30 {
31 namespace thin
32 {
33 namespace cache
34 {
41 template<typename K, typename V>
42 class CacheEntry
43 {
44 public:
50 CacheEntry() :
51 key(),
52 val(),
53 hasValue(false)
54 {
55 // No-op.
56 }
57
64 CacheEntry(const K& key, const V& val) :
65 key(key),
66 val(val),
67 hasValue(true)
68 {
69 // No-op.
70 }
71
77 CacheEntry(const CacheEntry& other) :
78 key(other.key),
79 val(other.val),
80 hasValue(other.hasValue)
81 {
82 // No-op.
83 }
84
90 CacheEntry(const std::pair<K, V>& p) :
91 key(p.first),
92 val(p.second),
93 hasValue(true)
94 {
95 // No-op.
96 }
97
98
102 virtual ~CacheEntry()
103 {
104 // No-op.
105 }
106
112 CacheEntry& operator=(const CacheEntry& other)
113 {
114 if (this != &other)
115 {
116 key = other.key;
117 val = other.val;
118 hasValue = other.hasValue;
119 }
120
121 return *this;
122 }
123
129 const K& GetKey() const
130 {
131 return key;
132 }
133
139 const V& GetValue() const
140 {
141 return val;
142 }
143
149 bool HasValue() const
150 {
151 return hasValue;
152 }
153
154 protected:
156 K key;
157
159 V val;
160
162 bool hasValue;
163 };
164 }
165 }
166 }
167
168 #endif //_IGNITE_THIN_CACHE_CACHE_ENTRY
ignite
Apache Ignite API.
Definition: cache.h:48
ignite::thin::cache::CacheEntry::operator=
CacheEntry & operator=(const CacheEntry &other)
Assignment operator.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:112
ignite::thin::cache::CacheEntry
Cache entry class template.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:42
ignite::thin::cache::CacheEntry::hasValue
bool hasValue
Indicates whether value exists.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:162
ignite::thin::cache::CacheEntry::CacheEntry
CacheEntry(const std::pair< K, V > &p)
Constructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:90
ignite::thin::cache::CacheEntry::CacheEntry
CacheEntry(const CacheEntry &other)
Copy constructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:77
ignite::thin::cache::CacheEntry::key
K key
Key.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:156
ignite::thin::cache::CacheEntry::val
V val
Value.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:159
ignite::thin::cache::CacheEntry::CacheEntry
CacheEntry(const K &key, const V &val)
Constructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:64
ignite::thin::cache::CacheEntry::GetValue
const V & GetValue() const
Get value.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:139
ignite::thin::cache::CacheEntry::HasValue
bool HasValue() const
Check if the value exists.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:149
ignite::thin::cache::CacheEntry::GetKey
const K & GetKey() const
Get key.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:129
ignite::thin::cache::CacheEntry::~CacheEntry
virtual ~CacheEntry()
Destructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:102
ignite::thin::cache::CacheEntry::CacheEntry
CacheEntry()
Default constructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:50