/*------------------------------------------------------------------------
 *
 *  File:	o1k_timer.h
 *  Revision:	1.2
 *  Last Mod:	17:36:59, 03/01/97
 *
 *  Description:
 *     Defines O1kTimer object.
 *     
 *----------------------------------------------------------------------*/
#pragma ident	"@(#)o1k_timer.h	1.2\t97/03/01  "

#ifndef O1K_TIMER_H
#define O1K_TIMER_H

#define O1K_TIMER_NUM_STORED 10

/*------------------------------------------------------------------------
 *
 *  Class:	O1kTimer
 *
 * Description:
 *     
 *     An O1kTimer is a convenient object for keeping track
 *     of time and optionally data information. It can be used
 *     in different ways.
 *
 *     When used for just a timer, the routine timeStart() sets a
 *     start time. The routine timeEnd() sets and end time. The
 *     routine timeDiff() returns in msecs the time difference between
 *     the  start and end time.
 *
 *     The O1kTimer also can keep track of multiple time differences
 *     and (optionally) data points. When created, by default
 *     O1K_TIMER_NUM_STORED entries are created for time differences
 *     and data point values. To store data point values the routine
 *     timeEnd(val) is used which sets both the end time and records
 *     a data point value. The routine timeUpdate() is called after 
 *     calling timeEnd() or timeEnd(val). This routine saved the
 *     time difference between time start and time end and then
 *     indexes to the next storage location. If the storage locations
 *     are full, the the time differences and (if timeEnd(val) was used)
 *     data values are printed.
 *     
 *----------------------------------------------------------------------*/

class O1kTimer {

private:

  struct timeval t0;
  struct timeval t1;
  
  double* tdiff;
  int*    dval;
  int     index;
  int     num_times;
  unsigned char dval_flag;
  char    name[20];
  
public:
  
  O1kTimer(char* time_name, int ntimes = O1K_TIMER_NUM_STORED);
  ~O1kTimer();

  void timeEnd();
  void timeEnd(int val);
  void timeUpdate();
  double timeDiff();
  
  void timeStart();
};



#endif
