Add functionality to reset the Class2Type and TypeMap
The EtchClass2Type and EtchType maps are initialized by
the value factory at the begin of a life cycle.
In order to allow a second life cycle this map must
be resetted again. This is triggered by the value factory.
Change-Id: I0064992869def776cbcbbf3166f4d8931a619dd9
git-svn-id: https://svn.apache.org/repos/asf/etch/trunk@1679578 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/binding-cpp/runtime/include/serialization/EtchClass2TypeMap.h b/binding-cpp/runtime/include/serialization/EtchClass2TypeMap.h
index b46c2cb..2a3be0c 100644
--- a/binding-cpp/runtime/include/serialization/EtchClass2TypeMap.h
+++ b/binding-cpp/runtime/include/serialization/EtchClass2TypeMap.h
@@ -66,6 +66,11 @@
void lock();
/**
+ * Resets the map. This removes all entries and unlocks to map.
+ */
+ void reset();
+
+ /**
* Hashing Functions for the EtchClass2TypeMap
*/
class Hash {
diff --git a/binding-cpp/runtime/include/serialization/EtchTypeMap.h b/binding-cpp/runtime/include/serialization/EtchTypeMap.h
index 89d621c..2a2623c 100644
--- a/binding-cpp/runtime/include/serialization/EtchTypeMap.h
+++ b/binding-cpp/runtime/include/serialization/EtchTypeMap.h
@@ -80,6 +80,11 @@
void lock();
/**
+ * Resets the map. This removes all entries and unlocks to map.
+ */
+ void reset();
+
+ /**
* @return the number of values in the map.
*/
capu::int32_t size();
diff --git a/binding-cpp/runtime/src/main/serialization/EtchClass2TypeMap.cpp b/binding-cpp/runtime/src/main/serialization/EtchClass2TypeMap.cpp
index 9ed5394..1b7bbe9 100644
--- a/binding-cpp/runtime/src/main/serialization/EtchClass2TypeMap.cpp
+++ b/binding-cpp/runtime/src/main/serialization/EtchClass2TypeMap.cpp
@@ -49,3 +49,8 @@
void EtchClass2TypeMap::lock() {
mLocked = true;
}
+
+void EtchClass2TypeMap::reset() {
+ mLocked = false;
+ mC2T.clear();
+}
\ No newline at end of file
diff --git a/binding-cpp/runtime/src/main/serialization/EtchTypeMap.cpp b/binding-cpp/runtime/src/main/serialization/EtchTypeMap.cpp
index 294b4c5..31075ce 100644
--- a/binding-cpp/runtime/src/main/serialization/EtchTypeMap.cpp
+++ b/binding-cpp/runtime/src/main/serialization/EtchTypeMap.cpp
@@ -26,16 +26,7 @@
}
EtchTypeMap::~EtchTypeMap() {
- EtchHashTable<capu::int32_t, EtchType*, EtchComparatorNative, EtchHashNative>::Iterator it = mById.begin();
- while (it.hasNext()) {
- EtchHashTable<capu::int32_t, EtchType*, EtchComparatorNative, EtchHashNative>::HashTableEntry entry;
- it.next(&entry);
- if (entry.value != NULL) {
- delete entry.value;
- }
- }
- mById.clear();
- mByName.clear();
+ reset();
}
status_t EtchTypeMap::add(EtchType *type) {
@@ -61,6 +52,21 @@
mLocked = true;
};
+void EtchTypeMap::reset() {
+ EtchHashTable<capu::int32_t, EtchType*, EtchComparatorNative, EtchHashNative>::Iterator it = mById.begin();
+ while (it.hasNext()) {
+ EtchHashTable<capu::int32_t, EtchType*, EtchComparatorNative, EtchHashNative>::HashTableEntry entry;
+ it.next(&entry);
+ if (entry.value != NULL) {
+ delete entry.value;
+ }
+ }
+ mById.clear();
+ mByName.clear();
+
+ mLocked = false;
+}
+
capu::int32_t EtchTypeMap::size() {
return mById.count();
}