You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.2 KiB
C++

#pragma once
#include <string>
#include <vector>
#include "KeyValueStruct.h"
#include "DllDefines.h"
namespace nsTrace
{
using stTrace = struct
{
std::vector<nsKeyValue::stKeyValueBool> Trace;
std::vector<nsKeyValue::stKeyValueBool> TraceTiming;
};
}
namespace nsTrace
{
using namespace nlohmann;
using namespace nsUtils;
void from_json(const json& j, stTrace& x);
void to_json(json& j, const stTrace& x);
inline void from_json(const json& j, stTrace& x)
{
getValue(j, "Trace", x.Trace);
getValue(j, "TraceTiming", x.TraceTiming);
}
inline void to_json(json& j, const stTrace& x)
{
j = nlohmann::json{
{ "Trace", x.Trace },
{ "TraceTiming", x.TraceTiming }
};
}
}
namespace nsTraceConfig
{
const std::string HARDWARE_TRACE_CONFIG = "d:/machine/config/trace/hardwareTrace.json";
const std::string CLASS_TRACE_CONFIG = "d:/machine/config/trace/classTrace.json";
const std::string MODULE_TRACE_CONFIG = "d:/machine/config/trace/hardwareTrace.json";
}
class UTILITYDLL CTraceConfig
{
public:
/**
* @brief
* @summary
* @param strFilePath Name of Trace file. eg: d:/machine/config/trace/HardwareTrace.json, d:/machine/config/trace/ModuleTrace.json, d:/machine/config/trace/classTrace.json
*/
CTraceConfig(const std::string& strFilePath);
virtual ~CTraceConfig();
/**
* @brief Init Memory Parameters
*/
void InitParameters();
/**
* @brief Get config object
* @return nsTrace::stTrace object (read Only)
*/
const nsTrace::stTrace& Get();
/**
* @brief Check Trace Enable
* @param strName Name of Trace
* @return true=enable trace
*/
bool IsTrace(const std::string& strName);
/**
* @brief Check Trace Timing Enable
* @param strName Name of Trace Data
* @return true=enable trace data
*/
bool IsTraceTiming(const std::string& strName);
private:
/**
* @brief Load config from file
* @param strFilePath File Path to load from
*/
void Load(const std::string& strFilePath);
std::string m_strFilePath;
nsTrace::stTrace m_config;
};