Added removeAll function to list class.
[dyninst.git] / common / h / tunableConst.h
1 /*
2  * tunableConstant - a constant that might be changed during execution.
3  *
4  * $Log: tunableConst.h,v $
5  * Revision 1.2  1994/02/28 23:58:28  hollings
6  * Changed global list to be a pointer to a list because I couldn't rely on
7  * the order of global constructors.
8  *
9  * Revision 1.1  1994/02/25  00:25:58  hollings
10  * added tunable constants.
11  *
12  *
13  */
14 #ifndef TUNABLE_CONST_H
15 #define TUNABLE_CONST_H
16
17 #include "util/h/stringPool.h"
18 #include "util/h/list.h"
19
20 typedef Boolean (*isValidFunc)(float newVale);
21 typedef void (*changeValCallBackFunc)(float value);
22
23 class tunableConstant {
24     public:
25         tunableConstant(float initialValue, 
26                         float min, 
27                         float max, 
28                         changeValCallBackFunc cb,
29                         char *name,
30                         char *desc);
31         tunableConstant(float initialValue, 
32                         isValidFunc, 
33                         changeValCallBackFunc cb,
34                         char *name,
35                         char *desc);
36         float getValue() { return value; }
37         char *getDesc() { return(desc); }
38         char *getName() { return(name); }
39         Boolean setValue(float newVal) {
40             if ((isValidValue) && isValidValue(newVal)) {
41                 value = newVal;
42                 if (newValueCallBack) newValueCallBack(newVal);
43                 return(TRUE);
44             } else if (simpleRangeCheck(newVal)) {
45                 value = newVal;
46                 if (newValueCallBack) newValueCallBack(newVal);
47                 return(TRUE);
48             } else {
49                 return(FALSE);
50             }
51         }
52         static List<tunableConstant*> *allConstants;
53         static stringPool *pool;
54     private:
55         char *desc;
56         char *name;
57         float value;
58         float min, max;
59         isValidFunc isValidValue;
60         Boolean simpleRangeCheck(float val);
61         changeValCallBackFunc newValueCallBack;
62 };
63
64 #endif