1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #ifndef __PUGINFACTORY_HPP_
- #define __PUGINFACTORY_HPP_
- #include <iostream>
- #include "Util/logger.h"
- #include <unordered_map>
- #include <map>
- #include "UtilBase.hpp"
- #include <vector>
- using namespace toolkit;
- using namespace std;
- namespace gsd
- {
- class PuginFactory
- {
- private:
- PuginFactory(){}
- public:
- using Ptr = std::shared_ptr<PuginFactory>;
- /**
- * @description: getPtr
- * @return {*}
- */
- static std::shared_ptr<PuginFactory> getPtr(){
- static std::shared_ptr<PuginFactory> PuginFactory_ = nullptr;
- if(PuginFactory_ == nullptr) PuginFactory_ = std::shared_ptr<PuginFactory>(new PuginFactory);
- return PuginFactory_;
- }
- /**
- * @description:
- * @return {*}
- */
- bool Regist(const std::string& Type, std::function<std::shared_ptr<gsd::PluginBase>()> pFunc){
- InfoL << Type << endl;
- if(pFunc == nullptr) return false;
- bool ret = _map.insert(std::make_pair(Type, pFunc)).second;
- return true;
- }
- /**
- * @description: getMap
- * @return {*}
- */
- unordered_map<std::string, std::function<std::shared_ptr<PluginBase>()>> getMap(){
- return _map;
- }
-
- /**
- * @description: ~PuginFactory
- * @return {*}
- */
- ~PuginFactory(){
- }
- protected:
- unordered_map<std::string, std::function<std::shared_ptr<PluginBase>()>> _map;
- };
- } // namespace gsd
- #endif
|