Go to the documentation of this file.
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;
static T * createHandler()
Definition: GnashFactory.h:65
std::string name
Definition: LocalConnection_as.cpp:149
T value_type
Definition: GnashFactory.h:59
@ T
Definition: GnashKey.h:132
@ i
Definition: GnashKey.h:155
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
@ m
Definition: GnashKey.h:159
void registerHandler(const Key &name, CreateHandler r)
Register a Handler with a particular name.
Definition: GnashFactory.h:120
@ r
Definition: GnashKey.h:164
Definition: GnashFactory.h:64
T * get(const Key &name)
Return a Handler identified by a name.
Definition: GnashFactory.h:103
@ _1
Definition: GnashKey.h:95
RegisterHandler(const Key &name)
Definition: GnashFactory.h:69
std::map< std::string, CreateHandler > Handlers
Definition: GnashFactory.h:75
void listKeys(Iterator i)
Dump the registered keys to the iterator.
Definition: GnashFactory.h:88
A generic factory class for registering and retrieving objects by key.
Definition: GnashFactory.h:56
static GnashFactory & instance()
Get the GnashFactory singleton.
Definition: GnashFactory.h:78
#define DSOEXPORT
Definition: dsodefs.h:55
Key key_type
Definition: GnashFactory.h:60