source: git/factory/cf_switches.h @ 9b88e6

fieker-DuValspielwiese
Last change on this file since 9b88e6 was fea494, checked in by Hans Schoenemann <hannes@…>, 10 years ago
format
  • Property mode set to 100644
File size: 1.8 KB
Line 
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**/
22const 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**/
39class CFSwitches
40{
41private:
42    bool switches [CFSwitchesMax];
43
44    CFSwitches ();
45public:
46    // constructors, destructors
47    ~CFSwitches () {}
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 */
Note: See TracBrowser for help on using the repository browser.