xosview  1.23
About: xosview is an X Windows based system monitor (cpu, memory, swap and network usage; interrupt and serial activities; load average).
  Fossies Dox: xosview-1.23.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

meter.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 1994, 1995, 2006 by Mike Romberg ( mike.romberg@noaa.gov )
3 //
4 // This file may be distributed under terms of the GPL
5 //
6 
7 #ifndef _METER_H_
8 #define _METER_H_
9 
10 #include "xosview.h"
11 #include <iostream>
12 
13 
14 class Meter {
15 public:
16  Meter( XOSView *parent, const char *title = "", const char *legend ="",
17  int docaptions = 0, int dolegends = 0, int dousedlegends = 0 );
18  virtual ~Meter( void );
19 
20  virtual const char *name( void ) const { return "Meter"; }
21  void resize( int x, int y, int width, int height );
22  virtual void checkevent( void ) = 0;
23  virtual void draw( void ) = 0;
24  void title( const char *title );
25  const char *title( void ) { return title_; }
26  void legend( const char *legend );
27  const char *legend( void ) { return legend_; }
28  void docaptions( int val ) { docaptions_ = val; }
29  void dolegends( int val ) { dolegends_ = val; }
30  void dousedlegends( int val ) { dousedlegends_ = val; }
31  int requestevent( void ){
32  if (priority_ == 0) {
33  std::cerr << "Warning: meter " << name() << " had an invalid priority "
34  << "of 0. Resetting to 1..." << std::endl;
35  priority_ = 1;
36  }
37  int rval = counter_ % priority_;
38  counter_ = (counter_ + 1) % priority_;
39  return !rval;
40  }
41 
42  int getX() const { return x_; }
43  int getY() const { return y_; }
44  int getWidth() const { return width_; }
45  int getHeight() const { return height_; }
46 
47  virtual void checkResources( void );
48 
49  static double scaleValue( double value, char *scale, bool metric );
50 
51 protected:
55  char *title_, *legend_;
56  unsigned long textcolor_;
58  double secondsPerSample() { return 1.0/samplesPerSecond(); }
59 
60 private:
61 };
62 
63 #endif
Definition: meter.h:14
virtual void draw(void)=0
double secondsPerSample()
Definition: meter.h:58
int x_
Definition: meter.h:53
int priority_
Definition: meter.h:54
const char * title(void)
Definition: meter.h:25
double samplesPerSecond()
Definition: meter.h:57
int docaptions_
Definition: meter.h:53
int getX() const
Definition: meter.h:42
int dolegends_
Definition: meter.h:53
int getHeight() const
Definition: meter.h:45
void resize(int x, int y, int width, int height)
Definition: meter.cc:59
virtual void checkResources(void)
Definition: meter.cc:33
int getY() const
Definition: meter.h:43
int y_
Definition: meter.h:53
void dolegends(int val)
Definition: meter.h:29
Meter(XOSView *parent, const char *title="", const char *legend="", int docaptions=0, int dolegends=0, int dousedlegends=0)
Definition: meter.cc:11
int dousedlegends_
Definition: meter.h:53
int width_
Definition: meter.h:53
char * legend_
Definition: meter.h:55
virtual const char * name(void) const
Definition: meter.h:20
static double scaleValue(double value, char *scale, bool metric)
Definition: meter.cc:67
unsigned long textcolor_
Definition: meter.h:56
int counter_
Definition: meter.h:54
const char * legend(void)
Definition: meter.h:27
void docaptions(int val)
Definition: meter.h:28
char * title_
Definition: meter.h:55
void dousedlegends(int val)
Definition: meter.h:30
int getWidth() const
Definition: meter.h:44
XOSView * parent_
Definition: meter.h:52
int height_
Definition: meter.h:53
virtual ~Meter(void)
Definition: meter.cc:26
virtual void checkevent(void)=0
int requestevent(void)
Definition: meter.h:31
double MAX_SAMPLES_PER_SECOND
Definition: xosview.cc:60