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)  

bitfieldmeter.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 1999, 2006 Thomas Waldmann (ThomasWaldmann@gmx.de)
3 // based on work of Mike Romberg ( mike.romberg@noaa.gov )
4 //
5 // This file may be distributed under terms of the GPL
6 //
7 //
8 #ifndef _BITFIELDMETER_H_
9 #define _BITFIELDMETER_H_
10 
11 #include "meter.h"
12 #include "xosview.h"
13 #include "timer.h"
14 
15 
16 class BitFieldMeter : public Meter {
17 public:
18  BitFieldMeter( XOSView *parent, int numBits = 1, int numfields = 1,
19  const char *title = "",
20  const char *bitlegend = "", const char *fieldlegend = "",
21  int docaptions = 0, int dolegends = 0, int dousedlegends = 0 );
22  virtual ~BitFieldMeter( void );
23 
24  virtual void drawfields( int mandatory = 0 );
25  void drawBits( int mandatory = 0 );
26 
27  void setfieldcolor( int field, const char *color );
28  void setfieldcolor( int field, unsigned long color);
29  void docaptions( int val ) { docaptions_ = val; }
30  void dolegends( int val ) { dolegends_ = val; }
31  void dousedlegends( int val ) { dousedlegends_ = val; }
32  void reset( void );
33 
34  void setUsed (double val, double total);
35  void setBits(int startbit, unsigned char values);
36 
37  void draw( void );
38  void checkevent( void );
39  void disableMeter ( void );
40 
41  virtual void checkResources( void );
42 
43 protected:
45 
47  double *fields_;
49  int *lastvals_, *lastx_;
50  unsigned long *colors_;
51  unsigned long usedcolor_;
55  bool metric_;
57 
58  unsigned long onColor_, offColor_;
59  char *bits_, *lastbits_;
60  int numbits_;
61 
62  void SetUsedFormat ( const char * const str );
63  void drawfieldlegend( void );
64  void drawused( int mandatory );
65  bool checkX(int x, int width) const;
66 
67  void setNumFields(int n);
68  void setNumBits(int n);
69  char *fieldLegend_;
70 
71  void setfieldlegend(const char *fieldlegend);
72 
73 private:
75 protected:
78  // Before, we simply called _timer.report(), which returns usecs.
79  // However, it suffers from wrap/overflow/sign-bit problems, so
80  // instead we use doubles for everything.
82  double IntervalTimeInSecs() { return _timer.report_usecs()/1e6; }
83 };
84 
85 #endif
void docaptions(int val)
Definition: bitfieldmeter.h:29
char * fieldLegend_
Definition: bitfieldmeter.h:69
unsigned long usedcolor_
Definition: bitfieldmeter.h:51
void drawused(int mandatory)
void checkevent(void)
BitFieldMeter(XOSView *parent, int numBits=1, int numfields=1, const char *title="", const char *bitlegend="", const char *fieldlegend="", int docaptions=0, int dolegends=0, int dousedlegends=0)
UsedType print_
Definition: bitfieldmeter.h:52
void reset(void)
void drawBits(int mandatory=0)
unsigned long * colors_
Definition: bitfieldmeter.h:50
void dousedlegends(int val)
Definition: bitfieldmeter.h:31
void IntervalTimerStart()
Definition: bitfieldmeter.h:76
void setUsed(double val, double total)
virtual ~BitFieldMeter(void)
void setBits(int startbit, unsigned char values)
void IntervalTimerStop()
Definition: bitfieldmeter.h:77
virtual void drawfields(int mandatory=0)
void setNumFields(int n)
double * fields_
Definition: bitfieldmeter.h:47
void setNumBits(int n)
double lastused_
Definition: bitfieldmeter.h:48
void setfieldlegend(const char *fieldlegend)
void SetUsedFormat(const char *const str)
unsigned long onColor_
Definition: bitfieldmeter.h:58
double IntervalTimeInSecs()
Definition: bitfieldmeter.h:82
char * lastbits_
Definition: bitfieldmeter.h:59
void dolegends(int val)
Definition: bitfieldmeter.h:30
void draw(void)
bool checkX(int x, int width) const
virtual void checkResources(void)
unsigned long offColor_
Definition: bitfieldmeter.h:58
void drawfieldlegend(void)
int printedZeroTotalMesg_
Definition: bitfieldmeter.h:53
double IntervalTimeInMicrosecs()
Definition: bitfieldmeter.h:81
void disableMeter(void)
void setfieldcolor(int field, const char *color)
Definition: meter.h:14
const char * title(void)
Definition: meter.h:25
int docaptions_
Definition: meter.h:53
int dolegends_
Definition: meter.h:53
int dousedlegends_
Definition: meter.h:53
Definition: timer.h:22
double report_usecs(void) const
Definition: timer.h:32
void start(void)
Definition: timer.h:27
void stop(void)
Definition: timer.h:28