c++boos库学习-08-自己封装一个服务

#include <iostream>
using namespace std;
#include <map>
#include <string>
#include <memory>
#include <boost/signals2.hpp>
using namespace boost::signals2;
#include <functional>
#include <windows.h>
#include <mutex>

class TyService;
class TyService_Manager
{
   
    
    
private:
	TyService_Manager() = default;
public:
	static auto GetInstance()
	{
   
    
    
		TyService_Manager s;
		return &s;
	}

	void RegisterService(string strService,std::shared_ptr<TyService> spService)
	{
   
    
    
		m_mapServices[strService] = spService;
	}

	auto GetService(string strServicename)->std::shared_ptr<TyService>
	{
   
    
    
		auto it = m_mapServices.find(strServicename);
		if (it != m_mapServices.end())
		{
   
    
    
			return it->second;
		}
		else
		{
   
    
    
			return nullptr;
		}
	

猜你喜欢

转载自blog.csdn.net/FairLikeSnow/article/details/130838221