cf_switches.h
Go to the documentation of this file.
1 /* emacs edit mode for this file is -*- C++ -*- */
2 
3 /**
4  *
5  * @file cf_switches.h
6  *
7  * header to cf_switches.cc.
8  *
9 **/
10 
11 
12 #ifndef INCL_CF_SWITCHES_H
13 #define INCL_CF_SWITCHES_H
14 
15 // #include "config.h"
16 
17 /** const int CFSwitchesMax
18  *
19  * const CFSwitchesMax - maximum number of switches.
20  *
21 **/
22 const int CFSwitchesMax = 8;
23 
24 /** class CFSwitches
25  *
26  * class CFSwitches - manages boolean switches.
27  *
28  * An object of class `CFSwitches' is simply an array of booleans
29  * with some comfortable access methods (`On()', `isOn()', etc.).
30  * Each object may contain `CFSwitchesMax' switches. When a new
31  * object of type `CFSwitches' is created, all its switches are
32  * turned off.
33  *
34  * Note: No range checking is done when accessing switches.
35  *
36  * switches: the switches
37  *
38 **/
40 {
41 private:
43 
44  CFSwitches ();
45 public:
46  // constructors, destructors
48 
49  static inline CFSwitches& getInstance()
50  {
51  static CFSwitches singleton;
52  return singleton;
53  }
54  // selectors
55  /// switch 's' on
56  void On ( int s ) { switches[s] = true; }
57  /// switch 's' off
58  void Off ( int s ) { switches[s] = false; }
59  /// check if 's' is on
60  bool isOn ( int s ) const { return switches[s]; }
61  /// check if 's' is off
62  bool isOff ( int s ) const { return ! switches[s]; }
63 };
64 /** CFSwitches cf_glob_switches;
65  *
66  * cf_glob_switches - factory switches.
67  *
68  * This is the only object of type CFSwitches in factory. It is
69  * used either directly in the low level algorithms or by the
70  * functions On(), Off(), isOn() defined in canonicalform.cc.
71  *
72 **/
73 // extern CFSwitches& cf_glob_switches;
74 // CFSwitches& cf_glob_switches = CFSwitches::getInstance();
75 #define cf_glob_switches (CFSwitches::getInstance())
76 
77 #endif /* ! INCL_CF_SWITCHES_H */
bool isOn(int s) const
check if 's' is on
Definition: cf_switches.h:60
const CanonicalForm int s
Definition: facAbsFact.cc:55
class CFSwitches
Definition: cf_switches.h:39
void On(int s)
switch 's' on
Definition: cf_switches.h:56
bool switches[CFSwitchesMax]
Definition: cf_switches.h:42
CFSwitches()
CFSwitches::CFSwitches ()
Definition: cf_switches.cc:27
void Off(int s)
switch 's' off
Definition: cf_switches.h:58
const int CFSwitchesMax
const int CFSwitchesMax
Definition: cf_switches.h:22
static CFSwitches & getInstance()
Definition: cf_switches.h:49
bool isOff(int s) const
check if 's' is off
Definition: cf_switches.h:62