#ifndef __BUILDER_EXPORT_H__
#define __BUILDER_EXPORT_H__

#include <algorithm>
#include <fstream>
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include <variant>
#include <vector>

#include <gio/gio.h>
#include <json/json.h>
#include <ostree.h>
#include <yaml-cpp/yaml.h>

#include "KMBuilderCache.h"
#include "KMBuilderConfigTypes.h"
#include "KMBuilderContext.h"
#include "KMBuilderGlobal.h"
#include "KMBuilderUtils.h"
#include "common/KMLogger.h"

using namespace std;

/*
类名: KMBuilderExport
功能: 用于处理export过程
成员变量:
   - shared_ptr<ConfigData> m_pConfigData;       	        //ConfigData配置文件指针
   - shared_ptr<KMBuilderCache> m_pKMBuilderCache; 	        //KMBuilderCache指针
   - BuilderCache m_builderCache;               	        //BuilderCache结构体
   - KMBuilderModule *m_pBuilderModule; 			        //BuilderModule私有嵌套BuilderModuleData
   - shared_ptr<BuilderModuleData> m_pBuilderModuleData;	//BuilderModuleData指针
   - string m_exportRepo                                      //export导出路径
成员函数:
   - 省略
*/

class KMBuilderExport
{
public:
    KMBuilderExport(shared_ptr<KMBuilderCache> cache);
    virtual ~KMBuilderExport();

public:
    /**
     * @brief : 执行导出阶段
     * @return: true-成功; false-失败
     */
    bool exportStage();

    /**
     * @brief : 查询builderExtension路径
     * @return : 返回vector
     */
    vector<string> configGetExcludeDirs();

    /**
     * @brief : 参数拼接并且最终执行export
     * @return :
     */
    bool doExport(bool runtime, string location, string directory, vector<string> excludeDirs, string branch, string collectionId, int tokenType, vector<string> extrArgs);

private:
    shared_ptr<ConfigData> m_pConfigData;               // ConfigData配置文件指针
    shared_ptr<KMBuilderCache> m_pKMBuilderCache;       // KMBuilderCache指针
    BuilderCache m_builderCache;                        // BuilderCache结构体
    KMBuilderModule *m_pBuilderModule;                  // BuilderModule私有嵌套BuilderModuleData
    shared_ptr<BuilderModuleData> m_pBuilderModuleData; // BuilderModuleData指针
    // export过程使用
    string m_exportRepo; // export导出路径
};

#endif /* __BUILDER_EXPORT_H__ */
