Registration.h 632 B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include <mutex>
  3. #include <map>
  4. #include <memory>
  5. #include <IGenerator.h>
  6. #define REGISTER(CLASS) registerGenerator<CLASS>(#CLASS);
  7. namespace mdd {
  8. class Registration {
  9. private:
  10. std::map<std::string, std::shared_ptr<IGenerator>> _gens;
  11. //std::mutex _mutex;
  12. public:
  13. template<class MODULE_CLASS>
  14. void registerGenerator(const std::string& name) {
  15. auto generator = std::make_shared<Generator<MODULE_CLASS>>();
  16. if (generator != nullptr)
  17. {
  18. //_mutex.lock();
  19. _gens[name] = generator;
  20. //_mutex.unlock();
  21. }
  22. }
  23. Registration();
  24. IModule::Ptr generateModule(const std::string& name);
  25. };
  26. }