19#ifndef CLASSREGISTRY_H
20#define CLASSREGISTRY_H
36#define REGISTER_CLASS(BASE, TYPE, KEY, REGISTRY) \
37 static ClassRegistration<BASE> _class_registration_ ## TYPE(REGISTRY, &ClassRegistry<BASE>::factory<TYPE>, KEY);
50 typedef T* (*Factory)(void);
56 template<
class Sub
class>
79 if (!m_items.contains(key))
82 return m_items[key]();
107 registry->
add(factory, key);
ClassRegistration(ClassRegistry< T > *registry, typename ClassRegistry< T >::Factory factory, const QString &key)
Definition classregistry.h:103
A class for creating objects based on the class' runtime name or key (a string).
Definition classregistry.h:47
const QMap< QString, Factory > & items() const
Definition classregistry.h:63
void add(Factory f, const QString &key)
Definition classregistry.h:68
T *(* Factory)(void)
Definition classregistry.h:50
static T * factory()
Definition classregistry.h:57
T * create(const QString &key)
Definition classregistry.h:77