Cleaner.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include <iostream>
  3. #include <map>
  4. #include <time.h>
  5. #include <dirent.h>
  6. #include <time.h>
  7. #include <cstdlib>
  8. #include <dirent.h>
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <unistd.h>
  12. #include "Util/logger.h"
  13. #include "Util/NoticeCenter.h"
  14. #include "Poller/EventPoller.h"
  15. #include "Util/SqlPool.h"
  16. #include "Network/TcpClient.h"
  17. #include "Poller/Timer.h"
  18. // opencv
  19. #include <opencv2/core.hpp>
  20. #include <opencv2/videoio.hpp>
  21. #include <opencv2/highgui.hpp>
  22. #include <opencv2/imgproc.hpp>
  23. #include <opencv2/imgproc/types_c.h>
  24. #include "Util/logger.h"
  25. #include <cstdlib>
  26. #include "recorder.h"
  27. using namespace toolkit;
  28. using namespace std;
  29. namespace gsd_ds
  30. {
  31. class Cleaner
  32. {
  33. public:
  34. using Ptr = std::shared_ptr<Cleaner>;
  35. int ClearType = 1; // 清理类型 0 - 不清除记录
  36. // 1 - 超过设定阈值就删除第一个,保持不超过阈值
  37. // 2 - 超过设定阈值,直接删除全部记录
  38. // 3 - 设定时间,如只保留前多少小时的数据
  39. int recordMax = 100;
  40. int validTime = 1; // 有效时间 时间单位 天
  41. public:
  42. Cleaner();
  43. ~Cleaner();
  44. /**
  45. * @description: 单例
  46. * @param {*}
  47. * @return {*}
  48. */
  49. static std::shared_ptr<Cleaner> CreateNew();
  50. /**
  51. * @description: 清除历史记录
  52. * @param {*}
  53. * @return {*}
  54. */
  55. int32_t ClearHistory();
  56. protected:
  57. int rmDir(std::string file_name);
  58. };
  59. } // namespace gsd_ds