void Data_Service::Write_Connections (void) { Connect_File *file = (Connect_File *) System_File_Handle (NEW_CONNECTION); int dir, index, count; Connect_Data *connect_ptr; Dir_Data *dir_ptr; Link_Data *link_ptr; Int_Map_Itr itr; count = 0; Show_Message (String ("Writing %s -- Record") % file->File_Type ()); Set_Progress (); for (itr = link_map.begin (); itr != link_map.end (); itr++) { link_ptr = &link_array [itr->second]; for (dir=0; dir < 2; dir++) { index = (dir) ? link_ptr->BA_Dir () : link_ptr->AB_Dir (); if (index < 0) continue; Show_Progress (); dir_ptr = &dir_array [index]; for (index = dir_ptr->First_Connect (); index >= 0; index = connect_ptr->Next_Index ()) { connect_ptr = &connect_array [index]; count += Put_Connect_Data (*file, *connect_ptr); } } } Show_Progress (count); End_Progress (); file->Close (); Print (2, String ("%s Records = %d") % file->File_Type () % count); }
void Data_Service::Read_Connections (void) { Connect_File *file = (Connect_File *) System_File_Handle (CONNECTION); int num, in, out; Int2_Map_Stat map_stat; Connect_Data connect_rec; //---- store the lane connectivity data ---- Show_Message (String ("Reading %s -- Record") % file->File_Type ()); Set_Progress (); Initialize_Connects (*file); num = 0; while (file->Read ()) { Show_Progress (); connect_rec.Clear (); if (Get_Connect_Data (*file, connect_rec)) { in = connect_rec.Dir_Index (); out = connect_rec.To_Index (); map_stat = connect_map.insert (Int2_Map_Data (Int2_Key (in, out), (int) connect_array.size ())); if (!map_stat.second) { Dir_Data *dir_ptr; Link_Data *link_ptr; dir_ptr = &dir_array [in]; link_ptr = &link_array [dir_ptr->Link ()]; in = link_ptr->Link (); dir_ptr = &dir_array [out]; link_ptr = &link_array [dir_ptr->Link ()]; out = link_ptr->Link (); Warning (String ("Duplicate Link Connection = %d to %d") % in % out); continue; } else { connect_array.push_back (connect_rec); } } } End_Progress (); file->Close (); Print (2, String ("Number of %s Records = %d") % file->File_Type () % Progress_Count ()); num = (int) connect_array.size (); if (num && num != Progress_Count ()) { Print (1, String ("Number of %s Data Records = %d") % file->File_ID () % num); } if (num > 0) { System_Data_True (CONNECTION); Connect_Data *connect_ptr; Dir_Data *dir_ptr; //---- create directional link list ---- while (num--) { connect_ptr = &connect_array [num]; dir_ptr = &dir_array [connect_ptr->Dir_Index ()]; connect_ptr->Next_To (dir_ptr->First_Connect_To ()); dir_ptr->First_Connect_To (num); dir_ptr = &dir_array [connect_ptr->To_Index ()]; connect_ptr->Next_From (dir_ptr->First_Connect_From ()); dir_ptr->First_Connect_From (num); } } }