| 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 impl
32 {
33 namespace thin
34 {
35 template<typename T>
36 class ReadableImpl;
37 }
38 }
39 namespace thin
40 {
41 namespace cache
42 {
49 template<typename K, typename V>
50 class CacheEntry
51 {
52 friend class ignite::impl::thin::ReadableImpl< ignite::thin::cache::CacheEntry<K, V> >;
53 public:
59 CacheEntry() :
60 key(),
61 val(),
62 hasValue(false)
63 {
64 // No-op.
65 }
66
73 CacheEntry(const K& key, const V& val) :
74 key(key),
75 val(val),
76 hasValue(true)
77 {
78 // No-op.
79 }
80
86 CacheEntry(const CacheEntry& other) :
87 key(other.key),
88 val(other.val),
89 hasValue(other.hasValue)
90 {
91 // No-op.
92 }
93
99 CacheEntry(const std::pair<K, V>& p) :
100 key(p.first),
101 val(p.second),
102 hasValue(true)
103 {
104 // No-op.
105 }
106
107
111 virtual ~CacheEntry()
112 {
113 // No-op.
114 }
115
121 CacheEntry& operator=(const CacheEntry& other)
122 {
123 if (this != &other)
124 {
125 key = other.key;
126 val = other.val;
127 hasValue = other.hasValue;
128 }
129
130 return *this;
131 }
132
138 const K& GetKey() const
139 {
140 return key;
141 }
142
148 const V& GetValue() const
149 {
150 return val;
151 }
152
158 bool HasValue() const
159 {
160 return hasValue;
161 }
162
163 protected:
165 K key;
166
168 V val;
169
171 bool hasValue;
172 };
173 }
174 }
175 }
176
177 #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:121
ignite::thin::cache::CacheEntry
Cache entry class template.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:50
ignite::thin::cache::CacheEntry::hasValue
bool hasValue
Indicates whether value exists.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:171
ignite::thin::cache::CacheEntry::CacheEntry
CacheEntry(const std::pair< K, V > &p)
Constructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:99
ignite::thin::cache::CacheEntry::CacheEntry
CacheEntry(const CacheEntry &other)
Copy constructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:86
ignite::thin::cache::CacheEntry::key
K key
Key.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:165
ignite::thin::cache::CacheEntry::val
V val
Value.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:168
ignite::thin::cache::CacheEntry::CacheEntry
CacheEntry(const K &key, const V &val)
Constructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:73
ignite::thin::cache::CacheEntry::GetValue
const V & GetValue() const
Get value.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:148
ignite::thin::cache::CacheEntry::HasValue
bool HasValue() const
Check if the value exists.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:158
ignite::thin::cache::CacheEntry::GetKey
const K & GetKey() const
Get key.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:138
ignite::thin::cache::CacheEntry::~CacheEntry
virtual ~CacheEntry()
Destructor.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:111
ignite::impl::thin::ReadableImpl
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:36