1234567891011121314151617181920212223242526272829303132333435363738 |
- #pragma once
- #include <map>
- #include <string>
- #include "IGenerator.h"
- namespace mdd
- {
- template <class MODULE_CLASS>
- class Generator
- : public IGenerator
- {
- virtual std::shared_ptr<IModule> Generate()
- {
- return std::make_shared<MODULE_CLASS>();
- }
- };
- std::map<std::string, std::shared_ptr<IGenerator>>&
- GetGenerators(
- const std::string& name = "",
- const std::shared_ptr<IGenerator>& generator = nullptr);
- template<class MODULE_CLASS>
- class GeneratorRegistration
- {
- public:
- GeneratorRegistration(const std::string& name)
- {
- GetGenerators(name.substr(6), std::make_shared<Generator<MODULE_CLASS>>());
- }
- };
- }
- #define ADD_GENERATOR(CLASS) namespace{mdd::GeneratorRegistration<CLASS> reg_sdewfdsf(typeid(CLASS).name());}
|