activemq-cpp-3.8.2
MapEntry.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 
18 #ifndef _DECAF_UTIL_MAPENTRY_H_
19 #define _DECAF_UTIL_MAPENTRY_H_
20 
21 #include <decaf/util/Config.h>
22 
23 namespace decaf {
24 namespace util {
25 
26  template<typename K, typename V>
27  class MapEntry {
28  private:
29 
30  K key;
31  V value;
32 
33  public:
34 
35  MapEntry() : key(), value() {
36  }
37 
38  MapEntry(const MapEntry& other) : key(other.getKey()), value(other.getValue()) {
39  }
40 
41  MapEntry(const K& key, const V& value) : key(key), value(value) {
42  }
43 
44  MapEntry& operator= (const MapEntry& other) {
45  this->key = other.getKey();
46  this->value = other.getValue();
47 
48  return *this;
49  }
50 
51  virtual ~MapEntry() {};
52 
53  virtual void setKey(K key) {
54  this->key = key;
55  }
56 
57  virtual K& getKey() {
58  return this->key;
59  }
60 
61  virtual const K& getKey() const {
62  return this->key;
63  }
64 
65  virtual void setValue(const V& value) {
66  this->value = value;
67  }
68 
69  virtual V& getValue() {
70  return this->value;
71  }
72 
73  virtual const V& getValue() const {
74  return this->value;
75  }
76 
77  virtual bool equals(const MapEntry<K, V>& entry) const {
78  if (this == &entry) {
79  return true;
80  }
81 
82  if (!(this->key == entry.getKey())) {
83  return false;
84  }
85 
86  if (!(this->value == entry.getValue())) {
87  return false;
88  }
89 
90  return true;
91  }
92 
93  virtual bool operator==(const MapEntry<K, V>& other) const {
94  return this->equals(other);
95  }
96  };
97 
98 }}
99 
100 #endif /* _DECAF_UTIL_MAPENTRY_H_ */
MapEntry(const MapEntry &other)
Definition: MapEntry.h:38
MapEntry(const K &key, const V &value)
Definition: MapEntry.h:41
virtual const V & getValue() const
Definition: MapEntry.h:73
virtual void setValue(const V &value)
Definition: MapEntry.h:65
virtual K & getKey()
Definition: MapEntry.h:57
virtual bool operator==(const MapEntry< K, V > &other) const
Definition: MapEntry.h:93
virtual void setKey(K key)
Definition: MapEntry.h:53
virtual V & getValue()
Definition: MapEntry.h:69
virtual const K & getKey() const
Definition: MapEntry.h:61
MapEntry & operator=(const MapEntry &other)
Definition: MapEntry.h:44
Definition: MapEntry.h:27
virtual bool equals(const MapEntry< K, V > &entry) const
Definition: MapEntry.h:77
virtual ~MapEntry()
Definition: MapEntry.h:51
MapEntry()
Definition: MapEntry.h:35
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25