123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- #ifndef GLOBALINFO_H
- #define GLOBALINFO_H
- #include <QString>
- #include <vector>
- #include "nlohmann/json.hpp"
- /**
- * @brief 全局信息
- *
- */
- using nJson = nlohmann::json;
- /* 算法相关信息 */
- struct AlgorithmInfo
- {
- int PKID; /* 主键ID */
- int ActionTaskID; /* 算法任务ID */
- std::string ActionID; /* 算法ID */
- std::string ActionName; /* 算法名称 */
-
- AlgorithmInfo() = default;
- AlgorithmInfo(const AlgorithmInfo& other)
- : PKID(other.PKID), ActionID(other.ActionID), ActionName(other.ActionName), ActionTaskID(other.ActionTaskID) {}
- AlgorithmInfo& operator=(const AlgorithmInfo& other) {
- if (this != &other) {
- ActionID = other.ActionID;
- ActionName = other.ActionName;
- ActionTaskID = other.ActionTaskID;
- PKID = other.PKID;
- }
- return *this;
- }
- /* 对比是否相等 */
- bool operator==(const AlgorithmInfo& other) const {
- if(ActionID != other.ActionID)
- {
- return false;
- }
- if(ActionName != other.ActionName || ActionTaskID != other.ActionTaskID)
- {
- return false;
- }
- return true;
- }
- };
- /* 设备列表 */
- struct DeviceInfo
- {
- int PKID; /* 主键ID */
- int DeviceID; /* 设备ID */
- int DevicePort; /* 设备端口 */
- std::string DeviceName; /* 设备名称 */
- std::string DeviceIP; /* 设备IP */
- std::string DeviceSerial; /* 设备序列号 */
- std::string DeviceType; /* 设备类型 */
- std::string UserAccount; /* 用户账号 */
- std::string UserPassword; /* 用户密码 */
- std::vector<AlgorithmInfo> vecAlgorithmInfo; /* 算法信息 */
- DeviceInfo() = default;
- DeviceInfo(const DeviceInfo& other)
- : PKID(other.PKID),
- DeviceID(other.DeviceID),
- DevicePort(other.DevicePort),
- DeviceName(other.DeviceName),
- DeviceSerial(other.DeviceSerial),
- DeviceType(other.DeviceType),
- DeviceIP(other.DeviceIP),
- UserAccount(other.UserAccount),
- UserPassword(other.UserPassword),
- vecAlgorithmInfo(other.vecAlgorithmInfo) {}
- DeviceInfo& operator=(const DeviceInfo& other) {
- if (this != &other) {
- DeviceID = other.DeviceID;
- DevicePort = other.DevicePort;
- DeviceName = other.DeviceName;
- DeviceSerial = other.DeviceSerial;
- DeviceType = other.DeviceType;
- DeviceIP = other.DeviceIP;
- UserAccount = other.UserAccount;
- UserPassword = other.UserPassword;
- vecAlgorithmInfo = other.vecAlgorithmInfo;
- }
- return *this;
- }
- /* 对比是否相等 */
- bool operator==(const DeviceInfo& other) const {
- if(DeviceID != other.DeviceID) {
- return false;
- }
- else if(DeviceName != other.DeviceName || DeviceIP != other.DeviceIP) {
- return false;
- }
- else if(DeviceSerial != other.DeviceSerial || DeviceType != other.DeviceType) {
- return false;
- }
- else if(DevicePort != other.DevicePort || UserAccount != other.UserAccount || UserPassword != other.UserPassword) {
- return false;
- }
- return true;
- }
- /* 对比设备关联的算法信息是否相等 */
- bool isEqualAlgorithmInfo(const DeviceInfo& other) const {
- /* 算法数目不相等,直接返回false */
- if(vecAlgorithmInfo.size() != other.vecAlgorithmInfo.size()) {
- return false;
- }else {
- /* 算法数目相等,进一步对比算法信息 */
- bool isEquality = true;
- /* 逐步对比算法信息 */
- for(const auto& it0 : vecAlgorithmInfo) {
- bool isEq2 = true;
- for(const auto& it1 : other.vecAlgorithmInfo) {
- if(it0 == it1) {
- continue;
- }else {
- isEq2 = false;
- break;
- }
- }
- if(!isEq2) {
- isEquality = false;
- break;
- }
- }
- if(!isEquality) {
- return false;
- }
- }
- return true;
- }
- };
- #endif /* GLOBALINFO_H */
|