eis/eqpalg/utility/ExpModule.h

113 lines
2.6 KiB
C
Raw Normal View History

#pragma once
/**
* @file ExpModule.h
* @brief
* @author your name (you@domain.com)
* @version 0.1
* @date 2025-08-20
*
* Copyright: Baosight Co. Ltd.
* DO NOT COPY/USE WITHOUT PERMISSION
*
*/
#include "mix_cc/ihyper_db.h"
#include "mix_cc/json.h"
#include "mix_cc/matheval/matheval.hpp"
#include <chrono>
#include <eqpalg/utility/StatExp.hpp>
#include <log4cplus/LOG.h>
#include <map>
#include <memory>
#include <string>
#include <vector>
using std::map;
using std::string;
using std::vector;
using MExp = mix_cc::matheval::Expression;
using namespace std::chrono;
using std::chrono::system_clock;
using TimePoint = system_clock::time_point;
using TimeDur = milliseconds;
class ExpModule {
public:
ExpModule(std::map<std::string, double> &vars_ref, vector<string> &m_tags,
bool &is_exp_alg_ref);
~ExpModule();
ExpModule() = delete;
ExpModule &operator=(const ExpModule &) = delete;
/**
* @brief
* @param exp_name
* @param exp_str
* @return int
*/
int add_exp(string exp_name, string exp_str);
/**
* @brief
* @return int
*/
int update();
void fun_reset();
/**
* @brief
* @param queried_data
* @return int
*/
int update(Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> queried_data,
std::vector<TimePoint> queried_time, int row = 0);
/**
* @brief
* @param exp_name
* @return double
*/
double get_value(string exp_name);
/**
* @brief
*/
void print_value();
/**
* @brief Get the exp str object
* @param exp_name My Param doc
* @return string
*/
string get_exp_str(string exp_name);
private:
/**
* @brief
*/
void init();
/**
* @brief
*/
void refresh_exp_vars_mem();
/**
* @brief
* @param queried_data
*/
void refresh_exp_ihd_mem(
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> queried_data,
std::vector<TimePoint> queried_time, int row);
private:
map<string, double> &mm_vars;
map<string, double> exp_result_;
map<string, std::unique_ptr<MExp>> exp_ptr_;
map<string, string> exp_str_;
vector<string> &m_tags;
std::unique_ptr<LOG> logger_;
TimePoint now_time_;
/**
* @brief
*/
StatExp::FunVars fun_vars_;
bool &is_exp_alg_;
};