/////////////////////////////////////////////////////////////////////////////////////////////////
//
// Clock.h: class definition for Clock class,
//
// Copyright 2006 National Center for Ecological Analysis and Synthesis (NCEAS)
// Author: Rick Reeves, NCEAS Scientific Programmer
// 
// Please see the top of each class method for descriptions
//
// Note: the header file clock.h contains the formal class definition
//
/////////////////////////////////////////////////////////////////////////////////////////////////             
#ifndef CLOCKCLASS_H  
#define CLOCKCLASS_H  
#include <time.h>

#define RANDOM_CACHE_SIZE 50000

class Clock
{
   private:       
      time_t lCurrentTime;    
      time_t lStartingTime;                                               
      time_t lBaseTime;    
      time_t ulElapsedTimeInSec;          
//
// RR 12/4/06 Add pseudo-random number generation functionality.
//
      unsigned long lRandomCacheCount;
      unsigned long lNextRandomVal;
      void SetRandomSeed();
      unsigned long FillRandomCache();
      
      int RandomCache[RANDOM_CACHE_SIZE];
   public:
      Clock();
      ~Clock();
      const unsigned long GetNextTick(void);        
      const unsigned long GetStartingTime(void);
      const unsigned long GetCurrentTime(void);
      const unsigned long GetElapsedTimeInSec(void);      
      void DelayForCentiSec(clock_t WaitTimeInCentiSec);
//
// RR 12/4/06 routine gets next random value, refilling cache if necessary
//
      int GetNextRandValFromCache();
};          
#endif
