aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/tree/type-factory-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-factory-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-factory-map.txx')
-rw-r--r--libxsd/xsd/cxx/tree/type-factory-map.txx47
1 files changed, 46 insertions, 1 deletions
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 <typename C>
void type_factory_map<C>::
+ unregister_type (const qualified_name& name)
+ {
+ type_map_.erase (name);
+ }
+
+ template <typename C>
+ void type_factory_map<C>::
register_element (const qualified_name& root,
const qualified_name& subst,
factory f)
@@ -242,6 +249,22 @@ namespace xsd
}
template <typename C>
+ void type_factory_map<C>::
+ 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 C>
typename type_factory_map<C>::factory type_factory_map<C>::
find (const qualified_name& name) const
{
@@ -416,6 +439,7 @@ namespace xsd
template<unsigned long id, typename C, typename T>
type_factory_initializer<id, C, T>::
type_factory_initializer (const C* name, const C* ns)
+ : name_ (name), ns_ (ns)
{
type_factory_map_instance<id, C> ().register_type (
xml::qualified_name<C> (name, ns), &factory_impl<T>);
@@ -423,14 +447,35 @@ namespace xsd
template<unsigned long id, typename C, typename T>
type_factory_initializer<id, C, T>::
- type_factory_initializer (const C* root_name, const C* root_ns,
+ ~type_factory_initializer ()
+ {
+ type_factory_map_instance<id, C> ().unregister_type (
+ xml::qualified_name<C> (name_, ns_));
+ }
+
+ //
+ //
+ template<unsigned long id, typename C, typename T>
+ element_factory_initializer<id, C, T>::
+ 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<id, C> ().register_element (
xml::qualified_name<C> (root_name, root_ns),
xml::qualified_name<C> (subst_name, subst_ns),
&factory_impl<T>);
}
+
+ template<unsigned long id, typename C, typename T>
+ element_factory_initializer<id, C, T>::
+ ~element_factory_initializer ()
+ {
+ type_factory_map_instance<id, C> ().unregister_element (
+ xml::qualified_name<C> (root_name_, root_ns_),
+ xml::qualified_name<C> (subst_name_, subst_ns_));
+ }
}
}
}