AuditPlugin.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef __AUDITPLUGIN_HPP_
  2. #define __AUDITPLUGIN_HPP_
  3. #include <iostream>
  4. #include "UtilBase.hpp"
  5. #include "Network/Socket.h"
  6. #include <mutex>
  7. #include <condition_variable>
  8. #include <future>
  9. #include "Util/logger.h"
  10. #include "Poller/Timer.h"
  11. #include <vector>
  12. #include "PluginSubscriber.hpp"
  13. #include "PuginFactory.hpp"
  14. using namespace std;
  15. using namespace toolkit;
  16. namespace gsd
  17. {
  18. class AuditPlugin: public PluginSubscriber<AuditPlugin>, public PluginBase
  19. {
  20. private:
  21. AuditPlugin(): PluginBase(){
  22. }
  23. public:
  24. using Ptr = std::shared_ptr<AuditPlugin>;
  25. /**
  26. * @description: 获取Ptr
  27. * @return {*}
  28. */
  29. static std::shared_ptr<AuditPlugin> getPtr();
  30. /**
  31. * @description: Init
  32. * @return {*}
  33. */
  34. virtual bool Init();
  35. /**
  36. * @description: StartTask
  37. * @return {*}
  38. */
  39. virtual bool StartTask();
  40. /**
  41. * @description: Alive
  42. * @return {*}
  43. */
  44. virtual bool Alive();
  45. /**
  46. * @description: 释放资源
  47. * @return {*}
  48. */
  49. virtual void Destroy();
  50. /**
  51. * @description: RestPlugin
  52. * @return {*}
  53. */
  54. virtual bool RestPlugin(){
  55. return true;
  56. }
  57. /**
  58. * @description: PluginTaskCheck
  59. * @return {*}
  60. */
  61. virtual bool PluginTaskCheck();
  62. /**
  63. * @description: ~AuditPlugin
  64. * @return {*}
  65. */
  66. ~AuditPlugin(){
  67. InfoL;
  68. this->Destroy();
  69. }
  70. private:
  71. Timer::Ptr timer = nullptr;
  72. unordered_map<std::string, std::function<std::shared_ptr<PluginBase>()>> map_;
  73. std::shared_ptr<ThreadPool> pool = nullptr;
  74. };
  75. } // namespace gsd
  76. #endif