From ee4eb695119bce96515b330f9fc83ddd67da5c62 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 2 Dec 2009 12:26:05 +0200 Subject: Implement de-registering polymorphic type information This is required for DLL/shared library unloading. --- libxsd/xsd/cxx/tree/type-factory-map.txx | 47 +++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'libxsd/xsd/cxx/tree/type-factory-map.txx') diff --git a/libxsd/xsd/cxx/tree/type-factory-map.txx b/libxsd/xsd/cxx/tree/type-factory-map.txx index 215f033..ee376f8 100644 --- a/libxsd/xsd/cxx/tree/type-factory-map.txx +++ b/libxsd/xsd/cxx/tree/type-factory-map.txx @@ -234,6 +234,13 @@ namespace xsd template void type_factory_map:: + unregister_type (const qualified_name& name) + { + type_map_.erase (name); + } + + template + void type_factory_map:: register_element (const qualified_name& root, const qualified_name& subst, factory f) @@ -242,6 +249,22 @@ namespace xsd } template + void type_factory_map:: + unregister_element (const qualified_name& root, + const qualified_name& subst) + { + typename element_map::iterator i (element_map_.find (root)); + + if (i != element_map_.end ()) + { + i->second.erase (subst); + + if (i->second.empty ()) + element_map_.erase (i); + } + } + + template typename type_factory_map::factory type_factory_map:: find (const qualified_name& name) const { @@ -416,6 +439,7 @@ namespace xsd template type_factory_initializer:: type_factory_initializer (const C* name, const C* ns) + : name_ (name), ns_ (ns) { type_factory_map_instance ().register_type ( xml::qualified_name (name, ns), &factory_impl); @@ -423,14 +447,35 @@ namespace xsd template type_factory_initializer:: - type_factory_initializer (const C* root_name, const C* root_ns, + ~type_factory_initializer () + { + type_factory_map_instance ().unregister_type ( + xml::qualified_name (name_, ns_)); + } + + // + // + template + element_factory_initializer:: + element_factory_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), + subst_name_ (subst_name), subst_ns_ (subst_ns) { type_factory_map_instance ().register_element ( xml::qualified_name (root_name, root_ns), xml::qualified_name (subst_name, subst_ns), &factory_impl); } + + template + element_factory_initializer:: + ~element_factory_initializer () + { + type_factory_map_instance ().unregister_element ( + xml::qualified_name (root_name_, root_ns_), + xml::qualified_name (subst_name_, subst_ns_)); + } } } } -- cgit v1.1