[493c477] | 1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
[bb82f0] | 2 | /* $Id: cf_switches.h,v 1.13 2008-06-16 12:54:05 Singular Exp $ */ |
---|
[2dd068] | 3 | |
---|
| 4 | #ifndef INCL_CF_SWITCHES_H |
---|
| 5 | #define INCL_CF_SWITCHES_H |
---|
| 6 | |
---|
[e743b3] | 7 | //{{{ docu |
---|
| 8 | // |
---|
| 9 | // cf_switches.h - header to cf_switches.cc. |
---|
| 10 | // |
---|
| 11 | //}}} |
---|
| 12 | |
---|
[b973c0] | 13 | #include <config.h> |
---|
| 14 | |
---|
[e743b3] | 15 | //{{{ const int CFSwitchesMax |
---|
| 16 | //{{{ docu |
---|
| 17 | // |
---|
| 18 | // const CFSwitchesMax - maximum number of switches. |
---|
| 19 | // |
---|
| 20 | //}}} |
---|
[bb82f0] | 21 | const int CFSwitchesMax = 16; |
---|
[e743b3] | 22 | //}}} |
---|
[2dd068] | 23 | |
---|
[e743b3] | 24 | //{{{ class CFSwitches |
---|
| 25 | //{{{ docu |
---|
| 26 | // |
---|
| 27 | // class CFSwitches - manages boolean switches. |
---|
| 28 | // |
---|
[a2952c] | 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. |
---|
[e743b3] | 34 | // |
---|
| 35 | // Note: No range checking is done when accessing switches. |
---|
| 36 | // |
---|
| 37 | // switches: the switches |
---|
| 38 | // |
---|
| 39 | //}}} |
---|
| 40 | //{{{ inline method docu |
---|
| 41 | // |
---|
[5586f4] | 42 | // void On ( int s ) |
---|
| 43 | // void Off ( int s ) |
---|
[f6590b9] | 44 | // bool isOn ( int s ) const |
---|
| 45 | // bool isOff ( int s ) const |
---|
[e743b3] | 46 | // |
---|
[a2952c] | 47 | // On(), Off() - switch `s' on or off, resp. |
---|
[e743b3] | 48 | // |
---|
[a2952c] | 49 | // isOn(), isOff() - return true iff `s' is on or off, resp. |
---|
[e743b3] | 50 | // |
---|
| 51 | //}}} |
---|
[2dd068] | 52 | class CFSwitches |
---|
| 53 | { |
---|
| 54 | private: |
---|
[e743b3] | 55 | bool switches [CFSwitchesMax]; |
---|
[a2952c] | 56 | |
---|
[2dd068] | 57 | public: |
---|
[a2952c] | 58 | // constructors, destructors |
---|
[5586f4] | 59 | CFSwitches (); |
---|
| 60 | ~CFSwitches () {} |
---|
[e743b3] | 61 | |
---|
[a2952c] | 62 | // selectors |
---|
[5586f4] | 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]; } |
---|
[2dd068] | 67 | }; |
---|
[e743b3] | 68 | //}}} |
---|
[2dd068] | 69 | |
---|
[493c477] | 70 | #endif /* ! INCL_CF_SWITCHES_H */ |
---|