ns-allinone-2.35/nam-1.15/trace.cc
void
Trace::scan() {
  char * time;
  /*
   * Read the next line in the trace file and store its contents
   * depending on line type.
   */
  while (1) {
    TraceEvent & p = pending_;
    time = p.image;

    p.offset = nextLine();

    if (p.offset <= 0) {
      // We reached the beginning of the file
      pending_.time = TIME_EOF;
      // Reset the last event time tracker
      last_event_time_ = 0.0;
      //fprintf(stderr, "EOF Reached.\n");
      return;
    }

    // -----------------------------------------------
    // This -t * line skipping is a hack to
    // enable the wireless code to work properly.
    // All the -t * lines are parsed in tcl files
    // before the animation starts and reparsing them
    // seems to screw up the wireless stuff.
    // ------------------------------------------------
    
    // Skip over -t * lines
    while (*time != '\0') {
      // Find the -t flag
      if (*time == '-') {
        time++;
        if (*time == 't') {
          // Eat the whitespace
          time++;
          while (*time == ' ' || *time == '\t') {
            time++;
          } 

          // We should be pointing to the
          // -t flag value now
          if (*time == '*') {
            break;
          }
        }
      } else {
        time++;
      }
    }
    
    if (*time == '*') {
      // Notify user if their tracefile has initialization events that
      // are mixed in with animation events
      switch (direction_) {
        case FORWARDS:
          // last_event_time_ is initialized to 0.0 since events cannot happen before this time.
          if (last_event_time_ != 0.0) {
            fprintf(stderr, "Warning: Initialization event is mixed in with animation events.\n");
            fprintf(stderr, "%s", p.image);
            fprintf(stderr, "The above event should occur before all -t <time> animation events.\n\n");
            fprintf(stderr, "last_time_event_ %f\n", last_event_time_);
          }
          break;
      }
      last_event_time_ = 0.0;

      if (p.offset <= 0) {
	      pending_.time = TIME_EOF;
	      //fprintf(stderr, "EOF Reached.\n");
	      return;
      }
      continue;
    } 

    if (parse_table_->parseLine(p.image)) {
      switch (direction_) {
        // Notify user if their tracefile has records that are out of order
        case FORWARDS:
          if (pending_.time < last_event_time_) {
            fprintf(stderr, "Warning: Tracefile events are not sorted by time.\n");
            fprintf(stderr, "%s", p.image);
            fprintf(stderr, "The above event should occur at or after -t %f.\n\n",
                            last_event_time_);
          }
          break;
        case BACKWARDS:
          if (pending_.time > last_event_time_ && last_event_time_ != 0.0) {
            fprintf(stderr, "Warning: Tracefile events are not sorted by time.\n");
            fprintf(stderr, "%s", p.image);
            fprintf(stderr, "The above event should occur at or before -t %f.\n\n",
                            last_event_time_);
          }
          break;
      }
      last_event_time_ = pending_.time;
      return;

    } else {
      fprintf(stderr, "Parsing error in event.\n");
    }
    
  } // end while
  /* NOTREACHED */
}
//---------------------------------------------------------------------
// void
// Trace::scan()
//   - scan for the next valid nam event line in file
//   - Once everything becomes stable you can to get rid of all the
//     data type specific scan functions
//---------------------------------------------------------------------
void
Trace::scan()
scan for the next valid nam event line in file
Once everything becomes stable you can to get rid of all the
data type specific scan functions
void Trace :: scan () scan for the next valid nam event line in file Once everything becomes stable you can to get rid of all the data type specific scan functions
void
Trace::scan() {
  char * time;
  while (1) {
    TraceEvent & p = pending_;
    time = p.image;
    p.offset = nextLine();
    if (p.offset <= 0) {
      pending_.time = TIME_EOF;
      last_event_time_ = 0.0;
      return;
    }
    -
    while (*time != '\0') {
      if (*time == '-') {
        time++;
        if (*time == 't') {
          time++;
          while (*time == ' ' || *time == '\t') {
            time++;
          } 
          if (*time == '*') {
            break;
          }
        }
      } else {
        time++;
      }
    }
    if (*time == '*') {
      switch (direction_) {
        case FORWARDS:
          if (last_event_time_ != 0.0) {
            fprintf(stderr, "Warning: Initialization event is mixed in with animation events.\n");
            fprintf(stderr, "%s", p.image);
            fprintf(stderr, "The above event should occur before all -t <time> animation events.\n\n");
            fprintf(stderr, "last_time_event_ %f\n", last_event_time_);
          }
          break;
      }
      last_event_time_ = 0.0;
      if (p.offset <= 0) {
	      pending_.time = TIME_EOF;
	      return;
      }
      continue;
    } 
    if (parse_table_->parseLine(p.image)) {
      switch (direction_) {
        case FORWARDS:
          if (pending_.time < last_event_time_) {
            fprintf(stderr, "Warning: Tracefile events are not sorted by time.\n");
            fprintf(stderr, "%s", p.image);
            fprintf(stderr, "The above event should occur at or after -t %f.\n\n",
                            last_event_time_);
          }
          break;
        case BACKWARDS:
          if (pending_.time > last_event_time_ && last_event_time_ != 0.0) {
            fprintf(stderr, "Warning: Tracefile events are not sorted by time.\n");
            fprintf(stderr, "%s", p.image);
            fprintf(stderr, "The above event should occur at or before -t %f.\n\n",
                            last_event_time_);
          }
          break;
      }
      last_event_time_ = pending_.time;
      return;
    } else {
      fprintf(stderr, "Parsing error in event.\n");
    }
  } 
}
void Trace :: scan ( ) { char * time ; while ( 1 ) { TraceEvent & p = pending_ ; time = p . image ; p . offset = nextLine ( ) ; if ( p . offset <= 0 ) { pending_ . time = TIME_EOF ; last_event_time_ = 0.0 ; return ; } while ( * time != ' \0 ' ) { if ( * time == ' ' ) { time ++ ; if ( * time == ' ' ) { time ++ ; while ( * time == ' ' || * time == ' \t ' ) { time ++ ; } if ( * time == ' ' ) { break ; } } } else { time ++ ; } } if ( * time == ' ' ) { switch ( direction_ ) { case FORWARDS : if ( last_event_time_ != 0.0 ) { fprintf ( stderr , " \n " ) ; fprintf ( stderr , " " , p . image ) ; fprintf ( stderr , " \n \n " ) ; fprintf ( stderr , " \n " , last_event_time_ ) ; } break ; } last_event_time_ = 0.0 ; if ( p . offset <= 0 ) { pending_ . time = TIME_EOF ; return ; } continue ; } if ( parse_table_ -> parseLine ( p . image ) ) { switch ( direction_ ) { case FORWARDS : if ( pending_ . time < last_event_time_ ) { fprintf ( stderr , " \n " ) ; fprintf ( stderr , " " , p . image ) ; fprintf ( stderr , " \n \n " , last_event_time_ ) ; } break ; case BACKWARDS : if ( pending_ . time > last_event_time_ && last_event_time_ != 0.0 ) { fprintf ( stderr , " \n " ) ; fprintf ( stderr , " " , p . image ) ; fprintf ( stderr , " \n \n " , last_event_time_ ) ; } break ; } last_event_time_ = pending_ . time ; return ; } else { fprintf ( stderr , " \n " ) ; } } }
void
Trace::scan()
 scan for the next valid nam event line in file
 Once everything becomes stable you can to get rid of all the
data type specific scan functions
void Trace :: scan () scan for the next valid nam event line in file Once everything becomes stable you can to get rid of all the data type specific scan functions
/*
   * Read the next line in the trace file and store its contents
   * depending on line type.
   */ // We reached the beginning of the file // Reset the last event time tracker //fprintf(stderr, "EOF Reached.\n"); // ----------------------------------------------- // This -t * line skipping is a hack to // enable the wireless code to work properly. // All the -t * lines are parsed in tcl files // before the animation starts and reparsing them // seems to screw up the wireless stuff. // ------------------------------------------------ // Skip over -t * lines // Find the -t flag // Eat the whitespace // We should be pointing to the // -t flag value now // Notify user if their tracefile has initialization events that // are mixed in with animation events // last_event_time_ is initialized to 0.0 since events cannot happen before this time. //fprintf(stderr, "EOF Reached.\n"); // Notify user if their tracefile has records that are out of order // end while /* NOTREACHED */