CCalendarDlg::~CCalendarDlg() { delete m_pCalendarCtrl; POSITION pos = g_CalendarData.GetStartPosition(); while (pos){ CalendarDataItem* p; time_t date; g_CalendarData.GetNextAssoc(pos, (void*&)date, (void*&)p); delete p; } }
void CedExporter::RecordLocations(const CePoint& p, CMapPtrToPtr& locIndex) { //CString s; //s.Format("Process point %s", p.FormatKey()); //Log(s); //FILE* log = 0; //if (p.FormatKey() == "2632804") // log = LogFile; CPtrArray locs; const CeLocation* loc = p.GetpVertex(); GetAllCoincidentLocations(loc, locs, LogFile); //if (locs.GetSize() != 1) //{ // CString s; // s.Format("%d locs", locs.GetSize()); // Log(s); //} for (int i=0; i<locs.GetSize(); i++) { void* pLoc = locs.GetAt(i); locIndex.SetAt(pLoc, 0); } }
void CCalendarDlg::OnCalendarMarkSelected() { CDWordArray dwaSelection; m_pCalendarCtrl->GetSelectedItems(dwaSelection); for(int i=0; i<dwaSelection.GetSize(); i++) { CalendarDataItem* p = NULL; if(!g_CalendarData.Lookup((void*)dwaSelection[i], (void*&)p)) { p = new CalendarDataItem; g_CalendarData.SetAt((void*)dwaSelection[i], (void*)p); } p->bMarked = true; } m_pCalendarCtrl->UpdateCells(); }
void CedExporter::CheckForExtraPoint(const CeLocation* loc, CMapPtrToPtr& locIndex, IdFactory& idf, CPtrArray& extraPoints) { // Nothing to do if the location has already been noted void* x; if (locIndex.Lookup((void*)loc, x)) return; CString msg; msg.Format("Recording extra point for %x", (int)loc); Log(msg); // Generate an extra point unsigned int entityId = 0; PointFeature_c* p = new PointFeature_c(idf, entityId, *loc); //msg.Format("Added point %d", p->Stub->InternalId); //Log(msg); extraPoints.Add(p); locIndex.SetAt((void*)loc, (void*)p->Stub->InternalId); // I don't think we really need the ID, but hold it just in case }
void CCalendarDlg::OnCalendarAddEntryToSelected() { // TODO: Add your command handler code here CCalendarInputDlg dlg; if(dlg.DoModal() == IDOK && !dlg.m_Text.IsEmpty()) { CDWordArray dwaSelection; m_pCalendarCtrl->GetSelectedItems(dwaSelection); for(int i=0; i<dwaSelection.GetSize(); i++) { CalendarDataItem* p = NULL; if(!g_CalendarData.Lookup((void*)dwaSelection[i], (void*&)p)) { p = new CalendarDataItem; p->bMarked = false; g_CalendarData.SetAt((void*)dwaSelection[i], (void*)p); } p->csLines.Add(dlg.m_Text); } m_pCalendarCtrl->UpdateCells(); } }
void CedExporter::LoadValidData(CMapPtrToPtr& validData, CeMap* cedFile) { #ifdef _CEDIT // Generate an index of valid objects void* ptr=0; os_typespec* curts=0; os_int32 count=0; os_object_cursor c(os_database::of(cedFile)); for ( c.first(); c.more(); c.next() ) { if ( c.current(ptr,curts,count) ) { validData.SetAt(ptr, 0); } } CString a; a.Format("Number of objects=%d", validData.GetCount()); AfxMessageBox(a); #endif }
HRESULT CCalendarDlg::CalendarDataCallback(CCalendarCtrl* pWnd, time_t date) { if(pWnd) { CalendarDataItem* p = NULL; if(g_CalendarData.Lookup((void*)date, (void*&)p)) { CCalendarCell* pCell = pWnd->GetCell(date); pCell->bMark = p->bMarked; pCell->csaLines.Copy(p->csLines); } } return 0; }
void CCalendarDlg::OnCalendarClearSelected() { CDWordArray dwaSelection; m_pCalendarCtrl->GetSelectedItems(dwaSelection); for(int i=0; i<dwaSelection.GetSize(); i++) { CalendarDataItem* p = NULL; if(g_CalendarData.Lookup((void*)dwaSelection[i], (void*&)p)) { p->bMarked = false; p->csLines.RemoveAll(); } } m_pCalendarCtrl->UpdateCells(); }
void CedExporter::CleanObjectLists(CeMap* cedFile) { #ifdef _CEDIT // Generate an index of valid objects CMapPtrToPtr validData; LoadValidData(validData, cedFile); // Scan again for lists. For each list, count how many refer to // invalid objects void* ptr=0; os_typespec* curts=0; os_int32 count=0; os_object_cursor c(os_database::of(cedFile)); int nBad = 0; int nCheck = 0; int nSkip = 0; for ( c.first(); c.more(); c.next() ) { if ( c.current(ptr,curts,count) ) { if (count > 1) { int junk = 0; continue; } nCheck++; CeClass* pc = (CeClass*)ptr; objectstore::touch(pc, false); if (ptr == (void*)0x3039a900 || ptr == (void*)0x30399b88 || ptr == (void*)0x30399660 || ptr == (void*)0x303988c0 || ptr == (void*)0x30398df8) { nSkip++; continue; } CeObjectList* pList = dynamic_cast<CeObjectList*>(pc); if (pList) { CeFixedArray<CeClass*> stuff(*pList); UINT4 numobj = stuff.GetCount(); for ( UINT4 i=0; i<numobj; i++ ) { void* pThing = (void*)stuff[i]; void* pRes; if (!validData.Lookup(pThing, pRes)) nBad++; } } } } CString t; t.Format("Number of bad refs=%d (nCheck=%d) (nSkip=%d)", nBad, nCheck, nSkip); AfxMessageBox(t); #endif }
int main() { CMapPtrToPtr map; if( !map.IsEmpty() ) _fail; if( map.GetCount() != 0 ) _fail; if( map.GetSize() != 0 ) _fail; map.SetAt( (void *)0, (void *)0 ); map.SetAt( (void *)1, (void *)1 ); map.SetAt( (void *)2, (void *)2 ); void *value; if( !map.Lookup( (void *)0, value ) ) _fail; if( value != (void *)0 ) _fail; if( !map.Lookup( (void *)1, value ) ) _fail; if( value != (void *)1 ) _fail; if( !map.Lookup( (void *)2, value ) ) _fail; if( value != (void *)2 ) _fail; if( map.Lookup( (void *)3, value ) ) _fail; POSITION position = map.GetStartPosition(); void *key; BOOL bFound0 = FALSE; BOOL bFound1 = FALSE; BOOL bFound2 = FALSE; while( position != NULL ) { map.GetNextAssoc( position, key, value ); switch( (INT_PTR)key ) { case 0: if( bFound0 ) _fail; if( value != (void *)0 ) _fail; bFound0 = TRUE; break; case 1: if( bFound1 ) _fail; if( value != (void *)1 ) _fail; bFound1 = TRUE; break; case 2: if( bFound2 ) _fail; if( value != (void *)2 ) _fail; bFound2 = TRUE; break; default: _fail; break; } } if( !bFound0 ) _fail; if( !bFound1 ) _fail; if( !bFound2 ) _fail; map.RemoveKey( (void *)0 ); if( map.Lookup( (void *)0, value ) ) _fail; _PASS; }