82 lines
1.8 KiB
C++
82 lines
1.8 KiB
C++
/*
|
|
* @Date: 2024-09-03 13:53:50
|
|
* @LastEditors: Jacky
|
|
* @LastEditTime: 2024-09-11 08:41:40
|
|
* @FilePath: /GeneralTracker/Universal/IConfiguration.h
|
|
*/
|
|
#ifndef _ICONFIGURATION__H_
|
|
#define _ICONFIGURATION__H_
|
|
|
|
#include <string>
|
|
#include <fstream>
|
|
#include <sstream>
|
|
#include <iostream>
|
|
#include <functional>
|
|
#include <list>
|
|
|
|
#include "json.hpp"
|
|
|
|
using json = nlohmann::json;
|
|
|
|
/**
|
|
* 模块配置类
|
|
*
|
|
* 1、模块定义
|
|
*
|
|
*
|
|
*/
|
|
|
|
class IConfiguration{
|
|
public:
|
|
typedef enum {
|
|
MODULE_VI = 0,
|
|
MODULE_VO,
|
|
MODULE_VENC,
|
|
MODULE_VDEC,
|
|
MODULE_VPSS,
|
|
MODULE_POST_VPSS,
|
|
MODULE_ARITH,
|
|
MODULE_OSD,
|
|
MODULE_RECORD,
|
|
MODULE_ILLEGAL = 0xff
|
|
}MODULE_TYPE_E;
|
|
|
|
typedef enum {
|
|
VI_PCIE = 0,
|
|
VI_SENSOR,
|
|
VI_DECODE
|
|
}VI_TYPE_E;
|
|
|
|
struct module_config_t{
|
|
MODULE_TYPE_E type; //类型
|
|
bool enable; //使能
|
|
bool msg_enable; //消息接收使能
|
|
std::string name; //模块名
|
|
std::string parent; // parent node
|
|
std::list<std::string> bind; // children node
|
|
|
|
bool operator<(const module_config_t&other) const{
|
|
return name < other.name;
|
|
}
|
|
};
|
|
|
|
using ConfigHandle = std::function<int(module_config_t &config)>;
|
|
IConfiguration(const std::string &configFile);
|
|
int dump();
|
|
/**
|
|
* @brief: 配置解析
|
|
* @param {ConfigHandle} func
|
|
* @return {*}
|
|
* @Date: 2024-09-03 16:51:20
|
|
*/
|
|
int parse(ConfigHandle func);
|
|
|
|
private:
|
|
int parseConfig(std::string name, ConfigHandle func);
|
|
int parseConfig(MODULE_TYPE_E type, std::string name, ConfigHandle func);
|
|
int parseModule(MODULE_TYPE_E type, json &module, module_config_t &config, std::string key);
|
|
std::string _config_file = "";
|
|
json _config_json;
|
|
};
|
|
|
|
#endif |