void Tour_File::Setup (void) { if (File_Access () == CREATE) { File_Type ("New Tour Data File"); File_ID ("NewTour"); } else { File_Type ("Tour Data File"); File_ID ("Tour"); } hhold = person = tour = purpose = mode = origin = destination = stop_out = stop_in = start = end = group = 0; }
void Timing_File::Setup (void) { File_Type ("Timing Plan File"); File_ID ("Timing"); timing = phase = next = minimum = maximum = extend = yellow = red = ring = group = 0; }
void Sign_File::Setup (void) { File_Type ("Sign File"); File_ID ("Sign"); link = dir = sign = -1; }
void Count_File::Setup (void) { File_Type ("Traffic Count File"); File_ID ("Count"); anode = bnode = start = end = count = 0; }
void Event_File::Setup (void) { File_Type ("Event File"); File_ID ("Event"); hhold = person = mode = trip = leg = type = schedule = actual = link = offset = 0; }
void Fare_File::Setup (void) { File_Type ("Transit Fare File"); File_ID ("Fare"); from_zone = to_zone = from_mode = to_mode = period = type = fare = -1; }
void System_Event_File::Setup (void) { File_Type ("System Event File"); File_ID ("SysEvent"); time = type = node = plan = phase = ring = group = status = 0; }
void Location_File::Setup (void) { File_Type ("Location File"); File_ID ("Location"); location = link = dir = offset = setback = zone = -1; }
void Coordinator_File::Setup (void) { File_Type ("Signal Coordinator File"); File_ID ("Coordinator"); id = 0; }
void Parking_File::Setup (void) { File_Type ("Parking File"); File_ID ("Parking"); id = link = node = offset = type = use = space = start = end = hourly = daily = 0; }
void Location_File::Setup (void) { File_Type ("Activity Location File"); File_ID ("Location"); location = link = node = offset = x = y = zone = 0; }
void Boundary_File::Setup (void) { File_Type ("Boundary Speed File"); File_ID ("Boundary"); parking = start = end = speed = 0; }
void Ridership_File::Setup (void) { File_Type ("Transit Ridership File"); File_ID ("Ridership"); mode = route = run = stop = schedule = time = board = alight = load = factor = 0; }
void Node_File::Setup (void) { File_Type ("Node File"); File_ID ("Node"); node = x = y = z = subarea = part = -1; }
void Access_File::Setup (void) { File_Type ("Access File"); File_ID ("Access"); link = from_id = to_id = from_type = to_type = dir = time = cost = -1; }
void Veh_Type_File::Setup (void) { File_Type ("Vehicle Type File"); File_ID ("VehType"); type = sub_type = length = max_speed = max_accel = max_decel = use = capacity = 0; load = unload = method = min_dwell = max_dwell = 0; }
void Route_Nodes_File::Setup (void) { File_Type ("Route Nodes File"); File_ID ("RouteNodes"); dwell_flag = time_flag = speed_flag = false; route = node = dwell = time = speed = 0; }
void Connect_File::Setup (void) { File_Type ("Connection File"); File_ID ("Connect"); link = dir = to_link = lanes = to_lanes = in_high = out_high = -1; type = penalty = speed = capacity = -1; }
void Veh_Type_File::Setup (void) { File_Type ("Vehicle Type File"); File_ID ("VehType"); type = length = max_speed = max_accel = max_decel = op_cost = use = capacity = max_load = -1; occupancy = load = unload = method = min_dwell = max_dwell = subtype = -1; grade = fuel = fuel_cap = -1; }
void Factor_File::Setup (void) { Matrix_File::Setup (); File_Type ("Correction Factor File"); File_ID ("Factor"); factor = 0; }
void Link_Detail_File::Setup (void) { File_Type ("Link Detail File"); File_ID ("Detail"); link = dir = control = group = use = lanes = period = -1; left_merge = left = left_thru = thru = right_thru = right = right_merge = -1; lm_length = lt_length = rt_length = rm_length = -1; }
void Travel_Time_File::Setup (void) { File_Type ("Travel Time File"); File_ID ("TravelTime"); hhold = person = tour = trip = mode = base_start = started = start_diff = -1; base_end = ended = end_diff = mid_trip = ttime = -1; purpose = constraint = start_link = end_link = trip_start = trip_end = -1; }
void Link_Delay_File::Setup (void) { File_Type ("Link Delay File"); File_ID ("Delay"); Set_Nesting (turn_flag); link = dir = type = start = end = flow = time = -1; out_link = out_flow = out_time = -1; }
void Snapshot_File::Setup (void) { File_Type ("Snapshot File"); File_ID ("Snapshot"); hhold = vehicle = time = link = dir = lane = offset = speed = pass = type = -1; wait = diff = user = cell = x = y = z = bearing = blob = -1; location_flag = cell_flag = status_flag = compress = false; rec = 0; index = 0; units = METERS; }
void Skim_File::Setup (void) { Matrix_File::Setup (); File_Type ("Zone Skim File"); File_ID ("Skim"); transit_flag = drive_flag = other_flag = length_flag = true; total_flag = false; mode = count = walk = wait = transit = drive = other = length = cost = 0; time = variance = total = 0; }
void Plan_File::Setup (Memory_Type memory, Sort_Type sort) { num_record = num_plan = num_traveler = num_trip = max_data = 0; plan = NULL; File_Type ("Plan File"); File_ID ("Plan"); Setup_Record (); Plan_Memory (memory); Plan_Sort (sort); Node_Based_Flag (true); }
void Skim_File::Setup (void) { Matrix_File::Setup (); File_Type ("Skim File"); File_ID ("Skim"); time_format = SECONDS; len_format = FEET; time = walk = drive = transit = wait = other = length = cost = impedance = -1; time_flag = (Data_Type () == TIME_TABLE); table_flag = len_flag = false; mode = MAX_MODE; near_factor = 0; table = 0; ttime = 0; }
int Db_File::Num_Records (void) { if (!num_records && Check_File ()) { if (File_Format () == SQLITE3) { sqlite3_stmt *record_stmt; String sql; //---- get the number of rows ---- sql ("SELECT COUNT(*) FROM %s;") % File_ID (); if (sqlite3_prepare_v2 (db_file, sql.c_str (), -1, &record_stmt, 0) != SQLITE_OK) { exe->Warning ("Preparing Record Statement: ") << sqlite3_errmsg (db_file); } sqlite3_step (record_stmt); num_records = sqlite3_column_int (record_stmt, 0); sqlite3_finalize (record_stmt); } else if (File_Format () == BINARY || File_Format () == FIXED_COLUMN) { if (Max_Size () > 0) { num_records = (int) (File_Size () - First_Offset () + Max_Size () - 1) / Max_Size (); } } else { FILE *temp = f_open (Filename (), "rt"); if (temp != 0) { char buffer [4096]; while (fgets (buffer, sizeof (buffer), temp) != 0) { num_records++; } fclose (temp); } } } return (num_records); }
bool TPPlus_Matrix::Db_Open (string filename) { int i, type; char *license = 0; if (!Load_DLL ()) return (Status (NO_TPPLUS)); Set_Field_Numbers (); if (File_Access () == CREATE) { int len; unsigned char *header; Db_Field *fld_ptr; if (Num_Des () == 0 || Tables () == 0) return (false); if (Dbase_Format () == TRANPLAN) { type = TPLAN; } else { type = TPP; } TppMatMatSet (&fh, type, (char *) filename.c_str (), Num_Des (), Tables ()); header = fh->Mnames; for (i=0; i < Tables (); i++) { fld_ptr = Table_Field (i); if (fld_ptr->Decimal () == 0) { fh->Mspecs [i] = 'D'; } else { fh->Mspecs [i] = (unsigned char) fld_ptr->Decimal (); } len = (int) fld_ptr->Name ().length () + 1; memcpy (header, fld_ptr->Name ().c_str (), len); header += len; } if ((i = TppMatOpenOP (fh, (char *) File_ID ().c_str (), (char *) exe->Program (), 0, license, CUBE)) <= 0) { if (i < -1) { return (Status (TPPLUS_LICENSE)); } else { return (false); } } TppMatMatResize (&fh); } else { if (FileInquire ((char *) filename.c_str (), &fh) <= 0) return (false); if ((i = TppMatOpenIP (fh, license, CUBE)) <= 0) { if (i < -1) { return (Status (TPPLUS_LICENSE)); } else { return (false); } } Num_Org (fh->zones); Num_Des (fh->zones); Tables (fh->mats); } for (i=1; i <= Num_Des (); i++) { Add_Org (i); Add_Des (i); } fh->buffer = (void *) new char [fh->bufReq]; return (true); }
bool Db_File::Open (string path) { if (!path.empty ()) { Filename (path); } else if (filename.empty ()) { return (false); } if (Is_Open ()) { Close (); } else if (File_Format () == DEFAULT_FORMAT) { File_Format (DEFAULT_FORMAT); } bool create_flag, exist_flag; if (File_Access () == CREATE) { create_flag = true; exist_flag = f_exist (filename); num_records = record_num = max_record_num = 0; } else { create_flag = exist_flag = false; } if (!Db_Open (filename)) { if (exe->Send_Messages ()) { string message (((create_flag) ? "Creating " : "Opening ")); message += File_Type (); exe->File_Error (message, filename); } return (Status (NOT_OPEN)); } else { if (create_flag && !File_Type ().Starts_With ("New") && !File_Type ().Starts_With ("Output")) { File_Type (String ("New %s") % File_Type ()); if (File_Format () != SQLITE3) { File_ID (String ("New%s") % File_ID ()); } } //---- first open processing ---- if (first_open) { string name; num_files = 1; //---- print the filename ---- if (exe->Send_Messages ()) { if (!part_flag) { name = filename; } else { name = pathname + ".*"; part_num = 0; } exe->Print_Filename (1, File_Type (), name); } //---- delete existing files ---- if (exist_flag && part_flag) { int num; for (int part=1; part < 1000; part++) { num = exe->Partition_Number (part); if (num < 0) break; name = pathname + Extension (num); if (!f_exist (name)) break; remove (name.c_str ()); name += ".def"; remove (name.c_str ()); } } } if (File_Format () == SQLITE3) { if (sqlite3_exec (db_file, "PRAGMA synchronous = OFF", 0, 0, 0) != SQLITE_OK) { return (Status (NOT_OPEN)); } } return (Status (OK)); } }