1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | /* $Id: cf_switches.h,v 1.4 1997-07-23 15:55:19 schmidt Exp $ */ |
---|
3 | |
---|
4 | #ifndef INCL_CF_SWITCHES_H |
---|
5 | #define INCL_CF_SWITCHES_H |
---|
6 | |
---|
7 | //{{{ docu |
---|
8 | // |
---|
9 | // cf_switches.h - header to cf_switches.cc. |
---|
10 | // |
---|
11 | //}}} |
---|
12 | |
---|
13 | #include <config.h> |
---|
14 | |
---|
15 | //{{{ const int CFSwitchesMax |
---|
16 | //{{{ docu |
---|
17 | // |
---|
18 | // const CFSwitchesMax - maximum number of switches. |
---|
19 | // |
---|
20 | //}}} |
---|
21 | const int CFSwitchesMax = 10; |
---|
22 | //}}} |
---|
23 | |
---|
24 | //{{{ class CFSwitches |
---|
25 | //{{{ docu |
---|
26 | // |
---|
27 | // class CFSwitches - manages boolean switches. |
---|
28 | // |
---|
29 | // An object of type CFSwitches is simply an array of booleans |
---|
30 | // with some comfortable access methods (On, Off). Each object |
---|
31 | // may contain CFSwitchesMax switches. When a new object of type |
---|
32 | // CFSwitches is created, all its switches are turned off. |
---|
33 | // |
---|
34 | // Note: No range checking is done when accessing switches. |
---|
35 | // |
---|
36 | // switches: the switches |
---|
37 | // |
---|
38 | //}}} |
---|
39 | //{{{ inline method docu |
---|
40 | // |
---|
41 | // void On( int s ) |
---|
42 | // void Off( int s ) |
---|
43 | // bool isOn( int s ) |
---|
44 | // bool isOff( int s ) |
---|
45 | // |
---|
46 | // On(), Off() - switch s on or off, resp. |
---|
47 | // |
---|
48 | // isOn(), isOff() - return true iff s is on or off, resp. |
---|
49 | // |
---|
50 | //}}} |
---|
51 | class CFSwitches |
---|
52 | { |
---|
53 | private: |
---|
54 | bool switches [CFSwitchesMax]; |
---|
55 | public: |
---|
56 | CFSwitches(); |
---|
57 | ~CFSwitches() {} |
---|
58 | |
---|
59 | void On( int s ) { switches[s] = true; } |
---|
60 | void Off( int s ) { switches[s] = false; } |
---|
61 | bool isOn( int s ) const { return switches[s]; } |
---|
62 | bool isOff( int s ) const { return ! switches[s]; } |
---|
63 | }; |
---|
64 | //}}} |
---|
65 | |
---|
66 | #endif /* ! INCL_CF_SWITCHES_H */ |
---|