#include "stdafx.h" #include "PacketDispatcherFactory.h" #include "PacketDispatcher.h" using namespace DIOS::Dev::Detail::MachineryECOM; PacketDispatcherFactory *PacketDispatcherFactory::m_instance = nullptr; PacketDispatcherFactory::PacketDispatcherFactory() { } PacketDispatcherFactory::~PacketDispatcherFactory() { } PacketDispatcherFactory *PacketDispatcherFactory::Instance() { if (m_instance == nullptr) { m_instance = new PacketDispatcherFactory(); } return m_instance; } IPacketDispatcher *PacketDispatcherFactory::CreateSingleton(const std::string &typeName) { if (m_dispatchers.find(typeName) != m_dispatchers.end()) { return m_dispatchers[typeName]; } IPacketDispatcher *dispatcher = nullptr; if (typeName == GENERAL_DISPATCHER) { dispatcher = new PacketDispatcher(); m_dispatchers.insert(make_pair(typeName, dispatcher)); } return dispatcher; }