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_ENTRY
24 #define _IGNITE_CACHE_ENTRY
25 
26 #include <ignite/common/common.h>
27 
28 namespace ignite
29 {
30  namespace cache
31  {
35  template<typename K, typename V>
36  class IGNITE_IMPORT_EXPORT CacheEntry
37  {
38  public:
42  CacheEntry() : key(K()), val(V())
43  {
44  // No-op.
45  }
46 
53  CacheEntry(const K& key, const V& val) : key(key), val(val)
54  {
55  // No-op.
56  }
57 
63  CacheEntry(const CacheEntry& other)
64  {
65  key = other.key;
66  val = other.val;
67  }
68 
75  {
76  if (this != &other)
77  {
78  CacheEntry tmp(other);
79 
80  K& key0 = key;
81  V& val0 = val;
82 
83  key = tmp.key;
84  val = tmp.val;
85 
86  tmp.key = key0;
87  tmp.val = val0;
88  }
89 
90  return *this;
91  }
92 
98  K GetKey() const
99  {
100  return key;
101  }
102 
108  V GetValue() const
109  {
110  return val;
111  }
112 
113  private:
115  K key;
116 
118  V val;
119  };
120  }
121 }
122 
123 #endif
K GetKey() const
Get key.
Definition: cache_entry.h:98
V GetValue() const
Get value.
Definition: cache_entry.h:108
CacheEntry(const CacheEntry &other)
Copy constructor.
Definition: cache_entry.h:63
Cache entry.
Definition: cache_entry.h:36
CacheEntry & operator=(const CacheEntry &other)
Assignment operator.
Definition: cache_entry.h:74
CacheEntry()
Default constructor.
Definition: cache_entry.h:42
Apache Ignite API.
Definition: binary_consts.h:28
CacheEntry(const K &key, const V &val)
Constructor.
Definition: cache_entry.h:53