// file : xsd/cxx/tree/type-factory-map.hxx // author : Boris Kolpackov // copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_TREE_TYPE_FACTORY_MAP_HXX #define XSD_CXX_TREE_TYPE_FACTORY_MAP_HXX #include #include #include // std::auto_ptr #include // std::size_t #include #include #include namespace xsd { namespace cxx { namespace tree { template struct type_factory_map { typedef xml::qualified_name qualified_name; typedef std::auto_ptr (*factory) (const xercesc::DOMElement&, flags, container*); public: type_factory_map (); void register_type (const qualified_name& name, factory, bool override = true); void unregister_type (const qualified_name& name); void register_element (const qualified_name& root, const qualified_name& subst, factory); void unregister_element (const qualified_name& root, const qualified_name& subst); std::auto_ptr create (const C* name, // element name const C* ns, // element namespace factory static_type, bool global, bool qualified, const xercesc::DOMElement&, const qualified_name&, flags, container*) const; public: factory find (const qualified_name& name) const; private: template static std::auto_ptr traits_adapter (const xercesc::DOMElement&, flags, container*); private: typedef std::map type_map; // Map of (root-element to map of (subst-element to factory)). // typedef std::map subst_map; typedef std::map element_map; type_map type_map_; element_map element_map_; private: factory find_substitution (const subst_map& start, const qualified_name& name) const; // The name argument is as specified in xsi:type. // factory find_type (const std::basic_string& name, const xercesc::DOMElement&) const; }; // // template struct type_factory_plate { static type_factory_map* map; static std::size_t count; type_factory_plate (); ~type_factory_plate (); }; template type_factory_map* type_factory_plate::map = 0; template std::size_t type_factory_plate::count = 0; // // template inline type_factory_map& type_factory_map_instance () { return *type_factory_plate::map; } // // template std::auto_ptr factory_impl (const xercesc::DOMElement&, flags, container*); // // template struct type_factory_initializer { type_factory_initializer (const C* name, const C* ns); ~type_factory_initializer (); private: const C* name_; const C* ns_; }; // // template struct element_factory_initializer { element_factory_initializer (const C* root_name, const C* root_ns, const C* subst_name, const C* subst_ns); ~element_factory_initializer (); private: const C* root_name_; const C* root_ns_; const C* subst_name_; const C* subst_ns_; }; } } } #include #endif // XSD_CXX_TREE_TYPE_FACTORY_MAP_HXX