summaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/tree/type-serializer-map.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-12-02 12:26:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-12-02 12:26:05 +0200
commitee4eb695119bce96515b330f9fc83ddd67da5c62 (patch)
tree817bf37d4b0f0fb89e785004c41b4c6928228f79 /libxsd/xsd/cxx/tree/type-serializer-map.txx
parentc155e6925211747af9a13a5994c2f768c5048971 (diff)
Implement de-registering polymorphic type information
This is required for DLL/shared library unloading.
Diffstat (limited to 'libxsd/xsd/cxx/tree/type-serializer-map.txx')
-rw-r--r--libxsd/xsd/cxx/tree/type-serializer-map.txx47
1 files changed, 42 insertions, 5 deletions
diff --git a/libxsd/xsd/cxx/tree/type-serializer-map.txx b/libxsd/xsd/cxx/tree/type-serializer-map.txx
index 797cb13..232e239 100644
--- a/libxsd/xsd/cxx/tree/type-serializer-map.txx
+++ b/libxsd/xsd/cxx/tree/type-serializer-map.txx
@@ -263,6 +263,13 @@ namespace xsd
template <typename C>
void type_serializer_map<C>::
+ unregister_type (const type_id& tid)
+ {
+ type_map_.erase (&tid);
+ }
+
+ template <typename C>
+ void type_serializer_map<C>::
register_element (const qualified_name& root,
const qualified_name& subst,
const type_id& tid,
@@ -273,6 +280,21 @@ namespace xsd
template <typename C>
void type_serializer_map<C>::
+ unregister_element (const qualified_name& root, const type_id& tid)
+ {
+ typename element_map::iterator i (element_map_.find (root));
+
+ if (i != element_map_.end ())
+ {
+ i->second.erase (&tid);
+
+ if (i->second.empty ())
+ element_map_.erase (root);
+ }
+ }
+
+ template <typename C>
+ void type_serializer_map<C>::
serialize (const C* name, // element name
const C* ns, // element namespace
bool global,
@@ -508,7 +530,6 @@ namespace xsd
e << static_cast<const T&> (x);
}
-
// type_serializer_initializer
//
template<unsigned long id, typename C, typename T>
@@ -523,10 +544,18 @@ namespace xsd
template<unsigned long id, typename C, typename T>
type_serializer_initializer<id, C, T>::
- type_serializer_initializer (const C* root_name,
- const C* root_ns,
- const C* subst_name,
- const C* subst_ns)
+ ~type_serializer_initializer ()
+ {
+ type_serializer_map_instance<id, C> ().unregister_type (typeid (T));
+ }
+
+ // element_serializer_initializer
+ //
+ template<unsigned long id, typename C, typename T>
+ element_serializer_initializer<id, C, T>::
+ element_serializer_initializer (const C* root_name, const C* root_ns,
+ const C* subst_name, const C* subst_ns)
+ : root_name_ (root_name), root_ns_ (root_ns)
{
type_serializer_map_instance<id, C> ().register_element (
xml::qualified_name<C> (root_name, root_ns),
@@ -534,6 +563,14 @@ namespace xsd
typeid (T),
&serializer_impl<T>);
}
+
+ template<unsigned long id, typename C, typename T>
+ element_serializer_initializer<id, C, T>::
+ ~element_serializer_initializer ()
+ {
+ type_serializer_map_instance<id, C> ().unregister_element (
+ xml::qualified_name<C> (root_name_, root_ns_), typeid (T));
+ }
}
}
}