427 lines
27 KiB
C++
427 lines
27 KiB
C++
/*
|
||
* 说明: sysset表
|
||
*
|
||
* 作者: 杨海洋
|
||
* 日期: 2023-07-27
|
||
*/
|
||
|
||
#ifndef SYSSETTABLE_H
|
||
#define SYSSETTABLE_H
|
||
|
||
#include "IDBTable.h"
|
||
|
||
class JUDGE_API SysSetTable : public IDBTable
|
||
{
|
||
enum asType
|
||
{
|
||
type_null,
|
||
type_string,
|
||
type_bool,
|
||
type_int,
|
||
type_int64,
|
||
type_real,
|
||
type_array,
|
||
type_array2,
|
||
type_array_int,
|
||
type_array2_int,
|
||
};
|
||
|
||
class JUDGE_API TAny
|
||
{
|
||
public:
|
||
TAny() : type(type_null) {}
|
||
virtual ~TAny() {}
|
||
TAny(const std::string& val) { set(val, type_string); }
|
||
template<typename... Args>
|
||
bool setValue(const std::string& val, Args... args) { return set(val, args...); }
|
||
const std::string& value() const { TASSERT(type != type_null, ""); return vValue; }
|
||
const std::string& asString() const { TASSERT(type == type_string, ""); return vValue; }
|
||
bool asBool () const { TASSERT(type == type_bool, ""); return base.vBool; }
|
||
int asInt () const { TASSERT(type == type_int, ""); return base.vInt; }
|
||
int64 asInt64 () const { TASSERT(type == type_int64, ""); return base.vInt64; }
|
||
float asFloat () const { TASSERT(type == type_real, ""); return static_cast<float>(base.vReal); }
|
||
double asDouble() const { TASSERT(type == type_real, ""); return base.vReal; }
|
||
const std::vector<std::string>& asArray() const { TASSERT(type == type_array, ""); return vArray; }
|
||
const std::vector<std::vector<std::string>>& asArray2() const { TASSERT(type == type_array2, ""); return vArray2; }
|
||
const std::vector<int>& asArrayInt() const { TASSERT(type == type_array_int, ""); return vArrayInt; }
|
||
const std::vector<std::vector<int>>& asArray2Int() const { TASSERT(type == type_array2_int, ""); return vArray2Int; }
|
||
|
||
bool isString() const { return type == type_string; }
|
||
bool isBool () const { return type == type_bool; }
|
||
bool isInt () const { return type == type_int; }
|
||
bool isInt64 () const { return type == type_int64; }
|
||
bool isFloat () const { return type == type_real; }
|
||
bool isDouble() const { return type == type_real; }
|
||
bool isArray() const { return type == type_array; }
|
||
bool isArray2() const { return type == type_array2; }
|
||
bool isArrayInt() const { return type == type_array_int; }
|
||
bool isArray2Int() const { return type == type_array2_int; }
|
||
|
||
template<typename T> T as() const JUDGE_TEMPLATE_DELETE; //始终总是返回有值支持的类型:bool,int,int64,float,double,string
|
||
template<typename T> bool is() const JUDGE_TEMPLATE_DELETE;
|
||
private:
|
||
bool set(const std::string& val, asType ty = type_string, const std::string& d1 = "", const std::string& d2 = "")
|
||
{
|
||
type = ty;
|
||
vValue = val;
|
||
switch(type)
|
||
{
|
||
case type_null:
|
||
TASSERT_BOOL(false, "type error!");
|
||
break;
|
||
case type_string:
|
||
vValue = val;
|
||
break;
|
||
case type_bool:
|
||
base.vBool = (Tools::tolower(vValue) == "true");
|
||
break;
|
||
case type_int:
|
||
base.vInt = std::atoi(vValue.data());
|
||
break;
|
||
case type_int64:
|
||
base.vInt64 = std::atoll(vValue.data());
|
||
break;
|
||
case type_real:
|
||
base.vReal = std::atof(vValue.data());
|
||
break;
|
||
case type_array:
|
||
TASSERT_BOOL(d1 != "", "");
|
||
Tools::split(vValue, d1, vArray);
|
||
break;
|
||
case type_array2:
|
||
TASSERT_BOOL(d1 != "" && d2 != "", "");
|
||
Tools::split(vValue, d1, d2, vArray2);
|
||
break;
|
||
case type_array_int:
|
||
TASSERT_BOOL(d1 != "", "");
|
||
Tools::splitToInt(vValue, d1, vArrayInt);
|
||
break;
|
||
case type_array2_int:
|
||
TASSERT_BOOL(d1 != "" && d2 != "", "");
|
||
Tools::splitToInt(vValue, d1, d2, vArray2Int);
|
||
break;
|
||
default:
|
||
TASSERT_BOOL(false, "type error!");
|
||
break;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
asType type = type_null;
|
||
std::string vValue;
|
||
union
|
||
{
|
||
bool vBool = 0;
|
||
int vInt;
|
||
int64 vInt64;
|
||
double vReal;
|
||
} base;
|
||
std::vector<std::string> vArray;
|
||
std::vector<std::vector<std::string>> vArray2;
|
||
std::vector<int> vArrayInt;
|
||
std::vector<std::vector<int>> vArray2Int;
|
||
};
|
||
|
||
|
||
#define SYSSET_DECLARE(key, ...) \
|
||
public: \
|
||
void set##key(const std::string& v){ m_##key.setValue(v, ##__VA_ARGS__); } \
|
||
const std::string& get##key () { return m_##key.value(); } \
|
||
const std::string& value##key () { return m_##key.value(); } \
|
||
const std::string& asString##key() { return m_##key.asString(); } \
|
||
bool asBool##key () { return m_##key.asBool(); } \
|
||
int asInt##key () { return m_##key.asInt(); } \
|
||
int64 asInt64##key () { return m_##key.asInt64(); } \
|
||
float asFloat##key () { return m_##key.asFloat(); } \
|
||
double asDouble##key() { return m_##key.asDouble(); } \
|
||
const std::vector<std::string>& asArray##key() { return m_##key.asArray(); } \
|
||
const std::vector<std::vector<std::string>>& asArray2_##key() { return m_##key.asArray2(); } \
|
||
const std::vector<int>& asArrayInt##key() { return m_##key.asArrayInt(); } \
|
||
const std::vector<std::vector<int>>& asArray2Int_##key() { return m_##key.asArray2Int(); } \
|
||
private: \
|
||
TAny m_##key; \
|
||
|
||
#define SYSSET_ASSIGN(key) set##key(value(key));
|
||
|
||
//=============================================================================================
|
||
|
||
SYSSET_DECLARE(19, type_array, ":"); //夜间考试考试时间
|
||
SYSSET_DECLARE(211); //考试地点参数
|
||
SYSSET_DECLARE(301, type_array2, "^", ","); //条件1:档位,车速,持续时间,结束标志(0-不结束,1红闪,2黑闪),距离,^条件2:档位,车速,持续时间,0,距离,^评判时间(0-最后评判,1-里程达到就评判)^ //示例:4,35,3,0,1,^5,50,3,0,1,^
|
||
SYSSET_DECLARE(303); //行驶距离限制(米) //3000
|
||
SYSSET_DECLARE(306); //直行键(0-直行,1-加速行驶) //1
|
||
SYSSET_DECLARE(307); //只考一次的项目 //5,15,16
|
||
SYSSET_DECLARE(308, type_array2, "^", ";"); //v_no=301,1,2条件都不满足扣分列表^条件1不满足,条件2满足扣分表^ //20,60;20,60;20,60;^20,60;^
|
||
SYSSET_DECLARE(316, type_array, "@"); //1^距离^重复(0-否,1-是)^扣分^时间^~2^距离^重复^扣分^时间^~3(1,2档累计使用)^距离^重复^扣分^时间^~ //1^50^1^~2^150^1^~
|
||
SYSSET_DECLARE(318); //减速慢行不扣分条件(0-车速、踩刹、松油门,1-车速、踩刹,2-车速,3-车速&踩刹,4-踩刹) //1
|
||
SYSSET_DECLARE(319); //里程不够不报靠边停车(0-否 1-是 2-必考项目未完成且里程不够不报项目) //0
|
||
SYSSET_DECLARE(320, type_array, ","); //直线行驶:缓冲距离,项目距离(空-不允许) //30,120
|
||
SYSSET_DECLARE(321); //进靠边停车不报其他语音(0-否 1-是 2-只报路口项目) //1
|
||
SYSSET_DECLARE(322); //模拟夜间检查灯光时机(0-考试前后 1-仅考试后 2-仅考试前) //0 扣20-93
|
||
SYSSET_DECLARE(323); //模拟夜间模式(0-必考 1-未扣分补考时不考 2-不模拟 3-夜考时模拟+实际夜间灯光) //1
|
||
SYSSET_DECLARE(325); //靠边停车压线条件(0-停车压线才判;1-压线立即判) //0
|
||
SYSSET_DECLARE(326); //靠边停车后是否进入下车状态评判(0-否 1-是) //0
|
||
SYSSET_DECLARE(329, type_array, ","); //GPS搜索范围(大范围CM,小范围CM,) //6000,3000,
|
||
SYSSET_DECLARE(332); //不允许人工触发的项目列表,以","分隔
|
||
SYSSET_DECLARE(333); //直线行驶结束是否判减速带(0-不判,1-判) 0
|
||
SYSSET_DECLARE(334, type_array, "^"); //人行横道随机提示有行人通过(随机提示比例0~10) //0
|
||
SYSSET_DECLARE(336, type_int); //基础里程设置 //0
|
||
SYSSET_DECLARE(342); //车上是否能进行人工操作(0-能1-不能人工评判2-不能人工进项目3-都不能) //1
|
||
SYSSET_DECLARE(346); //RTK差分改正数串口(-1-普通GPS,0-共用串口2,>0-额外串口) // 0
|
||
SYSSET_DECLARE(348); //直线行驶中不进其他考试项目(0-否 1-是) //0
|
||
SYSSET_DECLARE(349, type_array, ","); //RTK基准站参数 //43.83836419,125.25308285,226.013,1.3,5
|
||
SYSSET_DECLARE(355); //差分模式下任何时刻都判变道不打方向灯(0-否 1-以前点车道数变化 2-以基准点车道数发生变化 3-车轮压线) // 0
|
||
SYSSET_DECLARE(359); //自动搜索差分车道(0-路段号无关,每次都搜索当前车道,>0-根据路段号搜索,如果路段号为空则为搜索时间秒) //0
|
||
SYSSET_DECLARE(360, type_array, "^"); //起步取消压线评判距离(米) //0
|
||
SYSSET_DECLARE(362); //启用监管系统(0-否 1-项目进一次 2-项目进多次) // 0
|
||
SYSSET_DECLARE(363); //踩下离合器也算空档滑行(0-否 1-是 2-2019年8月检测新规则) // 1
|
||
SYSSET_DECLARE(364); //绕车一周评判时机(1-开始考试后判 2-开始考试前判,) //1 //恢复
|
||
SYSSET_DECLARE(373); //考试不合格后,只报路口方向不进项目(0-否 1-是) //1
|
||
SYSSET_DECLARE(378); //变更车道和超车:取消第1个项目 (0-不能 1-不变道也不开转向灯 2-开双跳) //0
|
||
SYSSET_DECLARE(383, type_array, "^"); //新模拟夜间(次数^错扣^固定^) //-
|
||
SYSSET_DECLARE(386); //触发夜间灯光模拟的条件(0-点完成 1-插安全带或点火 2-点火 3-上车准备人工评判按钮切换 4-点击“继续考试”按钮触发 5-有点火1信号就可以触发,6-有安全带就触发) //1 //3时342=0或2有效
|
||
SYSSET_DECLARE(389); //人行道不能掉头(0-否 1-是) // 0
|
||
SYSSET_DECLARE(390); //加减档位顺序 //23432
|
||
SYSSET_DECLARE(394, type_array2, ";", ":"); //档位车速范围 //1:0-20;2:5-30;3:15-40;4:25-55;5:35-150;
|
||
SYSSET_DECLARE(399); //人工按键(0-标准 1-会车,2-最左侧车道才能点会车) // 0
|
||
SYSSET_DECLARE(400, type_array, "^"); //全程车速要求:评判标记(0-不评判,1-里程车速评判,2-按分断车速持续时间)^每M米之内保持N米(秒)YKm/h车速以上^ //0^500,50,20^
|
||
SYSSET_DECLARE(402); //直线行驶车速高于标准(0-评判 1-不评判 2-只要达到达标车速就行) // 0
|
||
SYSSET_DECLARE(405); //超车时在超车道上需驶离超车道 (0-否 1-是 2-不进项目) //0
|
||
SYSSET_DECLARE(409); //变道后变更车道项目结束(0-否 1-是) // 0
|
||
SYSSET_DECLARE(411); //靠边停车以右前、后轮判靠边距离(0-否 1-是) //0
|
||
SYSSET_DECLARE(414); //变道、超车以前后轮都过线(0-否 1-是) //0
|
||
SYSSET_DECLARE(415, type_array, "^"); //自动报靠边停车(启用标记^全部结束n米报^)启用标记:0-否 1-是 319参数为2有效 //0^1^
|
||
SYSSET_DECLARE(418); //扣分时实时播报语音(0-否 1-是) //0
|
||
SYSSET_DECLARE(421); //模拟夜间:车辆发生故障,按近光灯和双跳进行评判(0-是 1-否)
|
||
SYSSET_DECLARE(425, type_array, ","); //加减档位操作挂一个挡位要松一次离合器(项目,全程)(0-否 1-是)() // 0,0,
|
||
SYSSET_DECLARE(426); //手工取消正在考的项目(0-否 1-是) // 1
|
||
SYSSET_DECLARE(427); //加减档位采用加档到上一档,减档到下一档(0-否 1-是 2-濮阳模式 3-常州模式 4-广东揭阳模式)
|
||
SYSSET_DECLARE(428); //加减档位操作换档语音提示(0-否 1-是) //0
|
||
SYSSET_DECLARE(429); //加减档位操作只在项目中评判(0-否全过程评判 1-是此在项目中评判) //0
|
||
SYSSET_DECLARE(430); //靠边停车确认停车条件(0-拉手刹放空挡或拉手刹动作或开车门或解开安全带 1-拉手刹同时置空档 2-停车就判 3-开车门才判)// 0
|
||
SYSSET_DECLARE(437, type_array, "^"); //制动不平顺评判方式(0-靠边停车阶段,1-表示全过程阶段),以^隔开使用速度模式,第二个^里设置速度差值 // 0
|
||
SYSSET_DECLARE(441, type_array, "^"); //全程限高速(0-不启用 >0表示启用,表示最高车速) //0
|
||
SYSSET_DECLARE(442, type_int); //会车只要求减速(0-要打右方向和减速 1-是 按318设置的减速条件 2-只判断车速) // 0
|
||
SYSSET_DECLARE(445); //C2车型不以点火2信号来判断熄火(0-要评判 1-不判断)修改为:压线评判不判断差分信号 //0 //20220624
|
||
SYSSET_DECLARE(481, type_int); //边缘线宽度CM //0
|
||
SYSSET_DECLARE(478); //空挡滑行增加发动机转速限制条件(1转速小于怠速+200,0不限制) // 2023-03-01增加
|
||
SYSSET_DECLARE(482, type_array, "^"); //超车时车速要求(0-不要求 其它值表示要求 车速^持续时长秒^要求阶段 ^ //0
|
||
SYSSET_DECLARE(483); //里程大于多少米开始进入项目 //0
|
||
SYSSET_DECLARE(484, type_array, "^"); //贵州地区上下山参数(开始上山路段号^开始下山路段号^)
|
||
SYSSET_DECLARE(487); //启用139号令大车考试模式 (0-否 1-是) //0 //失效不用了
|
||
SYSSET_DECLARE(488, type_array, "^"); //环境感知参数(安全距离L厘米^时长S秒^横向距离L2厘米^)
|
||
SYSSET_DECLARE(489); //加减档位:取消第1个项目(0-不能,1-档位不变)
|
||
SYSSET_DECLARE(490); //设置反向路段号,以逗号隔开
|
||
SYSSET_DECLARE(491); //未松离合,档位取之前的档位(0-否 1-是 2-表示使用模糊档位,可以对1,3,5档位和2,4档位进行筛选) //0
|
||
SYSSET_DECLARE(500, type_array, ","); //通用参数:lhqxs,zdxhkf,fscys,ddgzskfsj,ddgzskfzs,zxdbgbjl,fxkzwbjd,fxkzwbxz,zdbpsjgsj,zbksddsj,zbksddtscs,dhddsj,xslx, yjjdcxsj, qcyjjdkf, gpslc,mndgddsj, //25,0,2,20,2200,270,4,0.07,90,5,2,15,0,2,1,0,0,
|
||
SYSSET_DECLARE(501, type_array, ","); //模拟灯光参数:yyys,zqys,czys,ccczys,xskf,yyjgsj, lstcstd, //8000,4000,1800,20000,0,0,0,
|
||
SYSSET_DECLARE(502, type_array, ","); //起步参数:qbcd,ssc2qjsj,qbpdsjl,qbfdjzsgg,qblcjl,cfjxm,qbsj,
|
||
SYSSET_DECLARE(503, type_array, ","); //直线行驶参数:zxxsza,kzsdfw,zxxsdbcs,zxxsjsfz,kfsjjg, ppdtype,cfjd,cspp, //35,5,30,0,100,0,0.5,0,
|
||
SYSSET_DECLARE(504, type_array, ","); //变更车道超车参数:xmjl,bgcdzjd,slccdjl,ksccjl,hycdjl,ccxmjl,ccxmsj,bxybd, //150,3,30,30,30,0,15,0,
|
||
SYSSET_DECLARE(505, type_array, ",") //靠边停车参数:kbqfxdjd,kbqfxdcfjd,kbtczys,kbtcsj,fxdpp,kbxmjl, //10,0,0,180,0,150,
|
||
SYSSET_DECLARE(506, type_array, ","); //会车参数:jslxs,hcxmjl,kybxjl, //30,0,0,
|
||
SYSSET_DECLARE(507, type_array, ","); //加减挡位操作参数:+jjdxdxs,jjdwczxmjl,jjdwddsj, //10,1000,1,2,
|
||
SYSSET_DECLARE(508, type_array, ","); //路口项目参数:xmjl //250
|
||
SYSSET_DECLARE(509, type_array, ","); //学校区域参数:jslxmjl // 60
|
||
SYSSET_DECLARE(510, type_array, ","); //掉头参数:dtxmjl,dtzzj,jscs, //220,120,30,
|
||
SYSSET_DECLARE(512, type_array, ","); //其它参数:kfxs,lxbgcd,mnxmyy, gqxmjl,rgxmtj,rgppsj,rgxmfd, //0,0,0,0,0,0,0,
|
||
SYSSET_DECLARE(513, type_array, "^"); //513:绕车一周传感器 (0-原始两个声波或两个手按自动识别 1-手按式 接到右后磁s和右后磁n2-四个传感 器模式^串口号1,串口号2^ 3-三个手按式传感 器 接到右后磁s 左后磁n 右后磁n 4-一型机4个按钮 5-二型机4个按钮 6-超声波 8-4个按钮磁前磁s,前磁n,左前磁s,左前磁n) //0
|
||
SYSSET_DECLARE(521); //Gps信号异常(如方向未知)情况下不扣GPS_SID=1的分 //0
|
||
SYSSET_DECLARE(522, type_array2, ";", ","); //路口和人行横道项目减速设置,具体设置方法看后面详细说明 //20190618增加
|
||
SYSSET_DECLARE(523, type_array2, ";", ","); //靠边停车按每个项目设定项目距离 // 格式:11~项目号,项目距离; 20190619增加
|
||
SYSSET_DECLARE(524, type_array, ","); //科目三新规则 201909检测增加
|
||
SYSSET_DECLARE(527); //踩副刹时(包括引起的熄火)车上不扣分,由监控画面提示是否扣分 // 0
|
||
SYSSET_DECLARE(528, type_int); //掉头N米内不判连续变道和方向灯 //0
|
||
SYSSET_DECLARE(529); //模拟灯光前需要人脸验证 0 // 20200506增加
|
||
SYSSET_DECLARE(530, type_array, "^"); //环境感知参数
|
||
SYSSET_DECLARE(531, type_array, ","); //是否启用环境感知评判,是否启用驾驶行为评判,是否启用录像功能, //0
|
||
SYSSET_DECLARE(533); //开始考试后(n秒)提示点火,(m秒不点火扣分),格式:30,60, 此参数不能与512-9参数同时设置,两个参数最多只能设置一个 //20210524增加
|
||
SYSSET_DECLARE(541); //压非机动车道分解线立即评判 // 0 //2023-02-14增加
|
||
SYSSET_DECLARE(603, type_array2_int, ";", ","); //中停时间参数(秒) 格式:100,时间;itemno,时间;itemno1,时间1;
|
||
SYSSET_DECLARE(606, type_int); //倒车入库,桩考、侧方不可以取消项目, 0:可以取消 1:不可以取消
|
||
SYSSET_DECLARE(660); //侧方停车项目 停车距离判断阈值控制参数
|
||
SYSSET_DECLARE(671); //停车距离判断阈值控制参数
|
||
|
||
void assign()
|
||
{
|
||
SYSSET_ASSIGN(19);
|
||
SYSSET_ASSIGN(211);
|
||
SYSSET_ASSIGN(301);
|
||
SYSSET_ASSIGN(303);
|
||
SYSSET_ASSIGN(306);
|
||
SYSSET_ASSIGN(307);
|
||
SYSSET_ASSIGN(308);
|
||
SYSSET_ASSIGN(316);
|
||
SYSSET_ASSIGN(318);
|
||
SYSSET_ASSIGN(319);
|
||
SYSSET_ASSIGN(320);
|
||
SYSSET_ASSIGN(321);
|
||
SYSSET_ASSIGN(322);
|
||
SYSSET_ASSIGN(323);
|
||
SYSSET_ASSIGN(325);
|
||
SYSSET_ASSIGN(326);
|
||
SYSSET_ASSIGN(329);
|
||
SYSSET_ASSIGN(332);
|
||
SYSSET_ASSIGN(333);
|
||
SYSSET_ASSIGN(334);
|
||
SYSSET_ASSIGN(336);
|
||
SYSSET_ASSIGN(342);
|
||
SYSSET_ASSIGN(346);
|
||
SYSSET_ASSIGN(348);
|
||
SYSSET_ASSIGN(349);
|
||
SYSSET_ASSIGN(355);
|
||
SYSSET_ASSIGN(359);
|
||
SYSSET_ASSIGN(360);
|
||
SYSSET_ASSIGN(362);
|
||
SYSSET_ASSIGN(363);
|
||
SYSSET_ASSIGN(364);
|
||
SYSSET_ASSIGN(373);
|
||
SYSSET_ASSIGN(378);
|
||
SYSSET_ASSIGN(383);
|
||
SYSSET_ASSIGN(386);
|
||
SYSSET_ASSIGN(389);
|
||
SYSSET_ASSIGN(390);
|
||
SYSSET_ASSIGN(394);
|
||
SYSSET_ASSIGN(399);
|
||
SYSSET_ASSIGN(400);
|
||
SYSSET_ASSIGN(402);
|
||
SYSSET_ASSIGN(405);
|
||
SYSSET_ASSIGN(409);
|
||
SYSSET_ASSIGN(411);
|
||
SYSSET_ASSIGN(414);
|
||
SYSSET_ASSIGN(415);
|
||
SYSSET_ASSIGN(418);
|
||
SYSSET_ASSIGN(421);
|
||
SYSSET_ASSIGN(425);
|
||
SYSSET_ASSIGN(426);
|
||
SYSSET_ASSIGN(427);
|
||
SYSSET_ASSIGN(428);
|
||
SYSSET_ASSIGN(429);
|
||
SYSSET_ASSIGN(430);
|
||
SYSSET_ASSIGN(437);
|
||
SYSSET_ASSIGN(441);
|
||
SYSSET_ASSIGN(442);
|
||
SYSSET_ASSIGN(445);
|
||
SYSSET_ASSIGN(478);
|
||
SYSSET_ASSIGN(481);
|
||
SYSSET_ASSIGN(482);
|
||
SYSSET_ASSIGN(483);
|
||
SYSSET_ASSIGN(484);
|
||
SYSSET_ASSIGN(487);
|
||
SYSSET_ASSIGN(488);
|
||
SYSSET_ASSIGN(489);
|
||
SYSSET_ASSIGN(490);
|
||
SYSSET_ASSIGN(491);
|
||
SYSSET_ASSIGN(500);
|
||
SYSSET_ASSIGN(501);
|
||
SYSSET_ASSIGN(502);
|
||
SYSSET_ASSIGN(503);
|
||
SYSSET_ASSIGN(504);
|
||
SYSSET_ASSIGN(505);
|
||
SYSSET_ASSIGN(506);
|
||
SYSSET_ASSIGN(507);
|
||
SYSSET_ASSIGN(508);
|
||
SYSSET_ASSIGN(509);
|
||
SYSSET_ASSIGN(510);
|
||
SYSSET_ASSIGN(512);
|
||
SYSSET_ASSIGN(513);
|
||
SYSSET_ASSIGN(521);
|
||
SYSSET_ASSIGN(522);
|
||
SYSSET_ASSIGN(523);
|
||
SYSSET_ASSIGN(524);
|
||
SYSSET_ASSIGN(527);
|
||
SYSSET_ASSIGN(528);
|
||
SYSSET_ASSIGN(529);
|
||
SYSSET_ASSIGN(530);
|
||
SYSSET_ASSIGN(531);
|
||
SYSSET_ASSIGN(533);
|
||
SYSSET_ASSIGN(541);
|
||
SYSSET_ASSIGN(603);
|
||
SYSSET_ASSIGN(606);
|
||
SYSSET_ASSIGN(660);
|
||
SYSSET_ASSIGN(671);
|
||
}
|
||
|
||
public:
|
||
explicit SysSetTable() = default;
|
||
virtual ~SysSetTable() { unload(); }
|
||
bool load(const std::vector<TSysset>& sysset);
|
||
void unload();
|
||
const std::map<int, TSysset>& syssets() const noexcept { return m_syssets; }
|
||
|
||
private:
|
||
/**********************************************************************************
|
||
*
|
||
* 注意:外部不允许通过下面这些接口访问,如果数据被系统初始化的时候重新设置了,数据可能不准确
|
||
*
|
||
**********************************************************************************/
|
||
bool has(int key) const { return m_syssets.find(key) != m_syssets.end(); }
|
||
TSysset* find(int key); //始终总是返回有值
|
||
const std::string& value(int key) noexcept { return find(key)->value; };
|
||
template<typename T> T as(int key) JUDGE_TEMPLATE_DELETE; //始终总是返回有值支持的类型:bool,int,int64,float,double,string
|
||
//检查系统参数
|
||
bool check();
|
||
|
||
std::map<int, TSysset> m_syssets;
|
||
};
|
||
|
||
//成员函数模板和特化 杨海洋
|
||
#define JUDGE_ANY_AS(__as,__ty) template <> inline __ty SysSetTable::TAny::as<__ty>() const { return __as(); }
|
||
#define JUDGE_ANY_IS(__is,__ty) template <> inline bool SysSetTable::TAny::is<__ty>() const { return __is(); }
|
||
|
||
JUDGE_ANY_AS(asBool, bool);
|
||
JUDGE_ANY_AS(asInt, int);
|
||
JUDGE_ANY_AS(asInt64, int64);
|
||
JUDGE_ANY_AS(asFloat, float);
|
||
JUDGE_ANY_AS(asDouble, double);
|
||
JUDGE_ANY_AS(asString, const std::string&);
|
||
JUDGE_ANY_AS(asArray, const std::vector<std::string>&);
|
||
JUDGE_ANY_AS(asArray2, const std::vector<std::vector<std::string>>&);
|
||
JUDGE_ANY_AS(asArrayInt, const std::vector<int>&);
|
||
JUDGE_ANY_AS(asArray2Int, const std::vector<std::vector<int>>&);
|
||
|
||
JUDGE_ANY_IS(isBool, bool);
|
||
JUDGE_ANY_IS(isInt, int);
|
||
JUDGE_ANY_IS(isInt64, int64);
|
||
JUDGE_ANY_IS(isFloat, float);
|
||
JUDGE_ANY_IS(isDouble, double);
|
||
JUDGE_ANY_IS(isString, const std::string&);
|
||
JUDGE_ANY_IS(isArray, const std::vector<std::string>&);
|
||
JUDGE_ANY_IS(isArray2, const std::vector<std::vector<std::string>>&);
|
||
JUDGE_ANY_IS(isArrayInt, const std::vector<int>&);
|
||
JUDGE_ANY_IS(isArray2Int, const std::vector<std::vector<int>>&);
|
||
|
||
/*
|
||
template <> inline bool SysSetTable::TAny::as<bool> () const { return asBool(); }
|
||
template <> inline int SysSetTable::TAny::as<int> () const { return asInt(); }
|
||
template <> inline int64 SysSetTable::TAny::as<int64> () const { return asInt64(); }
|
||
template <> inline float SysSetTable::TAny::as<float> () const { return asFloat(); }
|
||
template <> inline double SysSetTable::TAny::as<double> () const { return asDouble(); }
|
||
template <> inline const std::string& SysSetTable::TAny::as<const std::string&> () const { return asString(); }
|
||
template <> inline const std::vector<std::string>&
|
||
SysSetTable::TAny::as<const std::vector<std::string>&>() const { return asArray(); }
|
||
template <> inline const std::vector<std::vector<std::string>>&
|
||
SysSetTable::TAny::as<const std::vector<std::vector<std::string>>&> () const { return asArray2(); }
|
||
template <> inline const std::vector<int>&
|
||
SysSetTable::TAny::as<const std::vector<int>&> () const { return asArrayInt(); }
|
||
template <> inline const std::vector<std::vector<int>>&
|
||
SysSetTable::TAny::as<const std::vector<std::vector<int>>&> () const { return asArray2Int(); }
|
||
|
||
template <> inline bool SysSetTable::TAny::is<bool> () const { return isBool(); }
|
||
template <> inline bool SysSetTable::TAny::is<int> () const { return isInt(); }
|
||
template <> inline bool SysSetTable::TAny::is<int64> () const { return isInt64(); }
|
||
template <> inline bool SysSetTable::TAny::is<float> () const { return isFloat(); }
|
||
template <> inline bool SysSetTable::TAny::is<double> () const { return isDouble(); }
|
||
template <> inline bool SysSetTable::TAny::is<const std::string&> () const { return isString(); }
|
||
template <> inline bool
|
||
SysSetTable::TAny::is<const std::vector<std::string>&>() const { return isArray(); }
|
||
template <> inline bool
|
||
SysSetTable::TAny::is<const std::vector<std::vector<std::string>>&> () const { return isArray2(); }
|
||
template <> inline bool
|
||
SysSetTable::TAny::is<const std::vector<int>&> () const { return isArrayInt(); }
|
||
template <> inline bool
|
||
SysSetTable::TAny::is<const std::vector<std::vector<int>>&> () const { return isArray2Int(); }
|
||
*/
|
||
|
||
#endif // SYSSETTABLE_H
|