SerializableFactory.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2021-04-24
  6. * Changed: 2021-04-24
  7. *
  8. * */
  9. #ifndef LS_STD_SERIALIZABLE_FACTORY_HPP
  10. #define LS_STD_SERIALIZABLE_FACTORY_HPP
  11. #include <ls_std/base/Class.hpp>
  12. #include <map>
  13. #include <string>
  14. #include <memory>
  15. #include <ls_std/factory/IFactory.hpp>
  16. namespace ls_std
  17. {
  18. class SerializableFactory : public ls_std::Class
  19. {
  20. public:
  21. SerializableFactory();
  22. ~SerializableFactory() override = default;
  23. bool addFactory(const std::pair<std::string, std::shared_ptr<ls_std::IFactory>> &_factoryInsertion);
  24. std::shared_ptr<ls_std::Class> build(const std::string &_relatedObjectName);
  25. bool clear();
  26. bool hasFactory(const std::string &_relatedObjectName);
  27. bool removeFactory(const std::string &_relatedObjectName);
  28. private:
  29. std::map<std::string, std::shared_ptr<ls_std::IFactory>> factories{};
  30. bool _hasFactory(const std::string &_relatedObjectName);
  31. void _init();
  32. };
  33. }
  34. #endif