1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | /* $Id: cf_switches.h,v 1.13 2008-06-16 12:54:05 Singular 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 = 16; |
---|
22 | //}}} |
---|
23 | |
---|
24 | //{{{ class CFSwitches |
---|
25 | //{{{ docu |
---|
26 | // |
---|
27 | // class CFSwitches - manages boolean switches. |
---|
28 | // |
---|
29 | // An object of class `CFSwitches' is simply an array of booleans |
---|
30 | // with some comfortable access methods (`On()', `isOn()', etc.). |
---|
31 | // Each object may contain `CFSwitchesMax' switches. When a new |
---|
32 | // object of type `CFSwitches' is created, all its switches are |
---|
33 | // turned off. |
---|
34 | // |
---|
35 | // Note: No range checking is done when accessing switches. |
---|
36 | // |
---|
37 | // switches: the switches |
---|
38 | // |
---|
39 | //}}} |
---|
40 | //{{{ inline method docu |
---|
41 | // |
---|
42 | // void On ( int s ) |
---|
43 | // void Off ( int s ) |
---|
44 | // bool isOn ( int s ) const |
---|
45 | // bool isOff ( int s ) const |
---|
46 | // |
---|
47 | // On(), Off() - switch `s' on or off, resp. |
---|
48 | // |
---|
49 | // isOn(), isOff() - return true iff `s' is on or off, resp. |
---|
50 | // |
---|
51 | //}}} |
---|
52 | class CFSwitches |
---|
53 | { |
---|
54 | private: |
---|
55 | bool switches [CFSwitchesMax]; |
---|
56 | |
---|
57 | public: |
---|
58 | // constructors, destructors |
---|
59 | CFSwitches (); |
---|
60 | ~CFSwitches () {} |
---|
61 | |
---|
62 | // selectors |
---|
63 | void On ( int s ) { switches[s] = true; } |
---|
64 | void Off ( int s ) { switches[s] = false; } |
---|
65 | bool isOn ( int s ) const { return switches[s]; } |
---|
66 | bool isOff ( int s ) const { return ! switches[s]; } |
---|
67 | }; |
---|
68 | //}}} |
---|
69 | |
---|
70 | #endif /* ! INCL_CF_SWITCHES_H */ |
---|