// // Created by ps on 8/9/18. // #ifndef UNTITLED_SYNCDB_HPP #define UNTITLED_SYNCDB_HPP #include #include #include namespace SyncDB { // Value-Defintions of the different String values enum Feature_InfoStringValue { evNotDefined, id, feature, create_by, create_time, update_time, img, idcard, enable, monLevel, evEnd }; // Map to associate the strings with the enum values typedef std::map Map_Fea_InfoString2Values; static Map_Fea_InfoString2Values map_Fea_InfoString2Values; static void Initialize() { map_Fea_InfoString2Values["id"] = Feature_InfoStringValue::id; map_Fea_InfoString2Values["feature"] = Feature_InfoStringValue::feature; map_Fea_InfoString2Values["create_by"] = Feature_InfoStringValue::create_by; map_Fea_InfoString2Values["create_time"] = Feature_InfoStringValue::create_time; map_Fea_InfoString2Values["update_time"] = Feature_InfoStringValue::update_time; map_Fea_InfoString2Values["img"] = Feature_InfoStringValue::img; map_Fea_InfoString2Values["idcard"] = Feature_InfoStringValue::idcard; map_Fea_InfoString2Values["enable"] = Feature_InfoStringValue::enable; map_Fea_InfoString2Values["monitorLevel"] = Feature_InfoStringValue::monLevel; map_Fea_InfoString2Values["end"] = evEnd; } // Intialization static bool ret = (Initialize(), true); struct Feature_Info { public: Feature_Info() { // Initialize(); } // ~Feature_Info() { // for (auto &item:map_Fea_InfoString2Values) { // map_Fea_InfoString2Values.erase(item.first); // } // } bool setValue(std::string key, std::string value) { try { switch (map_Fea_InfoString2Values[key]) { case Feature_InfoStringValue::evNotDefined: //#todo error info return false; case Feature_InfoStringValue::id: id = value; break; case Feature_InfoStringValue::feature: feature = value; break; case Feature_InfoStringValue::create_by: create_by = value; break; case Feature_InfoStringValue::create_time: create_time = value; break; case Feature_InfoStringValue::update_time: update_time = value; break; case Feature_InfoStringValue::img: img = value; break; case Feature_InfoStringValue::idcard: idcard = value; break; case Feature_InfoStringValue::enable: enable = value; break; case Feature_InfoStringValue::monLevel: monLevel = value; break; default: ERR(key << " is an invalid string. s_mapStringValues now contains " << map_Fea_InfoString2Values.size() << " entries."); return false; } return true; } catch (std::exception ex) { return false; } } public: public: std::string id; std::string feature; std::string create_by; std::string create_time; std::string update_time; std::string img; std::string idcard; std::string enable; std::string monLevel; // value is a atom: atomSize:19, atomValue:test@192.168.50.216 // value is a list:2018-08-08 20:17:11 // value is a atom: atomSize:36, atomValue:ce386825-76f4-42bc-a0e1-cd9484cb7a8c // value is a list:6eda59e2-d884-5ffb-89d9-84dcffda2ad6 // value is a list:2018-08-08 20:17:11 private: }; //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- //---------------------------DEVICE_INFO-------------------------------------- //---------------------------------------------------------------------------- // key:create_by string :za@192.168.50.216 // key:create_time string :2018-08-12 16:56:08 // key:del_flag bool :0 // key:dev_address string :DevAddress // key:device_name string : // key:father_node string : // key:node_id string :za@192.168.50.216 // key:node_online bool: 1 // key:update_time string :2018-08-12 16:56:08 // key:uuid string :19633f6f-acd9-5482-a0c8-74a44a576edf // Value-Defintions of the different String values enum Device_InfoStringValue { dev_evNotDefined, dev_create_by, dev_create_time, dev_del_flag, dev_cluster_id, dev_cluster_name, dev_device_id, dev_node_id, dev_node_online, dev_update_time, dev_uuid, dev_evEnd }; // Map to associate the strings with the enum values typedef std::map Map_Dev_InfoString2Values; static Map_Dev_InfoString2Values map_Dev_InfoString2Values; static void DevInitialize() { //#todo map_Dev_InfoString2Values["create_by"] = Device_InfoStringValue::dev_create_by; map_Dev_InfoString2Values["create_time"] = Device_InfoStringValue::dev_create_time; map_Dev_InfoString2Values["del_flag"] = Device_InfoStringValue::dev_del_flag; map_Dev_InfoString2Values["cluster_id"] = Device_InfoStringValue::dev_cluster_id; map_Dev_InfoString2Values["cluster_name"] = Device_InfoStringValue::dev_cluster_name; map_Dev_InfoString2Values["device_id"] = Device_InfoStringValue::dev_device_id; map_Dev_InfoString2Values["node_id"] = Device_InfoStringValue::dev_node_id; map_Dev_InfoString2Values["update_time"] = Device_InfoStringValue::dev_update_time; map_Dev_InfoString2Values["uuid"] = Device_InfoStringValue::dev_uuid; map_Dev_InfoString2Values["end"] = Device_InfoStringValue::dev_evEnd; } // Intialization static bool devRet = (DevInitialize(), true); struct Device_Info { public: Device_Info() : create_by(""), create_time(""), del_flag(""), device_id(""), cluster_id(""), cluster_name(""), node_id(""), update_time(""), uuid("") { // Initialize(); } ~Device_Info() { // for (auto &item:map_Fea_InfoString2Values) { // map_Fea_InfoString2Values.erase(item.first); // } } bool setValue(std::string key, std::string value) { try { //#todo int type = map_Dev_InfoString2Values[key]; switch (type) { case Device_InfoStringValue::dev_evNotDefined: //#todo error info return false; case Device_InfoStringValue::dev_create_by: create_by = value; break; case Device_InfoStringValue::dev_create_time: create_time = value; break; case Device_InfoStringValue::dev_del_flag: del_flag = value; break; case Device_InfoStringValue::dev_cluster_id: cluster_id = value; break; case Device_InfoStringValue::dev_cluster_name: cluster_name = value; break; case Device_InfoStringValue::dev_device_id: device_id = value; break; case Device_InfoStringValue::dev_node_id: node_id = value; break; case Device_InfoStringValue::dev_update_time: update_time = value; break; case Device_InfoStringValue::dev_uuid: uuid = value; break; default: ERR(key << " is an invalid string. s_mapStringValues now contains " << map_Fea_InfoString2Values.size() << " entries."); return false; } return true; } catch (std::exception ex) { return false; } } public: public: std::string create_by; std::string create_time; std::string del_flag; std::string device_id; std::string cluster_id; std::string cluster_name; std::string node_id; std::string update_time; std::string uuid; private: }; //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- //---------------------------Table_INFO-------------------------------------- //---------------------------------------------------------------------------- //{"create_by",'za@192.168.50.216'}, //{"create_time","2018-08-13 10:14:39"}, //{"del_flag","0"}, //{"tableDesc",test}, //{"tableName",aaa1}, //{"tableType",person}, //{"update_time","2018-08-13 10:14:39"}, //{"uuid","b1c19f77-623b-5294-9b65-9a766af1f77d"} // Value-Defintions of the different String values enum Table_InfoStringValue { tab_evNotDefined, tab_create_by, tab_create_time, tab_del_flag, tab_tableDesc, tab_tableName, tab_tableType, tab_bwType, tab_update_time, tab_uuid, tab_startTime, tab_endTime, tab_uploadFlag, tab_cmpThreshold, tab_enabled, tab_evEnd }; // Map to associate the strings with the enum values typedef std::map Map_Tab_InfoString2Values; static Map_Tab_InfoString2Values map_Tab_InfoString2Values; static void TabInitialize() { map_Tab_InfoString2Values["create_by"] = Table_InfoStringValue::tab_create_by; map_Tab_InfoString2Values["create_time"] = Table_InfoStringValue::tab_create_time; map_Tab_InfoString2Values["del_flag"] = Table_InfoStringValue::tab_del_flag; map_Tab_InfoString2Values["tableDesc"] = Table_InfoStringValue::tab_tableDesc; map_Tab_InfoString2Values["tableName"] = Table_InfoStringValue::tab_tableName; map_Tab_InfoString2Values["tableType"] = Table_InfoStringValue::tab_tableType; map_Tab_InfoString2Values["bwType"] = Table_InfoStringValue::tab_bwType; map_Tab_InfoString2Values["update_time"] = Table_InfoStringValue::tab_update_time; map_Tab_InfoString2Values["uuid"] = Table_InfoStringValue::tab_uuid; map_Tab_InfoString2Values["startTime"] = Table_InfoStringValue::tab_startTime; map_Tab_InfoString2Values["endTime"] = Table_InfoStringValue::tab_endTime; map_Tab_InfoString2Values["uploadFlag"] = Table_InfoStringValue::tab_uploadFlag; map_Tab_InfoString2Values["cmpThreshold"] = Table_InfoStringValue::tab_cmpThreshold; map_Tab_InfoString2Values["enabled"] = Table_InfoStringValue::tab_enabled; map_Tab_InfoString2Values["end"] = Table_InfoStringValue::tab_evEnd; } // Intialization static bool tabRet = (TabInitialize(), true); struct Table_Info { public: Table_Info() : create_by(""), create_time(""), del_flag(""), tableDesc(""), tableName(""), tableType(""), update_time(""), uuid(""), bwType(""), startTime(""), endTime(""), uploadFlag(""), cmpThreshold(""), enabled("") { // Initialize(); } ~Table_Info() { // for (auto &item:map_Fea_InfoString2Values) { // map_Fea_InfoString2Values.erase(item.first); // } } bool setValue(std::string key, std::string value) { try { //#todo int type = map_Tab_InfoString2Values[key]; switch (type) { case Table_InfoStringValue::tab_evNotDefined: //#todo error info return false; case Table_InfoStringValue::tab_create_by: create_by = value; break; case Table_InfoStringValue::tab_create_time: create_time = value; break; case Table_InfoStringValue::tab_del_flag: del_flag = value; break; case Table_InfoStringValue::tab_tableDesc: tableDesc = value; break; case Table_InfoStringValue::tab_tableName: tableName = value; break; case Table_InfoStringValue::tab_tableType: tableType = value; break; case Table_InfoStringValue::tab_bwType: bwType = value; break; case Table_InfoStringValue::tab_uuid: uuid = value; break; case Table_InfoStringValue::tab_update_time: update_time = value; break; case Table_InfoStringValue::tab_startTime: startTime = value; break; case Table_InfoStringValue::tab_endTime: endTime = value; break; case Table_InfoStringValue::tab_uploadFlag: uploadFlag = value; break; case Table_InfoStringValue::tab_cmpThreshold: cmpThreshold = value; break; case Table_InfoStringValue::tab_enabled: enabled = value; break; default: ERR(key << " is an invalid string. s_mapStringValues now contains " << map_Fea_InfoString2Values.size() << " entries."); return false; } return true; } catch (std::exception ex) { return false; } } public: public: std::string create_by; std::string create_time; std::string del_flag; std::string tableDesc; std::string tableName; std::string tableType; std::string update_time; std::string uuid; std::string bwType; std::string startTime; std::string endTime; std::string uploadFlag; std::string cmpThreshold; std::string enabled; private: }; //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- //---------------------------Bw_INFO-------------------------------------- //---------------------------------------------------------------------------- //{"bwType",'0'}, //{"create_by",'za@192.168.50.216'}, //{"create_time","2018-08-13 10:14:39"}, //{"tableName",aaa1}, //{"update_time","2018-08-13 10:14:39"}, //{"uuid","e0eb30e9-f595-5651-8895-6f07f3851fcf"} // Value-Defintions of the different String values enum Bw_InfoStringValue { bw_evNotDefined, bw_bwType, bw_create_by, bw_create_time, bw_tableName, bw_update_time, bw_uuid, bw_evEnd }; // Map to associate the strings with the enum values typedef std::map Map_Bw_InfoString2Values; static Map_Bw_InfoString2Values map_Bw_InfoString2Values; static void BwInitialize() { map_Bw_InfoString2Values["bwType"] = bw_bwType; map_Bw_InfoString2Values["create_by"] = bw_create_by; map_Bw_InfoString2Values["create_time"] = bw_create_time; map_Bw_InfoString2Values["tableName"] = bw_tableName; map_Bw_InfoString2Values["update_time"] = bw_update_time; map_Bw_InfoString2Values["uuid"] = bw_uuid; map_Bw_InfoString2Values["end"] = bw_evEnd; } // Intialization static bool bwRet = (BwInitialize(), true); struct Bw_Info { public: Bw_Info() : bwType(""), create_by(""), create_time(""), tableName(""), update_time(""), uuid("") { // Initialize(); } ~Bw_Info() { // for (auto &item:map_Fea_InfoString2Values) { // map_Fea_InfoString2Values.erase(item.first); // } } bool setValue(std::string key, std::string value) { try { //#todo int type = map_Bw_InfoString2Values[key]; switch (type) { case bw_evNotDefined: //#todo error info return false; case bw_bwType: bwType = value; break; case bw_create_by: create_by = value; break; case bw_create_time: create_time = value; break; case bw_tableName: tableName = value; break; case bw_uuid: uuid = value; break; case bw_update_time: update_time = value; break; default: ERR(key << " is an invalid string. s_mapStringValues now contains " << map_Fea_InfoString2Values.size() << " entries."); return false; } return true; } catch (std::exception ex) { return false; } } public: public: std::string create_by; std::string create_time; std::string bwType; std::string tableName; std::string update_time; std::string uuid; private: }; struct AddPersonInfo { std::string personid; std::string idcard; std::string personPic; std::string feature; }; enum AddPersRetStringValue { ap_evNotDefined, ap_PersonId, ap_Result, ap_msg, ap_evEnd }; // Map to associate the strings with the enum values typedef std::map Map_AddPersRetString2Values; static Map_AddPersRetString2Values map_AddPersRetString2Values; static void AddRetInitialize() { map_AddPersRetString2Values["PersonId"] = ap_PersonId; map_AddPersRetString2Values["Result"] = ap_Result; map_AddPersRetString2Values["msg"] = ap_msg; map_AddPersRetString2Values["end"] = ap_evEnd; } // Intialization static bool addPerRet = (AddRetInitialize(), true); struct AddPersRet { public: AddPersRet() : PersonId(""), Result(""), msg("") { // Initialize(); } ~AddPersRet() { } bool setValue(std::string key, std::string value) { try { //#todo int type = map_AddPersRetString2Values[key]; switch (type) { case ap_evNotDefined: //#todo error info return false; case ap_PersonId: PersonId = value; break; case ap_Result: Result = value; break; case ap_msg: msg = value; break; default: ERR(key << " is an invalid string. s_mapStringValues now contains " << map_AddPersRetString2Values.size() << " entries."); return false; } return true; } catch (std::exception ex) { return false; } } public: public: std::string PersonId; std::string Result; std::string msg; private: }; enum PerExistRetStringValue { pe_evNotDefined, pe_tableName, pe_tableUuid, pe_uuid, pe_evEnd }; // Map to associate the strings with the enum values typedef std::map Map_PerExistRetString2Values; static Map_PerExistRetString2Values map_PerExistRetString2Values; static void PerExistRetInitialize() { map_PerExistRetString2Values["tableName"] = pe_tableName; map_PerExistRetString2Values["tableUuid"] = pe_tableUuid; map_PerExistRetString2Values["uuid"] = pe_uuid; map_PerExistRetString2Values["end"] = pe_evEnd; } // Intialization static bool perExistsRet = (PerExistRetInitialize(), true); struct PerExistRet { public: PerExistRet() : tableName(""), uuid(""), tableUuid("") { // Initialize(); } ~PerExistRet() { } bool setValue(std::string key, std::string value) { try { //#todo int type = map_PerExistRetString2Values[key]; switch (type) { case pe_evNotDefined: //#todo error info return false; case pe_tableName: tableName = value; break; case pe_tableUuid: tableUuid = value; break; case pe_uuid: uuid = value; break; default: ERR(key << " is an invalid string. s_mapStringValues now contains " << map_PerExistRetString2Values.size() << " entries."); return false; } return true; } catch (std::exception ex) { return false; } } public: public: std::string tableName; std::string tableUuid; std::string uuid; private: }; enum UpdPersRetStringValue { up_evNotDefined, up_tableName, up_tableUuid, up_result, up_oldId, up_evEnd }; // Map to associate the strings with the enum values typedef std::map Map_UpdPersRetStringValue; static Map_UpdPersRetStringValue map_UpdPersRetStringValue; static void UpdPersRetInitialize() { map_UpdPersRetStringValue["tableName"] = up_tableName; map_UpdPersRetStringValue["tableUuid"] = up_tableUuid; map_UpdPersRetStringValue["result"] = up_result; map_UpdPersRetStringValue["oldId"] = up_oldId; map_UpdPersRetStringValue["end"] = up_evEnd; } // Intialization static bool updPerRet = (UpdPersRetInitialize(), true); struct UpdPersRet { public: UpdPersRet() : tableName(""), result(""), oldId(""), tableUuid("") { // Initialize(); } ~UpdPersRet() { } bool setValue(std::string key, std::string value) { try { //#todo int type = map_UpdPersRetStringValue[key]; switch (type) { case up_evNotDefined: //#todo error info return false; case up_tableName: tableName = value; break; case up_tableUuid: tableUuid = value; break; case up_result: result = value; break; case up_oldId: oldId = value; break; default: ERR(key << " is an invalid string. s_mapStringValues now contains " << map_UpdPersRetStringValue.size() << " entries."); return false; } return true; } catch (std::exception ex) { return false; } } public: public: std::string tableName; std::string tableUuid; std::string result; std::string oldId; private: }; } #endif //UNTITLED_SYNCDB_HPP