void CBallotRelSet::Open(const CDistrict* district, const CBaseunit* baseunit, const CVGroup* vgroup1, const CVGroup* vgroup2) { ASSERT(m_pDB != NULL); ASSERT(m_pDB->IsOpen()); ASSERT(GetSize() == 0); ASSERT(district != NULL); ASSERT(baseunit != NULL); if (district->KeyId() == -1) { Open(baseunit, vgroup1); } else { const CDistrictItem* pDistrictItem = m_pDB->Find(*district); if (pDistrictItem != NULL) { const CBaseunitKeyTable& baseunitTable = pDistrictItem->m_BaseunitKeyTable; int count = baseunitTable.GetSize(); for (int i = 0; i < count; i++) { const CBaseunit& curBaseunit = baseunitTable.GetAt(i); if (baseunit->KeyId() == -1 || *baseunit == curBaseunit) { const CBallotRelationshipItem* pBalRelItem = NULL; while ((pBalRelItem = m_pDB->FindNextBalRel(curBaseunit, pBalRelItem))){ if (!vgroup1 || vgroup1->KeyId() == -1 || (*vgroup1 == pBalRelItem->m_VGroup1 && !vgroup2) || (vgroup2 && *vgroup2 == pBalRelItem->m_VGroup2 && *vgroup1 == pBalRelItem->m_VGroup1)) Add(pBalRelItem); } } } m_CurIndex = 0; m_Open = TRUE; } } }
Figure 2: The function CBallotRelSet::Open from TSElection/TSElectionSet.cpp. This complex function is completely undocumented.