123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- #include "GlobalInfo.h"
- /* ====================================================================================
- * ******************************* 全局变量定义 **********************************
- * ====================================================================================*/
- int g_eventTimeVaild = 600; /* 事件时间有效性,单位秒,超过这个时间就认为是无效数据 */
- /* ====================================================================================
- * *************************** DeviceInfo成员函数 *******************************
- * ====================================================================================*/
- /* 对比是否相等 */
- bool DeviceInfo::operator==(const DeviceInfo& other)
- {
- 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 DeviceInfo::isEqualAlgorithmInfo(const std::vector<AlgorithmInfo>& other)
- {
- /* 算法数目不相等,直接返回false */
- if(vecAlgorithmInfo.size() != other.size()) {
- return false;
- }else {
- /* 算法数目相等,进一步对比算法信息 */
- bool isEquality = true;
- /* 逐步对比算法信息 */
- for(const auto& it0 : vecAlgorithmInfo) {
- bool isEq2 = true;
- for(const auto& it1 : other) {
- if(it0 == it1) {
- continue;
- }else {
- isEq2 = false;
- break;
- }
- }
- if(!isEq2) {
- isEquality = false;
- break;
- }
- }
- if(!isEquality) {
- return false;
- }
- }
- return true;
- }
- /* ====================================================================================
- * ************************** ListActionInfo成员函数 ****************************
- * ====================================================================================*/
- /* 添加关联信息,会自动进行重复判断,如果已有相同的信息,则跳过 */
- bool ListActionInfo::insertActionInfo(ActionInfo* info)
- {
- /* 先判断是否已经在列表中了 */
- if(findActionInList(info) == nullptr)
- {
- ActionInfo* pActionInfo = new ActionInfo;
- *pActionInfo = *info;
- listActionInfo.push_back(pActionInfo);
- }
- return true;
-
- }
- /* 删除信息 */
- bool ListActionInfo::deleteActionInfo(ActionInfo* info)
- {
- if(info == nullptr)
- {
- return false;
- }
- if(findActionInList(info) != nullptr)
- {
- listActionInfo.remove(info);
- delete info;
- info = nullptr;
- }
- return true;
- }
- /* 查找算法ID是否已在列表中 */
- ActionInfo* ListActionInfo::findActionInList(ActionInfo* pInfo)
- {
- for(const auto& it0 : listActionInfo)
- {
- if(*it0 == *pInfo)
- {
- return it0;
- }
- }
- return nullptr;
- }
- /* 清空容器 */
- void ListActionInfo::clear()
- {
- for(auto& it0 : listActionInfo)
- {
- delete it0;
- it0 = nullptr;
- }
- listActionInfo.clear();
- }
- /* ====================================================================================
- * *********************** ListRoomActionInfo成员函数 ***************************
- * ====================================================================================*/
- /* 添加关联信息,会自动进行重复判断,如果已有相同的room和action关联信息,则跳过 */
- bool ListRoomActionInfo::insertRoomActionInfo(const RoomActionInfo& info)
- {
- /* 先判断是否已经在列表中了 */
- if(findActionIDInList(info.RoomID, info.ActionID) == nullptr)
- {
- RoomActionInfo* pRoomActionInfo = new RoomActionInfo;
- *pRoomActionInfo = info;
- listRoomActionInfo.push_back(pRoomActionInfo);
- }
- return true;
- }
- /* 添加关联信息,会自动进行重复判断,如果已有相同的room和action关联信息,则跳过 */
- bool ListRoomActionInfo::insertRoomActionInfo(const int RoomID, const std::string& strActionID)
- {
- /* 先判断是否已经在列表中了 */
- if(findActionIDInList(RoomID, strActionID) == nullptr)
- {
- RoomActionInfo* pRoomActionInfo = new RoomActionInfo;
- pRoomActionInfo->RoomID = RoomID;
- pRoomActionInfo->ActionID = strActionID;
- listRoomActionInfo.push_back(pRoomActionInfo);
- }
- return true;
- }
- /* 清空容器 */
- void ListRoomActionInfo::clear()
- {
- for(auto& it0 : listRoomActionInfo)
- {
- delete it0;
- it0 = nullptr;
- }
- listRoomActionInfo.clear();
- }
- /* 添加算法信息,根据传入的算法信息,自动将其加入到对应的容器中 */
- void ListRoomActionInfo::addActionInfo(const ActionInfo& info)
- {
- auto pRAInfo = findActionIDInList(info.ChannelID, info.RoomID, info.ActionID);
- if(pRAInfo != nullptr)
- {
- pRAInfo->listCameraID.push_back(info.CameraID);
- }else {
- RoomActionInfo* pRoomActionInfo = new RoomActionInfo;
- pRoomActionInfo->ChannelID = info.ChannelID;
- pRoomActionInfo->RoomID = info.RoomID;
- pRoomActionInfo->ActionID = info.ActionID;
- pRoomActionInfo->RoomType = info.RoomType;
- pRoomActionInfo->strRoomName = info.strRoomName;
- pRoomActionInfo->listCameraID.push_back(info.CameraID);
- listRoomActionInfo.push_back(pRoomActionInfo);
- }
- }
- /* 查找算法ID是否已在列表中 */
- RoomActionInfo* ListRoomActionInfo::findActionIDInList(const int chnID, const int RoomID, const std::string& strActionID)
- {
- for(const auto& it0 : listRoomActionInfo)
- {
- if((it0->RoomID == RoomID) && (it0->ActionID == strActionID) && (it0->ChannelID == chnID))
- {
- return it0;
- }
- }
- return nullptr;
- }
|