| Apache Ignite C++

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_CACHE_ENTRY
24 #define _IGNITE_CACHE_CACHE_ENTRY
25
26 #include <utility>
27 #include <ignite/common/common.h>
28
29 namespace ignite
30 {
31 namespace cache
32 {
39 template<typename K, typename V>
40 class CacheEntry
41 {
42 public:
48 CacheEntry() :
49 key(),
50 val(),
51 hasValue(false)
52 {
53 // No-op.
54 }
55
62 CacheEntry(const K& key, const V& val) :
63 key(key),
64 val(val),
65 hasValue(true)
66 {
67 // No-op.
68 }
69
75 CacheEntry(const CacheEntry& other) :
76 key(other.key),
77 val(other.val),
78 hasValue(other.hasValue)
79 {
80 // No-op.
81 }
82
88 CacheEntry(const std::pair<K, V>& p) :
89 key(p.first),
90 val(p.second),
91 hasValue(true)
92 {
93 // No-op.
94 }
95
96
100 virtual ~CacheEntry()
101 {
102 // No-op.
103 }
104
110 CacheEntry& operator=(const CacheEntry& other)
111 {
112 if (this != &other)
113 {
114 key = other.key;
115 val = other.val;
116 hasValue = other.hasValue;
117 }
118
119 return *this;
120 }
121
127 const K& GetKey() const
128 {
129 return key;
130 }
131
137 const V& GetValue() const
138 {
139 return val;
140 }
141
147 bool HasValue() const
148 {
149 return hasValue;
150 }
151
152 protected:
154 K key;
155
157 V val;
158
160 bool hasValue;
161 };
162 }
163 }
164
165 #endif //_IGNITE_CACHE_CACHE_ENTRY
ignite::cache::CacheEntry::GetKey
const K & GetKey() const
Get key.
Definition: cache_entry.h:127
ignite
Apache Ignite API.
Definition: cache.h:48
ignite::cache::CacheEntry::CacheEntry
CacheEntry(const std::pair< K, V > &p)
Constructor.
Definition: cache_entry.h:88
ignite::cache::CacheEntry::HasValue
bool HasValue() const
Check if the value exists.
Definition: cache_entry.h:147
ignite::cache::CacheEntry
Cache entry class template.
Definition: cache_entry.h:40
ignite::cache::CacheEntry::key
K key
Key.
Definition: cache_entry.h:154
ignite::cache::CacheEntry::GetValue
const V & GetValue() const
Get value.
Definition: cache_entry.h:137
ignite::cache::CacheEntry::CacheEntry
CacheEntry(const CacheEntry &other)
Copy constructor.
Definition: cache_entry.h:75
ignite::cache::CacheEntry::~CacheEntry
virtual ~CacheEntry()
Destructor.
Definition: cache_entry.h:100
ignite::cache::CacheEntry::operator=
CacheEntry & operator=(const CacheEntry &other)
Assignment operator.
Definition: cache_entry.h:110
ignite::cache::CacheEntry::val
V val
Value.
Definition: cache_entry.h:157
ignite::cache::CacheEntry::hasValue
bool hasValue
Indicates whether value exists.
Definition: cache_entry.h:160
ignite::cache::CacheEntry::CacheEntry
CacheEntry()
Default constructor.
Definition: cache_entry.h:48
ignite::cache::CacheEntry::CacheEntry
CacheEntry(const K &key, const V &val)
Constructor.
Definition: cache_entry.h:62