]>
Commit | Line | Data |
---|---|---|
bf35a4a7 | 1 | /* |
ef57eb7b | 2 | * Copyright (C) 1996-2016 The Squid Software Foundation and contributors |
bf35a4a7 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
bf35a4a7 FC |
7 | */ |
8 | ||
bbc27441 AJ |
9 | #ifndef SQUID_YESNONONE_H_ |
10 | #define SQUID_YESNONONE_H_ | |
11 | ||
bf35a4a7 FC |
12 | /// Used for boolean enabled/disabled options with complex default logic. |
13 | /// Allows Squid to compute the right default after configuration. | |
14 | /// Checks that not-yet-defined option values are not used. | |
15 | class YesNoNone | |
16 | { | |
17 | // TODO: generalize to non-boolean option types | |
18 | public: | |
19 | YesNoNone(): option(0) {} | |
20 | ||
21 | /// returns true iff enabled; asserts if the option has not been configured | |
22 | operator void *() const; // TODO: use a fancy/safer version of the operator | |
23 | ||
24 | /// enables or disables the option; | |
25 | void configure(bool beSet); | |
26 | ||
27 | /// whether the option was enabled or disabled, by user or Squid | |
28 | bool configured() const { return option != 0; } | |
29 | ||
30 | private: | |
31 | enum { optUnspecified = -1, optDisabled = 0, optEnabled = 1 }; | |
32 | int option; ///< configured value or zero | |
33 | }; | |
34 | ||
bf35a4a7 | 35 | #endif /* SQUID_YESNONONE_H_ */ |
f53969cc | 36 |