| 对比新文件 |
| | |
| | | #include "pch.h" |
| | | #include "CCollectionEvent.h" |
| | | |
| | | |
| | | namespace SERVO { |
| | | CCollectionEvent::CCollectionEvent() |
| | | { |
| | | m_nCEID = 0; |
| | | } |
| | | |
| | | CCollectionEvent::CCollectionEvent(unsigned int id, const char* pszName, const char* pszDescription, std::vector<unsigned int>& prtids) |
| | | { |
| | | m_nCEID = id; |
| | | m_strName = pszName; |
| | | m_strDescription = pszDescription; |
| | | for (auto item : prtids) { |
| | | m_rptids.push_back(item); |
| | | } |
| | | } |
| | | |
| | | CCollectionEvent::~CCollectionEvent() |
| | | { |
| | | |
| | | } |
| | | |
| | | unsigned int CCollectionEvent::getEventId() |
| | | { |
| | | return m_nCEID; |
| | | } |
| | | |
| | | std::string& CCollectionEvent::getName() |
| | | { |
| | | return m_strName; |
| | | } |
| | | |
| | | std::string& CCollectionEvent::getDescription() |
| | | { |
| | | return m_strDescription; |
| | | } |
| | | |
| | | BOOL CCollectionEvent::addReport(CReport* pReport) |
| | | { |
| | | ASSERT(pReport); |
| | | if (getReport(pReport->getReportId()) != nullptr) { |
| | | return FALSE; |
| | | } |
| | | |
| | | m_reports.push_back(pReport); |
| | | return TRUE; |
| | | } |
| | | |
| | | BOOL CCollectionEvent::deleteReport(unsigned int nReportId) |
| | | { |
| | | BOOL bDelete = FALSE; |
| | | for (auto iter = m_reports.begin(); iter != m_reports.end(); ++iter) { |
| | | if (nReportId == (*iter)->getReportId()) { |
| | | m_reports.erase(iter); |
| | | bDelete = TRUE; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return bDelete; |
| | | } |
| | | |
| | | CReport* CCollectionEvent::getReport(unsigned int nReportId) |
| | | { |
| | | for (auto item : m_reports) { |
| | | if (nReportId == item->getReportId()) { |
| | | return item; |
| | | } |
| | | } |
| | | |
| | | return nullptr; |
| | | } |
| | | |
| | | void CCollectionEvent::setReport(unsigned int nReportId) |
| | | { |
| | | m_rptids.clear(); |
| | | if (nReportId != 0) { |
| | | m_rptids.push_back(nReportId); |
| | | } |
| | | } |
| | | |
| | | std::vector<CReport*>& CCollectionEvent::getReports() |
| | | { |
| | | return m_reports; |
| | | } |
| | | |
| | | std::vector<unsigned int>& CCollectionEvent::getReportIds() |
| | | { |
| | | return m_rptids; |
| | | } |
| | | |
| | | std::string CCollectionEvent::getReportIdsText() |
| | | { |
| | | std::string strResult, strName; |
| | | for (int i = 0; i < m_rptids.size(); i++) { |
| | | strResult += std::to_string(m_rptids[i]);// (getReport(m_rptids[i]) ? |
| | | if (nullptr == getReport(m_rptids[i])) { |
| | | strResult += ""; |
| | | } |
| | | if (i != m_rptids.size() - 1) { |
| | | strResult += ","; |
| | | } |
| | | } |
| | | |
| | | return strResult; |
| | | } |
| | | } |