21 #ifndef GNASH_FACTORY_H
22 #define GNASH_FACTORY_H
32 #include <boost/type_traits.hpp>
33 #include <boost/utility/enable_if.hpp>
55 template<
typename T,
typename Init =
void,
typename Key = std::
string>
63 template<
typename Derived>
75 typedef T*(*CreateHandler)();
76 typedef std::map<std::string, CreateHandler>
Handlers;
87 template<
typename Iterator>
88 void listKeys(Iterator
i,
typename boost::enable_if<boost::is_same<
89 typename std::iterator_traits<Iterator>::iterator_category,
90 std::output_iterator_tag> >::
type* dummy = 0) {
92 static_cast<void>(dummy);
93 std::transform(_handlers.begin(), _handlers.end(),
i,
94 boost::bind(&Handlers::value_type::first,
_1));
106 return _handlers.empty() ? 0 : _handlers.begin()->second();
109 typename Handlers::const_iterator it = _handlers.find(
name);
110 if (it == _handlers.end())
return 0;