Listing 4: The result of the code generator running on Listing 3

class RunCall
{
public:
  void run()
  {
    SimpleCall call( "630-979-2001", "630-979-2000" );
  
    // Start the call. This will put us in a transient state.
    call.inputMakeCall();
    
    // Force an error to occur -- i.e., the "make call"
    // input is not allowed in the transient state.
    call.inputMakeCall();

    // Simulate a network route complete input
    call.inputRouteComplete();
  
    // Simulate the called party going off hook
    call.inputAnswer();

    // Simulate the called party hanging up
    call.inputDisconnectCalled();

    // Simulate the called party going back off hook
    call.inputAnswer();

    // Simulate the calling party going on hook
    call.inputDisconnectCalling();

    // Simulate call billing at end of call
    call.inputBillCall();

    // Done with call
    LogRecord lrecWATCH1(INFO, 1, 2, 53, 16, __LINE__); 
    lrecInsert( lrecWATCH1, 17, call ); 
    LogStore::GetInstance()->store(&lrecWATCH1);
  }
};

main()
{
  RunCall r;
  
  try
  {
    r.run();
    LogStore::GetInstance()->outputAll(cout);
  }
  catch( CallStateException& ex )
  {
    LogRecord lrecERROR1(MAJOR, 1, 11, 54, 16, __LINE__); 
    lrecInsert( lrecERROR1, 55, ex.getMsg().c_str() );
    LogStore::GetInstance()->store(&lrecERROR1);
  }
}
— End of Listing —