ETCH-243 Refactored EtchObjectType hashing
Separate of hash and comparator functionality from EtchObject
Change-Id: I499a46ad0d77899eccd54f41471e4e17b71eac42
git-svn-id: https://svn.apache.org/repos/asf/incubator/etch/trunk@1399118 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/binding-cpp/runtime/include/common/EtchComparator.h b/binding-cpp/runtime/include/common/EtchComparator.h
index 4aa3600..3c47963 100644
--- a/binding-cpp/runtime/include/common/EtchComparator.h
+++ b/binding-cpp/runtime/include/common/EtchComparator.h
@@ -29,10 +29,6 @@
inline capu::bool_t operator() (const EtchObject &first, const EtchObject &second) const {
return first.equals(&second);
}
-
- inline capu::bool_t operator() (const EtchObjectType &first, const EtchObjectType &second) const {
- return first.equals(&second);
- }
};
template <class T>
@@ -42,10 +38,6 @@
inline capu::bool_t operator() (const EtchObject* first, const EtchObject* second) const {
return first->equals(second);
}
-
- inline capu::bool_t operator() (const EtchObjectType* first, const EtchObjectType* second) const {
- return first->equals(second);
- }
};
template <class T>
@@ -55,10 +47,6 @@
inline capu::bool_t operator() (const capu::SmartPointer<EtchObject>& first, const capu::SmartPointer<EtchObject>& second) const {
return first->equals(second.get());
}
-
- inline capu::bool_t operator() (const capu::SmartPointer<EtchObjectType>& first, const capu::SmartPointer<EtchObjectType>& second) const {
- return first->equals(second.get());
- }
};
#endif
diff --git a/binding-cpp/runtime/include/common/EtchObjectHash.h b/binding-cpp/runtime/include/common/EtchObjectHash.h
index 917ddef..2594c6a 100644
--- a/binding-cpp/runtime/include/common/EtchObjectHash.h
+++ b/binding-cpp/runtime/include/common/EtchObjectHash.h
@@ -35,18 +35,6 @@
static capu::uint32_t Digest(const capu::SmartPointer<EtchObject>& key) {
return key->getHashCode();
}
-
- static capu::uint32_t Digest(const EtchObjectType &key) {
- return key.getHashCode();
- }
-
- static capu::uint32_t Digest(const EtchObjectType* key) {
- return key->getHashCode();
- }
-
- static capu::uint32_t Digest(const capu::SmartPointer<EtchObjectType>& key) {
- return key->getHashCode();
- }
};
#endif
diff --git a/binding-cpp/runtime/include/serialization/EtchClass2TypeMap.h b/binding-cpp/runtime/include/serialization/EtchClass2TypeMap.h
index dd8a862..6e5fcd2 100644
--- a/binding-cpp/runtime/include/serialization/EtchClass2TypeMap.h
+++ b/binding-cpp/runtime/include/serialization/EtchClass2TypeMap.h
@@ -64,8 +64,50 @@
*/
void lock();
+ /**
+ * Hashing Functions for the EtchClass2TypeMap
+ */
+ class Hash {
+ public:
+ static capu::uint32_t Digest(const EtchObjectType &key) {
+ return key.getHashCode();
+ }
+
+ static capu::uint32_t Digest(const EtchObjectType* key) {
+ return key->getHashCode();
+ }
+
+ static capu::uint32_t Digest(const capu::SmartPointer<EtchObjectType>& key) {
+ return key->getHashCode();
+ }
+ };
+
+ /**
+ * Comperator Functions for the EtchClass2TypeMap
+ */
+ template <class T>
+ class Comparator {
+ public:
+ inline capu::bool_t operator() (const EtchObjectType &first, const EtchObjectType &second) const {
+ return first.equals(&second);
+ }
+ };
+ template <class T>
+ class Comparator <T*> {
+ public:
+ inline capu::bool_t operator() (const EtchObjectType* first, const EtchObjectType* second) const {
+ return first->equals(second);
+ }
+ };
+ template <class T>
+ class Comparator <capu::SmartPointer<T> > {
+ public:
+ inline capu::bool_t operator() (const capu::SmartPointer<EtchObjectType>& first, const capu::SmartPointer<EtchObjectType>& second) const {
+ return first->equals(second.get());
+ }
+ };
private:
- EtchHashTable<const EtchObjectType*, EtchType* > mC2T;
+ EtchHashTable<const EtchObjectType*, EtchType*, EtchClass2TypeMap::Hash, EtchClass2TypeMap::Comparator<const EtchObjectType*> > mC2T;
capu::bool_t mLocked;