CMessageBox.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. //#pragma warning(disable:4251)
  3. #include <vector>
  4. #include <mutex>
  5. #include <map>
  6. #include "string.h"
  7. #include "dt.h"
  8. #include "CLog.h"
  9. typedef enum
  10. {
  11. CLOSE_BUTTON = 0x1, //关闭
  12. STOP_BUTTON = 0x2, //终止
  13. REPEAT_BUTTON = 0x4,//重复
  14. IGNORE_BUTTON = 0x8,//忽略
  15. }BUTTON_TYPE;
  16. typedef struct
  17. {
  18. int eViewButton; //弹框需显示的按钮(BUTTON_TYPE)的组合
  19. LogStream::LogLevel iLevel; //报警级别
  20. long iId; //报警Id
  21. std::string strDescribe; //报警描述
  22. std::string strTip; //报警提示
  23. std::string strHelp; //报警帮助信息
  24. }MESSAGE_INFO;
  25. //报警弹框回调函数
  26. typedef BUTTON_TYPE(*CallMessageBox) (MESSAGE_INFO stMsgInfo);
  27. class __declspec(dllexport) CMessageBox
  28. {
  29. private:
  30. static std::mutex m_Mutex;
  31. static CMessageBox* m_pMessageBox;
  32. std::vector<MESSAGE_INFO> m_vecMessageBox;
  33. CallMessageBox m_funCallMessageBox = nullptr;
  34. std::mutex m_PopBoxMutex;
  35. //用于消息发布
  36. //void* m_pPubSocket;
  37. //void* m_pSubscriberSocket;
  38. long Init();
  39. void AddPopMassage(MESSAGE_INFO stMsgInfo);
  40. void ErasePopMassage(int iId);
  41. public:
  42. // 获取单实例对象
  43. static long GetInstance(CMessageBox** pMsgBox);
  44. void SetCallMessageBoxFunc(CallMessageBox func);
  45. void ClearAllPopMassage();
  46. BUTTON_TYPE PopMassageBox(int eViewButton, LogStream::LogLevel iLevel, long iId,
  47. std::string strDescribe, std::string strTip="", std::string strHelp = "");
  48. };