forked from hishamhm/htop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Meter.h
126 lines (98 loc) · 3.39 KB
/
Meter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Meter
#define HEADER_Meter
/*
htop - Meter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#define METER_BUFFER_LEN 128
#include "ListItem.h"
#include "ProcessList.h"
typedef struct Meter_ Meter;
typedef void(*Meter_Init)(Meter*);
typedef void(*Meter_Done)(Meter*);
typedef void(*Meter_UpdateMode)(Meter*, int);
typedef void(*Meter_SetValues)(Meter*, char*, int);
typedef void(*Meter_Draw)(Meter*, int, int, int);
typedef struct MeterClass_ {
ObjectClass super;
const Meter_Init init;
const Meter_Done done;
const Meter_UpdateMode updateMode;
const Meter_Draw draw;
const Meter_SetValues setValues;
const int defaultMode;
const double total;
const int* attributes;
const char* name;
const char* uiName;
const char* caption;
const char maxItems;
char curItems;
} MeterClass;
#define As_Meter(htop_this_) ((MeterClass*)((htop_this_)->super.klass))
#define Meter_initFn(htop_this_) As_Meter(htop_this_)->init
#define Meter_init(htop_this_) As_Meter(htop_this_)->init((Meter*)(htop_this_))
#define Meter_done(htop_this_) As_Meter(htop_this_)->done((Meter*)(htop_this_))
#define Meter_updateModeFn(htop_this_) As_Meter(htop_this_)->updateMode
#define Meter_updateMode(htop_this_, m_) As_Meter(htop_this_)->updateMode((Meter*)(htop_this_), m_)
#define Meter_drawFn(htop_this_) As_Meter(htop_this_)->draw
#define Meter_doneFn(htop_this_) As_Meter(htop_this_)->done
#define Meter_setValues(htop_this_, c_, i_) As_Meter(htop_this_)->setValues((Meter*)(htop_this_), c_, i_)
#define Meter_defaultMode(htop_this_) As_Meter(htop_this_)->defaultMode
#define Meter_getItems(htop_this_) As_Meter(htop_this_)->curItems
#define Meter_setItems(htop_this_, n_) As_Meter(htop_this_)->curItems = (n_)
#define Meter_attributes(htop_this_) As_Meter(htop_this_)->attributes
#define Meter_name(htop_this_) As_Meter(htop_this_)->name
#define Meter_uiName(htop_this_) As_Meter(htop_this_)->uiName
struct Meter_ {
Object super;
Meter_Draw draw;
char* caption;
int mode;
int param;
void* drawData;
int h;
ProcessList* pl;
double* values;
double total;
};
typedef struct MeterMode_ {
Meter_Draw draw;
const char* uiName;
int h;
} MeterMode;
typedef enum {
CUSTOM_METERMODE = 0,
BAR_METERMODE,
TEXT_METERMODE,
GRAPH_METERMODE,
LED_METERMODE,
LAST_METERMODE
} MeterModeId;
typedef struct GraphData_ {
struct timeval time;
double values[METER_BUFFER_LEN];
} GraphData;
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
extern MeterClass Meter_class;
extern MeterClass* Meter_types[];
Meter* Meter_new(ProcessList* pl, int param, MeterClass* type);
void Meter_delete(Object* cast);
void Meter_setCaption(Meter* htop_this, const char* caption);
void Meter_setMode(Meter* htop_this, int modeIndex);
ListItem* Meter_toListItem(Meter* htop_this);
/* ---------- TextMeterMode ---------- */
/* ---------- BarMeterMode ---------- */
/* ---------- GraphMeterMode ---------- */
#define DrawDot(a,y,c) do { attrset(a); mvaddch(y, x+k, c); } while(0)
/* ---------- LEDMeterMode ---------- */
extern MeterMode* Meter_modes[];
#endif