bool ModeChoice::Household_Processing (Db_File *fh) { Household_File *file = (Household_File *) fh; if (hhlist_flag) { if (First_Record ()) { if (!household_db.Max_Records (hhold_list.Num_Records ())) goto mem_error; } if (hhold_list.Get_Index (file->Household ()) == 0) return (false); } else if (First_Record ()) { if (!household_db.Max_Records (file->Max_Record_Number ())) goto mem_error; } //---- copy the data for user programs ---- household_db.Copy_Fields (file); if (!household_db.Add_Record ()) { Error ("Writing Household Database"); } return (false); mem_error: Error ("Insufficient Memory for Household Database"); return (false); }
bool LocationChoice::Household_Processing (Db_File *fh) { Household_Data *household_ptr; Household_File *file; file = (Household_File *) fh; if (First_Record ()) { int max_rec; if (hhlist_flag) { max_rec = hhold_list.Num_Records (); } else { max_rec = file->Estimate_Records (); } if (!household_data.Max_Records (max_rec)) goto mem_error; if (choice_flag) { if (!household_db.Max_Records (max_rec)) goto mem_error; } } if (hhlist_flag) { if (hhold_list.Get_Index (file->Household ()) == 0) return (false); } if (Demand_Service::Household_Processing (fh)) { household_ptr = household_data.New_Record (); household_ptr->Type (0); //---- copy the data for user programs ---- if (choice_flag) { household_db.Copy_Fields (file); if (!household_db.Add_Record ()) { Error ("Writing Household Database"); } } return (true); } return (false); mem_error: Error ("Insufficient Memory for Household Data"); return (false); }
bool RandomSelect::Get_Household_Data (Household_File &file, Household_Data &data, int partition) { if (!file.Nested ()) { int hhold, person, persons; Trip_Index trip_index; Select_Data select_data; Select_Map_Stat map_stat; hhold = file.Household (); if (hhold <= 0) return (false); if (select_households && !hhold_range.In_Range (hhold)) return (false); if (percent_flag && random.Probability () > select_percent) return (false); persons = file.Persons (); if (persons < 1) persons = 1; data.Household (hhold); data.Persons (persons); trip_index.Household (hhold); trip_index.Tour (0); trip_index.Trip (0); select_data.Type (0); select_data.Partition (partition); //---- save each person ---- for (person = 1; person <= persons; person++) { trip_index.Person (person); map_stat = select_map.insert (Select_Map_Data (trip_index, select_data)); if (!map_stat.second) { Warning (String ("Duplicate Selection Record = %d-%d-%d-%d") % trip_index.Household () % trip_index.Person () % trip_index.Tour () % trip_index.Trip ()); } } } return (false); }
int Data_Service::Put_Household_Data (Household_File &file, Household_Data &data) { Person_Itr person_itr; Location_Data *loc_ptr; int count = 0; loc_ptr = &location_array [data.Location ()]; file.Household (data.Household ()); file.Location (loc_ptr->Location ()); file.Persons (data.Persons ()); file.Workers (data.Workers ()); file.Vehicles (data.Vehicles ()); file.Type (data.Type ()); file.Partition (data.Partition ()); file.Num_Nest ((int) data.size ()); //file.Notes (data.Notes ()); if (!file.Write (false)) { Error (String ("Writing %s") % file.File_Type ()); } count++; for (person_itr = data.begin (); person_itr != data.end (); person_itr++) { file.Person (person_itr->Person ()); file.Age (person_itr->Age ()); file.Relate (person_itr->Relate ()); file.Gender (person_itr->Gender ()); file.Work (person_itr->Work ()); file.Drive (person_itr->Drive ()); if (!file.Write (true)) { Error (String ("Writing %s") % file.File_Type ()); } count++; } return (count); }