mrDarker
2025-08-05 82114df5ce7233a3fd22c44f0c72a083feab539c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "stdafx.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;
    }
 
    void CCollectionEvent::setReport(CReport* pReport)
    {
        m_rptids.clear();
        m_reports.clear();
        if (pReport != nullptr) {
            m_rptids.push_back(pReport->getReportId());
            m_reports.push_back(pReport);
        }
    }
 
    unsigned int CCollectionEvent::getPortID()
    {
        if (m_reports.empty()) return -1;
        return m_reports.front()->getReportId();
    }
 
    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;
    }
 
    std::vector<CReport*>& CCollectionEvent::getReports()
    {
        return m_reports;
    }
 
    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;
    }
}