RUDelegateFactory.h 692 B

12345678910111213141516171819202122232425262728
  1. /// 代理工厂
  2. #ifndef RUDelegateFactory_h
  3. #define RUDelegateFactory_h
  4. #include "RUDefine.h"
  5. #include "RUStateDelegate.h"
  6. NS_RU_BEGIN
  7. class DelegateFactory
  8. {
  9. public:
  10. static DelegateFactory* getInstance();
  11. /// 向工厂注册一个状态代理类的注册器
  12. void registerStateDelegateCreator(const std::string& creatorKey, std::function<StateDelegate*(void)> stateDelegateCreator);
  13. StateDelegate* createStateDelegate(const std::string& creatorKey);
  14. private:
  15. DelegateFactory() = default;
  16. ~DelegateFactory() = default;
  17. private:
  18. std::map<std::string, std::function<StateDelegate*(void)>> _stateDelegateCreators;
  19. };
  20. NS_RU_END
  21. #endif /* RUDelegateFactory_h */