//  
//  Copyright (c) 1994 by Mike Romberg (  romberg@md.fsl.noaa.gov )
//  Debugged and Featurized by Michael Hemy
//
//  This file may be distributed under terms of the GPL
//

#ifndef _NETMETER_H_
#define _NETMETER_H_

#include <fstream.h>
#include "timer.h"

#define NETFILENAME "/proc/net/dev"

class NetMeter {
public:
  NetMeter( void );
  ~NetMeter( void );

  static void checkevent( void );
  float incoming( void ){ 
    
    float ftmp = (incoming_[(index_+1)%2] - incoming_[index_]) * 
      1000000 / lastinterval_; 
    if (ftmp < 0.0)
      return(0.0);
    return(ftmp);
 }
  float outgoing( void ){ 
    float ftmp = (outgoing_[(index_+1)%2] - outgoing_[index_]) *
      1000000 / lastinterval_; 
    if (ftmp < 0.0)
      return(0.0);
    return(ftmp);
  }
protected:
  static float incoming_[2], outgoing_[2];
  static Timer timer_;
  static int index_;
  static float lastinterval_;
private:
};

#endif
