21 #ifndef GNASH_FACTORY_H 22 #define GNASH_FACTORY_H 32 #include <type_traits> 54 template<
typename T,
typename Init,
typename Key>
62 template<
typename Derived>
74 typedef T*(*CreateHandler)();
75 typedef std::map<std::string, CreateHandler>
Handlers;
86 template<
typename Iterator>
89 typedef typename std::iterator_traits<Iterator>::iterator_category cat;
90 static_assert(std::is_same<cat, std::output_iterator_tag>::value,
91 "i must be an output iterator.");
93 std::transform(_handlers.begin(), _handlers.end(),
i,
106 return _handlers.empty() ?
nullptr : _handlers.begin()->second();
109 typename Handlers::const_iterator it = _handlers.find(
name);
110 if (it == _handlers.end())
return nullptr;
T value_type
Definition: GnashFactory.h:59
void registerHandler(const Key &name, CreateHandler r)
Register a Handler with a particular name.
Definition: GnashFactory.h:120
static GnashFactory & instance()
Get the GnashFactory singleton.
Definition: GnashFactory.h:78
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
RegisterHandler(const Key &name)
Definition: GnashFactory.h:69
Definition: GnashKey.h:164
Definition: GnashFactory.h:63
#define DSOEXPORT
Definition: dsodefs.h:55
Definition: GnashKey.h:132
Key key_type
Definition: GnashFactory.h:60
Definition: GnashKey.h:155
void listKeys(Iterator i)
Dump the registered keys to the iterator.
Definition: GnashFactory.h:88
static T * createHandler()
Definition: GnashFactory.h:65
std::map< std::string, CreateHandler > Handlers
Definition: GnashFactory.h:75
Definition: GnashKey.h:159
A generic factory class for registering and retrieving objects by key.
Definition: GnashFactory.h:55
Definition: GnashKey.h:95
std::string name
Definition: LocalConnection_as.cpp:149