/* File: switch.cp Author: R. P. Futrelle Date: 8/8/98 Notice: Copyright 1998 by R. P. Futrelle and the College of Computer Science, Northeastern University Class: COM1204, Object-Oriented Design, Summer 1998. Proj: PS2.µ Metrowerks Code Warrior Mac. Done in IDE version 2.0.1. Purpose: Switch class methods defined. Modification history: 8/1/98: RPF. Started. 8/8/98: RPF. Switched from three to four states. */ #include "includes.h" // SWITCH int Switch::next_id = 0; Switch:: Switch() { id = next_id++; } // Here's a simple test that puts a dial packet in each phone // when time == 50 and looks inside to see what's there. void Switch:: run() { //loop over all phones when time = 3. if(sys->time == 50) { cout << "In switch run test at time == 50" << endl; for(int i = 0; i < num_phones ; i++) {connectors[i]->out->packet = new Packet(ring, null_string, -1, -1, -1); cout << "Control string in switch out line for phone: " << i << " is: " << *(connectors[i]->out->packet->control) << endl; states[i]->set_state(false, false, false, true); cout << "Switch phone state ringing slot for phone: " << i << " is: " << states[i]->ringing << endl; } } } // SWITCH_PHONE_STATE Switch_Phone_State:: Switch_Phone_State() : answered(false), dialing(false), picked_up(false), ringing(false) {} bool Switch_Phone_State:: is_state(bool a, bool d, bool p, bool r) { return ((answered == a) && (dialing == d) && (picked_up == p) && (ringing == r)); } void Switch_Phone_State:: set_state(bool a, bool d, bool p, bool r) { answered = a; dialing = d; picked_up = p; ringing = r; }