#ifndef _DATA_MAPPER_H
#define _DATA_MAPPER_H

#include "cpp/data_praser.h"
#include <jni.h>
#include <android/log.h>
#include <vector>
#include <variant>
#include <stdexcept>
#include <map>

// 数据映射器类
class Mapper
{
private:
    // 私有成员变量（如果需要的话）

public:
    // 构造函数和析构函数
    Mapper();
    ~Mapper();
    
    // 主要映射函数
    SensorData DataMapper(SensorData& data);
    
    // 各种设备类型的映射函数
    SensorData EEG_Data_Mapper(SensorData& data);
    SensorData ECG_2LEAD_Data_Mapper(SensorData& data);
    SensorData ECG_12LEAD_Data_Mapper(SensorData& data);
    SensorData PPG_Data_Mapper(SensorData& data);
    SensorData Respiration_Data_Mapper(SensorData& data);
    SensorData Snore_Data_Mapper(SensorData& data);
    SensorData Stethoscope_Data_Mapper(SensorData& data);
};

// JNI函数声明
extern "C" {
    // 创建数据映射器实例
    JNIEXPORT jlong JNICALL Java_com_example_cmake_1project_1test_DataMapper_createDataMapper(JNIEnv* env, jobject thiz);
    
    // 销毁数据映射器实例
    JNIEXPORT void JNICALL Java_com_example_cmake_1project_1test_DataMapper_destroyDataMapper(JNIEnv* env, jobject thiz, jlong mapperHandle);
    
    // 映射单个数据包
    JNIEXPORT jobject JNICALL Java_com_example_cmake_1project_1test_DataMapper_mapSensorData(JNIEnv* env, jobject thiz, jlong mapperHandle, jobject sensorData);
    
    // 批量映射数据包
    JNIEXPORT jobject JNICALL Java_com_example_cmake_1project_1test_DataMapper_mapSensorDataList(JNIEnv* env, jobject thiz, jlong mapperHandle, jobject sensorDataList);
}

// 辅助函数声明
jobject convertSensorDataToJava(JNIEnv* env, const SensorData& sensorData);
std::vector<SensorData> convertJavaSensorDataListToVector(JNIEnv* env, jobject sensorDataList);
jobject convertSensorDataVectorToJavaList(JNIEnv* env, const std::vector<SensorData>& sensorDataVector);
SensorData convertJavaSensorDataToCpp(JNIEnv* env, jobject javaSensorData);
std::vector<float> convertJavaFloatListToVector(JNIEnv* env, jobject floatList);

#endif