PacketDispatcherFactory.cpp 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "stdafx.h"
  2. #include "PacketDispatcherFactory.h"
  3. #include "PacketDispatcher.h"
  4. using namespace DIOS::Dev::Detail::MachineryECOM;
  5. PacketDispatcherFactory *PacketDispatcherFactory::m_instance = nullptr;
  6. PacketDispatcherFactory::PacketDispatcherFactory()
  7. {
  8. }
  9. PacketDispatcherFactory::~PacketDispatcherFactory()
  10. {
  11. }
  12. PacketDispatcherFactory *PacketDispatcherFactory::Instance()
  13. {
  14. if (m_instance == nullptr)
  15. {
  16. m_instance = new PacketDispatcherFactory();
  17. }
  18. return m_instance;
  19. }
  20. IPacketDispatcher *PacketDispatcherFactory::CreateSingleton(const std::string &typeName)
  21. {
  22. if (m_dispatchers.find(typeName) != m_dispatchers.end())
  23. {
  24. return m_dispatchers[typeName];
  25. }
  26. IPacketDispatcher *dispatcher = nullptr;
  27. if (typeName == GENERAL_DISPATCHER)
  28. {
  29. dispatcher = new PacketDispatcher();
  30. m_dispatchers.insert(make_pair(typeName, dispatcher));
  31. }
  32. return dispatcher;
  33. }