mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2025-01-11 04:21:08 +00:00
46 lines
930 B
C
46 lines
930 B
C
|
|
||
|
#if !defined(INCLUDED_MODULESYSTEM_MODULEREGISTRY_H)
|
||
|
#define INCLUDED_MODULESYSTEM_MODULEREGISTRY_H
|
||
|
|
||
|
#include "generic/static.h"
|
||
|
#include <list>
|
||
|
|
||
|
class ModuleRegisterable
|
||
|
{
|
||
|
public:
|
||
|
virtual void selfRegister() = 0;
|
||
|
};
|
||
|
|
||
|
class ModuleRegistryList
|
||
|
{
|
||
|
typedef std::list<ModuleRegisterable*> RegisterableModules;
|
||
|
RegisterableModules m_modules;
|
||
|
public:
|
||
|
void addModule(ModuleRegisterable& module)
|
||
|
{
|
||
|
m_modules.push_back(&module);
|
||
|
}
|
||
|
void registerModules() const
|
||
|
{
|
||
|
for(RegisterableModules::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i)
|
||
|
{
|
||
|
(*i)->selfRegister();
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
typedef SmartStatic<ModuleRegistryList> StaticModuleRegistryList;
|
||
|
|
||
|
|
||
|
class StaticRegisterModule : public StaticModuleRegistryList
|
||
|
{
|
||
|
public:
|
||
|
StaticRegisterModule(ModuleRegisterable& module)
|
||
|
{
|
||
|
StaticModuleRegistryList::instance().addModule(module);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif
|