#pragma once

#include <iostream>
#include <map>
#include <time.h>
#include <dirent.h>
#include <time.h>
#include <cstdlib>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include "Util/logger.h"
#include "Util/NoticeCenter.h"
#include "Poller/EventPoller.h"
#include "Player/PlayerProxy.h"
#include "Rtmp/RtmpPusher.h"
#include "Common/config.h"
#include "Pusher/MediaPusher.h"
#include "Extension/Frame.h"
#include "Util/SqlPool.h"
#include "Network/TcpClient.h"
#include "Poller/Timer.h"
// opencv
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/types_c.h>
#include "Util/logger.h"
#include <cstdlib>
#include "recorder.h"

using namespace toolkit;
using namespace std;


namespace MIVA
{
    class Cleaner
    {
    public:
        using Ptr = std::shared_ptr<Cleaner>;
        int ClearType = 1;  // 清理类型  0   - 不清除记录
                            //           1   - 超过设定阈值就删除第一个,保持不超过阈值
                            //           2   - 超过设定阈值,直接删除全部记录
                            //           3   - 设定时间,如只保留前多少小时的数据

        int recordMax = 100;
 
        int validTime = 1; // 有效时间 时间单位 天
    public:
        Cleaner();
        ~Cleaner();

        /**
         * @description: 单例
         * @param {*}
         * @return {*}
         */ 
        static std::shared_ptr<Cleaner> CreateNew();

        /**
         * @description: 清除历史记录
         * @param {*}
         * @return {*}
         */        
        int32_t ClearHistory();
    protected:
        int rmDir(std::string file_name);
    };

} // namespace MIVA